HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UN_CustomDataT< ID, INDEX > Class Template Referenceabstract

#include <UN_CustomData.h>

+ Inheritance diagram for UN_CustomDataT< ID, INDEX >:

Public Member Functions

virtual void setCapacityIfNeeded (UN_DataSize min_capacity)=0
 
virtual void merge (const UN_CustomData &other, const UN_DataMergeInfo &data_merge_info)=0
 
virtual void addData (ID id, INDEX index)=0
 Adds a new data slot to accommodate a new piece of data. More...
 
virtual void clearData (ID id, INDEX index)=0
 
virtual void removeData (ID id, INDEX index)=0
 
virtual void removeAllData ()=0
 
bool isValid (ID id) const
 
INDEX dataIndex (ID id) const
 Returns the data index into the data buffer arrays given its ID. More...
 
UN_DataSize dataBufferSize () const
 
- Public Member Functions inherited from UN_CustomData
 UN_CustomData ()=default
 Constructor and destructor. More...
 
virtual ~UN_CustomData ()=default
 
const UN_DataIndexMapindexMap () const
 

Protected Member Functions

template<typename V , typename B >
void setData (B &buffer, ID id, const V &value)
 Helper method to copy-assign the value to an entry in the data buffer. More...
 
template<typename V , typename B >
void setData (B &buffer, ID id, V &&value)
 Helper method to move-assign the value to an entry in the data buffer. More...
 
template<typename V , typename B >
const V & getDataRef (const B &buffer, ID id, const V &default_value) const
 Helper method to return a const ref to an entry in the data buffer. More...
 
template<typename V , typename B >
getDataVal (const B &buffer, ID id, const V &default_value) const
 
template<typename V , typename B >
stealData (B &buffer, ID id, const V &default_value)
 Helper method to return a value moved from an entry in the data buffer. More...
 
template<typename OP , typename B >
void updateData (B &buffer, ID id, const OP &op)
 

Detailed Description

template<typename ID, typename INDEX>
class UN_CustomDataT< ID, INDEX >

The interface for custom data containters, templetized for convenience of using spcific IDs (eg, UN_NodeID, UN_PortID, etc), rather than generic UN_DataID. Note, this would normally be part of UN_CustomData, but templates can complicate things, like forward declarations, so using a concrete base class for that.

Definition at line 68 of file UN_CustomData.h.

Member Function Documentation

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::addData ( ID  id,
INDEX  index 
)
pure virtual

Adds a new data slot to accommodate a new piece of data.

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::clearData ( ID  id,
INDEX  index 
)
pure virtual

Clears the data slot of a given ID and at the corresponding index as if it was newly created.

template<typename ID , typename INDEX >
UN_DataSize UN_CustomDataT< ID, INDEX >::dataBufferSize ( ) const
inline

Returns the size of the data buffers that use indexing based on the dataIndex() lookup call that maps IDs to indices. The size is lagest index issued plus one.

Definition at line 120 of file UN_CustomData.h.

template<typename ID , typename INDEX >
INDEX UN_CustomDataT< ID, INDEX >::dataIndex ( ID  id) const
inline

Returns the data index into the data buffer arrays given its ID.

Definition at line 110 of file UN_CustomData.h.

template<typename ID , typename INDEX >
template<typename V , typename B >
const V& UN_CustomDataT< ID, INDEX >::getDataRef ( const B &  buffer,
ID  id,
const V &  default_value 
) const
inlineprotected

Helper method to return a const ref to an entry in the data buffer.

Definition at line 147 of file UN_CustomData.h.

template<typename ID , typename INDEX >
template<typename V , typename B >
V UN_CustomDataT< ID, INDEX >::getDataVal ( const B &  buffer,
ID  id,
const V &  default_value 
) const
inlineprotected

Returns a value constructed from an entry in the data buffer. This is useful when the type returned here differs from the underlying entry type. In particular, this is needed for UN_BoolDataBuffer whose underlying entries are bits (for which we can't return a const reference) while here we are returning bool (byte).

Definition at line 161 of file UN_CustomData.h.

template<typename ID , typename INDEX >
bool UN_CustomDataT< ID, INDEX >::isValid ( ID  id) const
inline

Returns true if the given ID refers to a valid data entry in the data buffers. Ie, such a piece of data exists and is valid.

Definition at line 104 of file UN_CustomData.h.

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::merge ( const UN_CustomData other,
const UN_DataMergeInfo data_merge_info 
)
pure virtual

Merge the other custom data into this one. The merge info includes ID remapping as well as buffer spans that can be copied in bulk. The spans don't contain root data, (applicable only to node and subnet data) so this method should merge any desired root data separately.

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::removeAllData ( )
pure virtual

Frees all the the data slots occupied by all the items, clearing them if necessary.

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::removeData ( ID  id,
INDEX  index 
)
pure virtual

Frees the data slot occupied by the item given by the id and a corresponding index (either can be used), clearing it if necessary.

template<typename ID , typename INDEX >
virtual void UN_CustomDataT< ID, INDEX >::setCapacityIfNeeded ( UN_DataSize  min_capacity)
pure virtual

Increases the capacity of the data buffer arrays to the given minimum, unless the capacity is already greater or equal to that minimum, in which case the capacity remains unchanged. This is a hint to the custom data, in case it uses data buffer arrays.

template<typename ID , typename INDEX >
template<typename V , typename B >
void UN_CustomDataT< ID, INDEX >::setData ( B &  buffer,
ID  id,
const V &  value 
)
inlineprotected

Helper method to copy-assign the value to an entry in the data buffer.

Definition at line 130 of file UN_CustomData.h.

template<typename ID , typename INDEX >
template<typename V , typename B >
void UN_CustomDataT< ID, INDEX >::setData ( B &  buffer,
ID  id,
V &&  value 
)
inlineprotected

Helper method to move-assign the value to an entry in the data buffer.

Definition at line 138 of file UN_CustomData.h.

template<typename ID , typename INDEX >
template<typename V , typename B >
V UN_CustomDataT< ID, INDEX >::stealData ( B &  buffer,
ID  id,
const V &  default_value 
)
inlineprotected

Helper method to return a value moved from an entry in the data buffer.

Definition at line 170 of file UN_CustomData.h.

template<typename ID , typename INDEX >
template<typename OP , typename B >
void UN_CustomDataT< ID, INDEX >::updateData ( B &  buffer,
ID  id,
const OP &  op 
)
inlineprotected

Helper method to update an entry value in the data buffer. It updates a data value in-place in the data buffer, which for complex data values (eg, dictionaries or arrays) is faster than getting and setting the value (although stealing and setting may be comparable). This is a convenient and useful idiom, that tries to avoid the buffer data aliasing issues. Intended usage: updateData(buff, id, [&key, &value](auto &x) { x[key] = value; });

Definition at line 186 of file UN_CustomData.h.


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