16 #ifndef SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H
17 #define SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H
20 #include <unordered_map>
25 namespace DataStructures
47 if (name.length() == 0)
67 if ((index < 0) || (index >= static_cast<int>(
m_names.size())))
79 const std::vector<std::string>&
getAllNames()
const;
87 return ((name.length() > 0) && (
m_indices.count(name) > 0));
103 return static_cast<int>(
m_names.size());
107 template <
typename T>
127 int addEntry(
const std::string& name);
140 #endif // SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H
Definition: DriveElementFromInputBehavior.cpp:27
std::string getName(int index) const
Given an index, return the corresponding name (or "").
Definition: IndexDirectory.h:65
IndexDirectory()
Create an empty directory object.
Definition: IndexDirectory.cpp:24
std::vector< std::string > m_names
The array of entry names, in index order.
Definition: IndexDirectory.h:131
const std::vector< std::string > & getAllNames() const
Get a list of all the names available from the index directory.
Definition: IndexDirectory.cpp:36
A class that allows you to build a NamedData structure.
Definition: NamedDataBuilder.h:36
int addEntry(const std::string &name)
Create a new entry for the specified name.
Definition: IndexDirectory.cpp:53
int getIndex(const std::string &name) const
Given a name, return the corresponding index (or -1).
Definition: IndexDirectory.h:45
A simple bidirectional mapping between names (strings) and distinct consecutive non-negative indices...
Definition: IndexDirectory.h:32
std::unordered_map< std::string, int > m_indices
A mapping of entry names to indices.
Definition: IndexDirectory.h:134
int getNumEntries() const
Check the number of existing entries in the directory.
Definition: IndexDirectory.h:101
size_t size() const
Check the number of existing entries in the directory.
Definition: IndexDirectory.h:93
A class that allows you to build a DataGroup structure.
Definition: DataGroupBuilder.h:38
bool hasEntry(const std::string &name) const
Check whether the specified name exists in the directory.
Definition: IndexDirectory.h:85
IndexDirectory & operator=(const IndexDirectory &directory)
Assignment operator.
Definition: IndexDirectory.cpp:46