![]() |
A class that allows you to build a NamedData structure. More...
#include <SurgSim/DataStructures/NamedDataBuilder.h>
Public Member Functions | |
NamedDataBuilder () | |
Constructs an empty builder object. More... | |
NamedData< T > | createData () const |
Produces a NamedData object with an immutable set of names and indices. More... | |
std::shared_ptr< NamedData< T > > | createSharedData () const |
Produces a shared pointer to an empty NamedData object with an immutable set of names and indices. More... | |
int | addEntry (const std::string &name) |
Creates a new entry for the specified name. More... | |
void | addEntriesFrom (const std::vector< std::string > &names) |
Create new entries from a vector of names. More... | |
template<typename U > | |
void | addEntriesFrom (const NamedDataBuilder< U > &builder) |
Create new entries from another NamedDataBuilder. More... | |
template<typename U > | |
void | addEntriesFrom (const NamedData< U > &data) |
Create new entries from an already initialized NamedData. More... | |
void | addEntriesFrom (const IndexDirectory &directory) |
Create new entries from an IndexDirectory. More... | |
int | getIndex (const std::string &name) const |
Given a name, return the corresponding index (or -1). More... | |
std::string | getName (int index) const |
Given an index, return the corresponding name (or ""). More... | |
const std::vector< std::string > & | getAllNames () const |
Get a list of all the names available in the builder. More... | |
bool | hasEntry (const std::string &name) const |
Check whether the specified name exists in the builder. More... | |
size_t | size () const |
Check the number of existing entries in the builder. More... | |
int | getNumEntries () const |
Check the number of existing entries in the builder. More... | |
Private Attributes | |
IndexDirectory | m_directory |
The mapping between names and indices that will be used to create the NamedData instance. More... | |
A class that allows you to build a NamedData structure.
Since the data layout of a NamedData object cannot be modified, this class can be helpful in initially setting up the names and their corresponding indices. You can add entries to the builder using addEntry and addEntriesFrom calls, then create the NamedData instance with createData() or createSharedData().
|
inline |
Constructs an empty builder object.
|
inline |
Create new entries from a vector of names.
names | The names. |
|
inline |
Create new entries from another NamedDataBuilder.
typename | U The data type of the other NamedDataBuilder. |
builder | The other builder. |
|
inline |
|
inline |
Create new entries from an IndexDirectory.
directory | The index directory object. |
|
inline |
Creates a new entry for the specified name.
name | The name, which should be non-empty and should not already exist in the data. |
|
inline |
|
inline |
|
inline |
Get a list of all the names available in the builder.
|
inline |
Given a name, return the corresponding index (or -1).
name | The name. |
|
inline |
Given an index, return the corresponding name (or "").
index | The index. |
|
inline |
|
inline |
Check whether the specified name exists in the builder.
name | The name. |
|
inline |
Check the number of existing entries in the builder.
|
private |
The mapping between names and indices that will be used to create the NamedData instance.