12 m_collectionIDs(std::move(ids)), m_names(std::move(names)), m_mutex(std::make_unique<std::mutex>()) {
16 m_collectionIDs(ids), m_names(names), m_mutex(std::make_unique<std::mutex>()) {
20 std::lock_guard<std::mutex> lock(*m_mutex);
21 const auto result = std::find(begin(m_collectionIDs), end(m_collectionIDs), ID);
22 const auto index = std::distance(m_collectionIDs.begin(), result);
23 return m_names[index];
27 std::lock_guard<std::mutex> lock(*m_mutex);
28 const auto result = std::find(begin(m_names), end(m_names),
name);
29 const auto index = std::distance(m_names.begin(), result);
30 return m_collectionIDs[index];
34 std::lock_guard<std::mutex> lock(*m_mutex);
35 std::cout <<
"CollectionIDTable" << std::endl;
36 for (
unsigned i = 0; i < m_names.size(); ++i) {
37 std::cout <<
"\t" << m_names[i] <<
" : " << m_collectionIDs[i] << std::endl;
42 std::lock_guard<std::mutex> lock(*m_mutex);
43 const auto result = std::find(begin(m_names), end(m_names),
name);
44 return result != end(m_names);
48 std::lock_guard<std::mutex> lock(*m_mutex);
49 const auto result = std::find(begin(m_names), end(m_names),
name);
51 if (result == m_names.end()) {
52 m_names.emplace_back(
name);
54 m_collectionIDs.emplace_back(ID);
56 const auto index = std::distance(m_names.begin(), result);
57 ID = m_collectionIDs[index];
void print() const
Prints collection information.
bool present(const std::string &name) const
Check if collection name is known.
int add(const std::string &name)
int collectionID(const std::string &name) const
return collection ID for given name
const std::string name(int collectionID) const
return name for given collection ID