SST
12.0.0
StructuralSimulationToolkit
|
#include <sharedMap.h>
Public Types | |
typedef std::map< keyT, valT > ::const_iterator | const_iterator |
typedef std::map< keyT, valT > ::const_reverse_iterator | const_reverse_iterator |
Public Types inherited from SST::Shared::SharedObject | |
enum | verify_type { VERIFY_UNINITIALIZED, FE_VERIFY, INIT_VERIFY, NO_VERIFY } |
Enum of verify types. | |
Public Member Functions | |
int | initialize (const std::string &obj_name, verify_type v_type=FE_VERIFY) |
Initialize the SharedMap. More... | |
size_t | size () const |
Get the size of the map. More... | |
bool | empty () const |
Tests if the map is empty. More... | |
size_t | count (const keyT &k) const |
Counts elements with a specific key. More... | |
const_iterator | find (const keyT &key) const |
Searches the container for an element with a key equivalent to k and returns an iterator to it if found, otherwise it returns an iterator to SharedMap::end(). More... | |
const_iterator | begin () const |
Get const_iterator to beginning of underlying map. | |
const_iterator | end () const |
Get const_iterator to end of underlying map. | |
const_reverse_iterator | rbegin () const |
Get const_reverse_iterator to beginning of underlying map. | |
const_reverse_iterator | rend () const |
Get const_reverse_iterator to end of underlying map. | |
const_iterator | lower_bound (const keyT &key) const |
Returns an iterator pointing to the first element in the container whose key is not considered to go before k (i.e., either it is equivalent or goes after). More... | |
const_iterator | upper_bound (const keyT &key) const |
Returns an iterator pointing to the first element in the container whose key is considered to go after k. More... | |
void | publish () |
Indicate that the calling element has written all the data it plans to write. More... | |
bool | isFullyPublished () |
Check whether all instances of this SharedMap have called publish(). More... | |
void | write (const keyT &key, const valT &value) |
Write data to the map. More... | |
const valT & | operator[] (const keyT &key) const |
Read data from the map. More... | |
const valT & | mutex_read (const keyT &key) const |
Read data from the map. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from SST::Shared::SharedObject | |
void | incPublishCount (SharedObjectData *data) |
int | incShareCount (SharedObjectData *data) |
Static Protected Attributes inherited from SST::Shared::SharedObject | |
static SharedObjectDataManager | manager |
SharedMap class.
The class is templated to allow for Map of any non-pointer type as value. The type must be serializable.
|
inline |
Counts elements with a specific key.
Becuase this is not a multimap, it will either return 1 or 0.
|
inline |
Tests if the map is empty.
|
inline |
Searches the container for an element with a key equivalent to k and returns an iterator to it if found, otherwise it returns an iterator to SharedMap::end().
key | key to search for |
|
inline |
Initialize the SharedMap.
obj_name | Name of the object. This name is how the object is uniquely identified across ranks. |
verify_mode | Specifies how multiply written data should be verified. Since the underlying map knows if the data has already been written, FE_VERIFY and INIT_VERIFY simply use this built-in mechanism to know when an item has previously been written. When these modes are enabled, multiply written data must match what was written before. When NO_VERIFY is passed, no verification will occur. This is mostly useful when you can guarantee that multiple elements won't write the same value and you want to do in-place modifications as you initialize. VERIFY_UNINITIALIZED is a reserved value and should not be passed. |
|
inline |
|
inline |
Returns an iterator pointing to the first element in the container whose key is not considered to go before k (i.e., either it is equivalent or goes after).
key | key to compare to |
|
inline |
Read data from the map.
This returns a const reference, so is read only. This version of read is always thread safe (
key | key to read |
std::out_of_range | key is not found in map |
|
inline |
Read data from the map.
This returns a const reference, so is read only. If the key is not in the map, an out_of_range exception will be thrown.
NOTE: This function does not use a mutex, so it is possible to get invalid results if another thread is simulateously writing to the map. However, after the init() phase of simulation is complete (in setup() and beyond), this is always a safe operation. If reading during init() and you can't guarantee that all elements have already written all elements to the SharedMap, use mutex_read() to guarantee thread safety.
key | key to read |
std::out_of_range | key is not found in map |
|
inline |
Indicate that the calling element has written all the data it plans to write.
Writing to the map through this instance after publish() is called will create an error.
|
inline |
Get the size of the map.
|
inline |
Returns an iterator pointing to the first element in the container whose key is considered to go after k.
key | key to compare to |
|
inline |
Write data to the map.
This function is thread-safe, as a mutex is used to ensure only one write at a time.
key | key of the write |
value | value to be written |