Ocean
Ocean::DebugElements Class Reference

This class implements the base class for a container for debug elements. More...

Inheritance diagram for Ocean::DebugElements:

Data Structures

class  ScopedHierarchyBase
 This class implements a scoped hierarchy. More...
 

Public Types

typedef std::vector< std::string > Hierarchy
 Definition of a vector holding strings (a hierarchy). More...
 
typedef Callback< void, const uint32_t, const Frame *, const Hierarchy * > ElementUpdateCallback
 Definition of a callback function for an updated debug element. More...
 

Public Member Functions

bool isElementActive (const uint32_t elementId) const
 Returns whether a specific debug elements is activated. More...
 
void activateElement (const uint32_t elementId)
 Activates a specific debug element. More...
 
void deactivateElement (const uint32_t elementId)
 Deactivates a specific debug element. More...
 
void activateAllElements ()
 Explicitly activates all elements (to avoid defining all active elements individually). More...
 
void pushHierarchyItem (const std::string &hierarchyItem)
 Pushes a new hierarchy. More...
 
void popHierarchyItem ()
 Pops the most recent hierarchy item. More...
 
void updateElement (const uint32_t elementId, Frame &&frame)
 Updates the debug information of a specific debug element. More...
 
void updateElement (const uint32_t elementId, Frame &&frame, const Hierarchy &explicitHierarchy)
 Updates the debug information of a specific debug element. More...
 
void updateElement (const uint32_t elementId, const Frame &frame)
 Updates the debug information of a specific debug element. More...
 
void updateElement (const uint32_t elementId, const Frame &frame, const Hierarchy &explicitHierarchy)
 Updates the debug information of a specific debug element. More...
 
Frame element (const uint32_t elementId, const bool popElement=false)
 Returns the most recent debug frame of a specific debug element. More...
 
Frame element (const uint32_t elementId, const Hierarchy &hierarchy, const bool popElement=false)
 Returns the most recent debug frame of a specific debug element. More...
 
bool elementIfActivate (const uint32_t elementId, Frame &frame, const bool popElement=false)
 Returns the most recent debug frame of a specific debug element if the debug element is activate and exists. More...
 
bool elementIfActivate (const uint32_t elementId, Frame &frame, const Hierarchy &hierarchy, const bool popElement=false)
 Returns the most recent debug frame of a specific debug element if the debug element is activate and exists. More...
 
std::vector< Hierarchyhierarchies (const uint32_t elementId) const
 Returns all existing hierarchies for a given element id. More...
 
void setElementUpdateCallback (const ElementUpdateCallback &callback)
 Sets the optional callback function for updated debug element. More...
 

Protected Types

typedef std::map< Hierarchy, FrameHierarchyMap
 Definition of a map mapping hierarchies to frames. More...
 
typedef std::map< uint32_t, HierarchyMapElementMap
 Definition of a map mapping element ids to hierarchy maps. More...
 
typedef std::unordered_set< uint32_t > ElementSet
 Definition of a set holding element ids. More...
 

Protected Member Functions

 DebugElements ()
 Protected default constructor. More...
 

Protected Attributes

ElementSet activeElements_
 The set holding activate debug element ids. More...
 
bool allElementsActivate_
 True, if all debug elements are activated (this state overrides the individual ids of activeIds_). More...
 
ElementMap elementMap_
 The map mapping ids to frames. More...
 
Hierarchy hierarchy_
 The current hierarchy. More...
 
ElementUpdateCallback elementUpdateCallback_
 Optional callback function for updated debug elements. More...
 
Lock lock_
 The data lock. More...
 

Detailed Description

This class implements the base class for a container for debug elements.

To use this class, create an own singleton class and derive from this object.

Member Typedef Documentation

◆ ElementMap

typedef std::map<uint32_t, HierarchyMap> Ocean::DebugElements::ElementMap
protected

Definition of a map mapping element ids to hierarchy maps.

◆ ElementSet

typedef std::unordered_set<uint32_t> Ocean::DebugElements::ElementSet
protected

Definition of a set holding element ids.

◆ ElementUpdateCallback

typedef Callback<void, const uint32_t, const Frame*, const Hierarchy*> Ocean::DebugElements::ElementUpdateCallback

Definition of a callback function for an updated debug element.

◆ Hierarchy

typedef std::vector<std::string> Ocean::DebugElements::Hierarchy

Definition of a vector holding strings (a hierarchy).

◆ HierarchyMap

typedef std::map<Hierarchy, Frame> Ocean::DebugElements::HierarchyMap
protected

Definition of a map mapping hierarchies to frames.

Constructor & Destructor Documentation

◆ DebugElements()

Ocean::DebugElements::DebugElements ( )
inlineprotected

Protected default constructor.

Member Function Documentation

◆ activateAllElements()

void Ocean::DebugElements::activateAllElements ( )

Explicitly activates all elements (to avoid defining all active elements individually).

Beware: Activating a couple of debug elements (and preparing the debug data in particular) can reduce the performance.

◆ activateElement()

void Ocean::DebugElements::activateElement ( const uint32_t  elementId)

Activates a specific debug element.

Parameters
elementIdThe id of the element to activate
See also
isElementActivated(), deactivateElement().

◆ deactivateElement()

void Ocean::DebugElements::deactivateElement ( const uint32_t  elementId)

Deactivates a specific debug element.

Parameters
elementIdThe id of the element to activate
See also
activateElement().

◆ element() [1/2]

Frame Ocean::DebugElements::element ( const uint32_t  elementId,
const bool  popElement = false 
)

Returns the most recent debug frame of a specific debug element.

If more than one debug element with individual hierarchies exist, one of the elements will be returned.
Beware: Due to performance reasons, the specific debug element must be activated before calling this function.

Parameters
elementIdThe id for which the frame will be returned
popElementTrue, to remove the debug element; False, to keep the debug element until it gets updated again
Returns
The copy of the frame which is associated with the id, an invalid frame in case the id does not exist
See also
isElementActive().

◆ element() [2/2]

Frame Ocean::DebugElements::element ( const uint32_t  elementId,
const Hierarchy hierarchy,
const bool  popElement = false 
)

Returns the most recent debug frame of a specific debug element.

Beware: Due to performance reasons, the specific debug element must be activated before calling this function.

Parameters
elementIdThe id for which the frame will be returned
hierarchyThe hierarchy for which the element will be returned
popElementTrue, to remove the debug element; False, to keep the debug element until it gets updated again
Returns
The copy of the frame which is associated with the id, an invalid frame in case the id does not exist
See also
isElementActive().

◆ elementIfActivate() [1/2]

bool Ocean::DebugElements::elementIfActivate ( const uint32_t  elementId,
Frame frame,
const bool  popElement = false 
)

Returns the most recent debug frame of a specific debug element if the debug element is activate and exists.

If more than one debug element with individual hierarchies exist, one of the elements will be returned.

Parameters
elementIdThe id for which the frame will be returned
frameThe resulting copy of the debug frame which is associated with the id
popElementTrue, to remove the debug element; False, to keep the debug element until it gets updated again
Returns
True, if the debug element is activate and exists

◆ elementIfActivate() [2/2]

bool Ocean::DebugElements::elementIfActivate ( const uint32_t  elementId,
Frame frame,
const Hierarchy hierarchy,
const bool  popElement = false 
)

Returns the most recent debug frame of a specific debug element if the debug element is activate and exists.

Parameters
elementIdThe id for which the frame will be returned
frameThe resulting copy of the debug frame which is associated with the id
hierarchyThe hierarchy for which the element will be returned
popElementTrue, to remove the debug element; False, to keep the debug element until it gets updated again
Returns
True, if the debug element is activate and exists

◆ hierarchies()

std::vector<Hierarchy> Ocean::DebugElements::hierarchies ( const uint32_t  elementId) const

Returns all existing hierarchies for a given element id.

Parameters
elementIdThe id for which all hierarchies will be returned
Returns
The hierarchies of the element, an empty vector if the element does not exist

◆ isElementActive()

bool Ocean::DebugElements::isElementActive ( const uint32_t  elementId) const

Returns whether a specific debug elements is activated.

Call this function before preparing the debug information (and updating via updateElement) to reduce the performance overhead when debugging.

Parameters
elementIdThe id for which the activation state is returned
Returns
True, if the debug element is activate; False, if the debug element is deactivated

◆ popHierarchyItem()

void Ocean::DebugElements::popHierarchyItem ( )

Pops the most recent hierarchy item.

◆ pushHierarchyItem()

void Ocean::DebugElements::pushHierarchyItem ( const std::string &  hierarchyItem)

Pushes a new hierarchy.

Parameters
hierarchyItemThe hierarchy item to be pushed

◆ setElementUpdateCallback()

void Ocean::DebugElements::setElementUpdateCallback ( const ElementUpdateCallback callback)
inline

Sets the optional callback function for updated debug element.

The callback function will be called whenever a debug element is updated.

Parameters
callbackThe callback function to be set, can be invalid to remove a previously set function

◆ updateElement() [1/4]

void Ocean::DebugElements::updateElement ( const uint32_t  elementId,
const Frame frame 
)

Updates the debug information of a specific debug element.

Beware: Due to performance reasons, the specific debug element must be activated before it can be updated,
as the preparation of debug information for disabled elements can be skipped.

Parameters
elementIdThe id of the debug element, should be a value from DebugId
frameThe new debug frame of the debug element, will be copied
See also
activateElement(), activateAllElements().

◆ updateElement() [2/4]

void Ocean::DebugElements::updateElement ( const uint32_t  elementId,
const Frame frame,
const Hierarchy explicitHierarchy 
)

Updates the debug information of a specific debug element.

Beware: Due to performance reasons, the specific debug element must be activated before it can be updated,
as the preparation of debug information for disabled elements can be skipped.

Parameters
elementIdThe id of the debug element, should be a value from DebugId
frameThe new debug frame of the debug element, will be copied
explicitHierarchyThe explicit hierarchy which will be used instead of the actual internal known hierarchy
See also
activateElement(), activateAllElements().

◆ updateElement() [3/4]

void Ocean::DebugElements::updateElement ( const uint32_t  elementId,
Frame &&  frame 
)

Updates the debug information of a specific debug element.

In case one (or several) sub-element bits are set, the element with matching sub-element bit mask will be updated only. Beware: Due to performance reasons, the specific debug element must be activated before it can be updated,
as the preparation of debug information for disabled elements can be skipped.

Parameters
elementIdThe id of the debug element, should be a value from DebugId
frameThe new debug frame of the debug element, will be moved
See also
setSubElementBit(), activateElement().

◆ updateElement() [4/4]

void Ocean::DebugElements::updateElement ( const uint32_t  elementId,
Frame &&  frame,
const Hierarchy explicitHierarchy 
)

Updates the debug information of a specific debug element.

In case one (or several) sub-element bits are set, the element with matching sub-element bit mask will be updated only. Beware: Due to performance reasons, the specific debug element must be activated before it can be updated,
as the preparation of debug information for disabled elements can be skipped.

Parameters
elementIdThe id of the debug element, should be a value from DebugId
frameThe new debug frame of the debug element, will be moved
explicitHierarchyThe explicit hierarchy which will be used instead of the actual internal known hierarchy
See also
setSubElementBit(), activateElement().

Field Documentation

◆ activeElements_

ElementSet Ocean::DebugElements::activeElements_
protected

The set holding activate debug element ids.

◆ allElementsActivate_

bool Ocean::DebugElements::allElementsActivate_
protected

True, if all debug elements are activated (this state overrides the individual ids of activeIds_).

◆ elementMap_

ElementMap Ocean::DebugElements::elementMap_
protected

The map mapping ids to frames.

◆ elementUpdateCallback_

ElementUpdateCallback Ocean::DebugElements::elementUpdateCallback_
protected

Optional callback function for updated debug elements.

◆ hierarchy_

Hierarchy Ocean::DebugElements::hierarchy_
protected

The current hierarchy.

◆ lock_

Lock Ocean::DebugElements::lock_
mutableprotected

The data lock.


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