ngscopeclient v0.2
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members

Bidirectional table mapping integer IDs in scopesession files to object pointers. More...

#include <IDTable.h>

Public Types

typedef std::map< uintptr_t, SerializableObject *, std::less< uintptr_t > > forwardType
 Type of the forward map.
 
typedef std::map< SerializableObject *, uintptr_t, std::less< SerializableObject * > > reverseType
 Type of the reverse map.
 

Public Member Functions

forwardType::const_iterator begin ()
 Get an iterator to the start of the forward map.
 
forwardType::const_iterator end ()
 Get an iterator to the end of the forward map.
 
uintptr_t emplace (SerializableObject *p)
 Store a new object in the table.
 
void emplace (uintptr_t id, SerializableObject *p)
 Store a new object in the table using a specific ID.
 
bool HasID (SerializableObject *p)
 Checks if we have an object at a specific pointer.
 
bool HasID (uintptr_t id)
 Checks if we have an object with a specific ID.
 
void ReserveID (uintptr_t id)
 Marks an ID as unavailable for use, without assigning an pointer to it.
 
template<class T >
TLookup (uintptr_t id)
 Type-safe object lookup.
 
uintptr_t operator[] (SerializableObject *key)
 Forward lookup.
 
void clear ()
 Deletes all entries from the table.
 
void erase (uintptr_t key)
 Erase an entry given a forward key.
 
void erase (SerializableObject *key)
 Erase an entry given a reverse key.
 
void replace (SerializableObject *oldval, SerializableObject *newval)
 Replaces one value with another, keeping the keys identical.
 
size_t size () const
 Return the number of entries in the bijection.
 

Protected Attributes

uintptr_t m_nextID
 Index of the next ID to be assigned.
 
forwardType m_forwardMap
 Map of object-to-object in the forward direction.
 
reverseType m_reverseMap
 Map of object-to-object in the reverse direction.
 

Detailed Description

Bidirectional table mapping integer IDs in scopesession files to object pointers.

Pointers must be SerializableObject derived to ensure type safety

Member Function Documentation

◆ emplace() [1/2]

uintptr_t IDTable::emplace ( SerializableObject p)
inline

Store a new object in the table.

Parameters
pPointer to the object
Returns
The ID of the object

◆ emplace() [2/2]

void IDTable::emplace ( uintptr_t  id,
SerializableObject p 
)
inline

Store a new object in the table using a specific ID.

Parameters
idID to assign to the object
pPointer to the object

◆ erase() [1/2]

void IDTable::erase ( SerializableObject key)
inline

Erase an entry given a reverse key.

Parameters
keyThe object to remove

◆ erase() [2/2]

void IDTable::erase ( uintptr_t  key)
inline

Erase an entry given a forward key.

Parameters
keyThe object to remove

◆ HasID() [1/2]

bool IDTable::HasID ( SerializableObject p)
inline

Checks if we have an object at a specific pointer.

Parameters
pPointer to the object

◆ HasID() [2/2]

bool IDTable::HasID ( uintptr_t  id)
inline

Checks if we have an object with a specific ID.

Parameters
idID of the object

The documentation for this class was generated from the following file: