16 #ifndef SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H 17 #define SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H 20 #include <unordered_map> 25 namespace DataStructures
47 if (name.length() == 0)
51 auto entry = m_indices.find(name);
52 if (entry == m_indices.cend())
67 if ((index < 0) || (index >= static_cast<int>(m_names.size())))
73 return m_names[index];
79 const std::vector<std::string>&
getAllNames()
const;
87 return ((name.length() > 0) && (m_indices.count(name) > 0));
95 return m_names.size();
103 return static_cast<int>(m_names.size());
107 template <
typename T>
127 int addEntry(
const std::string& name);
131 std::vector<std::string> m_names;
134 std::unordered_map<std::string, int> m_indices;
140 #endif // SURGSIM_DATASTRUCTURES_INDEXDIRECTORY_H Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
const std::vector< std::string > & getAllNames() const
Get a list of all the names available from the index directory.
Definition: IndexDirectory.cpp:36
IndexDirectory()
Create an empty directory object.
Definition: IndexDirectory.cpp:24
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
size_t size() const
Check the number of existing entries in the directory.
Definition: IndexDirectory.h:93
bool hasEntry(const std::string &name) const
Check whether the specified name exists in the directory.
Definition: IndexDirectory.h:85
std::string getName(int index) const
Given an index, return the corresponding name (or "").
Definition: IndexDirectory.h:65
A class that allows you to build a DataGroup structure.
Definition: DataGroupBuilder.h:38
IndexDirectory & operator=(const IndexDirectory &directory)
Assignment operator.
Definition: IndexDirectory.cpp:46
int getNumEntries() const
Check the number of existing entries in the directory.
Definition: IndexDirectory.h:101