#include <GeneralRegistry.h>
Public Member Functions | |
GeneralRegistry (const std::string &name) | |
std::size_t | size () const |
std::size_t | id (const Key &key) const |
bool | keyExists (const Key &key) const |
bool | idExists (const std::size_t id) const |
const Item & | item (const std::size_t id) const |
Protected Member Functions | |
const Item & | itemNonLocking (const std::size_t id) const |
template<typename CreateItem > | |
std::size_t | registerItem (const Key &key, CreateItem &create_item) |
Registers an item with key key if said key does not exist. More... | |
Protected Attributes | |
const std::string | _name |
The name of this registry; used in error handling. More... | |
std::unordered_map< Key, std::size_t, KeyHash > | _key_to_id |
Map of keys to IDs. More... | |
std::deque< Item > | _id_to_item |
Vector of IDs to Items. More... | |
std::mutex | _key_to_id_mutex |
Mutex for locking access to _key_to_id NOTE: These can be changed to shared_mutexes once we get C++17. More... | |
std::mutex | _id_to_item_mutex |
Mutex for locking access to _id_to_item NOTE: These can be changed to shared_mutexes once we get C++17. More... | |
Definition at line 19 of file GeneralRegistry.h.
GeneralRegistry< Key, Item, KeyHash >::GeneralRegistry | ( | const std::string & | name | ) |
Definition at line 83 of file GeneralRegistry.h.
std::size_t GeneralRegistry< Key, Item, KeyHash >::id | ( | const Key & | key | ) | const |
key
Definition at line 97 of file GeneralRegistry.h.
Referenced by dataLoad(), and SolutionInvalidity::syncIteration().
bool GeneralRegistry< Key, Item, KeyHash >::idExists | ( | const std::size_t | id | ) | const |
id
is registered Definition at line 116 of file GeneralRegistry.h.
const Item & GeneralRegistry< Key, Item, KeyHash >::item | ( | const std::size_t | id | ) | const |
key
(thread safe) Definition at line 124 of file GeneralRegistry.h.
Referenced by dataStore(), SolutionInvalidity::printDebug(), SolutionInvalidity::summaryTable(), SolutionInvalidity::syncIteration(), and SolutionInvalidity::transientTable().
|
protected |
key
(not thread safe) Definition at line 132 of file GeneralRegistry.h.
bool GeneralRegistry< Key, Item, KeyHash >::keyExists | ( | const Key & | key | ) | const |
key
is registered Definition at line 108 of file GeneralRegistry.h.
Referenced by dataLoad(), and SolutionInvalidity::syncIteration().
|
protected |
Registers an item with key key
if said key does not exist.
key | The key |
create_item | Lambda called to create an item if the key does not exist. Takes a single argument std::size_t which is the new ID and should return an Item |
Definition at line 142 of file GeneralRegistry.h.
std::size_t GeneralRegistry< Key, Item, KeyHash >::size | ( | ) | const |
Definition at line 89 of file GeneralRegistry.h.
|
protected |
|
mutableprotected |
Mutex for locking access to _id_to_item NOTE: These can be changed to shared_mutexes once we get C++17.
Definition at line 79 of file GeneralRegistry.h.
|
protected |
Map of keys to IDs.
Definition at line 70 of file GeneralRegistry.h.
|
mutableprotected |
Mutex for locking access to _key_to_id NOTE: These can be changed to shared_mutexes once we get C++17.
Definition at line 76 of file GeneralRegistry.h.
|
protected |
The name of this registry; used in error handling.
Definition at line 67 of file GeneralRegistry.h.