CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
ComponentMemory.h File Reference

Shared-memory component registry: identity, location, parameters, private data and statistics for every component in the system. More...

#include "MemoryManager.h"
#include "PsyTime.h"
#include "Subscriptions.h"
Include dependency graph for ComponentMemory.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  cmlabs::ComponentMemoryStruct
 Root header of the component-memory segment. More...
struct  cmlabs::ComponentStats
 Legacy per-component throughput counters (DataMessageHeader-based rings). More...
struct  cmlabs::ComponentInfoStruct
 One component's registry record in shared memory. More...
struct  cmlabs::PrivateHeader
 Size-prefixed private-data entry stored after a component record. More...
struct  cmlabs::ParamHeader
 Size- and type-prefixed parameter entry stored after a component record. More...
struct  cmlabs::ParamIntegerHeader
 Value block of a PARAM_INTEGER parameter. More...
struct  cmlabs::ParamFloatHeader
 Value block of a PARAM_FLOAT parameter. More...
struct  cmlabs::ParamCollectionHeader
 Value block of a PARAM_*_COLL parameter; followed by the packed collection values. More...
class  cmlabs::ComponentMemory
 Accessor for the shared component registry. More...

Namespaces

namespace  cmlabs

Macros

#define NOTINUSE   65535
 Sentinel for an unused index/queue slot.
#define COMPONENT_CAN_MIGRATE   1
 Migration-policy flag: component may be moved to another process/node.
#define COMPINFOUSAGE(info)
 Total bytes used by a component record including its parameter and private-data areas.
#define CHECKCOMPONENTMEMORYSERIAL   if (serial != master->getComponentShmemSerial()) {if (!open()) {mutex->leave();return 0;}}
 Re-open the component segment if the master's resize serial no longer matches ours; bails out of the calling method (returning 0) on failure.
#define CHECKCOMPONENTMEMORYSERIALRETURN(a)
Component status values (ComponentInfoStruct::status)
#define COMPSTATUS_IDLE   1
 Component idle, waiting for triggers.
#define COMPSTATUS_STARTING   2
 Component is starting up.
#define COMPSTATUS_RUNNING   3
 Component is executing a run.
#define COMPSTATUS_FINISHED   4
 Component finished/stopped.
Component-record address helpers

Navigate from the segment header to a component's offset slot and record.

Offsets are relative to the end of the index area, so records can be relocated when they grow.

#define GETCOMPOFFSETP(header, id)
 Pointer to the offset slot for component id.
#define GETCOMPOFFSET(header, id)
 Offset value for component id (0 = not present).
#define GETCOMPDATA(header, id)
 Record pointer for component id, or NULL.
Parameter data types (ParamHeader::type)
#define PARAM_STRING   1
 Single string value.
#define PARAM_INTEGER   2
 int64 with default/min/max/interval (ParamIntegerHeader).
#define PARAM_FLOAT   3
 float64 with default/min/max/interval (ParamFloatHeader).
#define PARAM_STRING_COLL   4
 Collection of strings with a selected index.
#define PARAM_INTEGER_COLL   5
 Collection of int64 values with a selected index.
#define PARAM_FLOAT_COLL   6
 Collection of float64 values with a selected index.
#define PARAM_TYPE_COLL   7
 Collection of type names with a selected index.
Self-trigger policy values (may a component trigger itself with its own output?)
#define SELFTRIGGER_NONE   0
 Self-triggering forbidden.
#define SELFTRIGGER_WARN   1
 Allowed but logged as a warning.
#define SELFTRIGGER_ALLOW   2
 Explicitly allowed.

Detailed Description

Shared-memory component registry: identity, location, parameters, private data and statistics for every component in the system.

Components (modules, whiteboards, catalogs...) live inside space processes but are registered here so any process can resolve names/ids, check where a component runs (node/process), read or tweak its parameters, and follow its performance. The segment is one contiguous block: a ComponentMemoryStruct header, an index of uint64 offsets (one per component id), then variable-sized ComponentInfoStruct records each followed by their parameter and private-data areas. Records are relocated when they grow, so only offsets — never raw pointers — are stored.

Component migration between processes/nodes is supported by copying the record's data area (getComponentData/setComponentData) and updating its location fields.

Warning
Shared-memory layouts; changing any struct here requires a full rebuild of all binaries (make clean && make) — see MemoryManager.h for the ABI warning.

Definition in file ComponentMemory.h.

Macro Definition Documentation

◆ CHECKCOMPONENTMEMORYSERIAL

#define CHECKCOMPONENTMEMORYSERIAL   if (serial != master->getComponentShmemSerial()) {if (!open()) {mutex->leave();return 0;}}

Re-open the component segment if the master's resize serial no longer matches ours; bails out of the calling method (returning 0) on failure.

Definition at line 244 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::addComponentStats(), cmlabs::ComponentMemory::addLocalPerformanceStats(), cmlabs::ComponentMemory::cancelComponentID(), cmlabs::ComponentMemory::confirmComponentID(), cmlabs::ComponentMemory::createComponent(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::deleteParameter(), cmlabs::ComponentMemory::deletePrivateData(), cmlabs::ComponentMemory::destroyComponent(), cmlabs::ComponentMemory::findProcessComponents(), cmlabs::ComponentMemory::getAllCatalogs(), cmlabs::ComponentMemory::getAllComponents(), cmlabs::ComponentMemory::getAllLocalComponents(), cmlabs::ComponentMemory::getAllLocalComponents(), cmlabs::ComponentMemory::getAllModules(), cmlabs::ComponentMemory::getComponentData(), cmlabs::ComponentMemory::getComponentID(), cmlabs::ComponentMemory::getComponentLocation(), cmlabs::ComponentMemory::getComponentName(), cmlabs::ComponentMemory::getComponentNameString(), cmlabs::ComponentMemory::getComponentNodeID(), cmlabs::ComponentMemory::getComponentPolicy(), cmlabs::ComponentMemory::getComponentProcessID(), cmlabs::ComponentMemory::getComponentSelfTrigger(), cmlabs::ComponentMemory::getComponentType(), cmlabs::ComponentMemory::getMemoryUsage(), cmlabs::ComponentMemory::getParameter(), cmlabs::ComponentMemory::getParameter(), cmlabs::ComponentMemory::getParameter(), cmlabs::ComponentMemory::getParameterAsBool(), cmlabs::ComponentMemory::getParameterDataType(), cmlabs::ComponentMemory::getParameterString(), cmlabs::ComponentMemory::getParameterValueSize(), cmlabs::ComponentMemory::getPrivateData(), cmlabs::ComponentMemory::getPrivateDataCopy(), cmlabs::ComponentMemory::getPrivateDataMimetype(), cmlabs::ComponentMemory::getPrivateDataSize(), cmlabs::ComponentMemory::hasParameter(), cmlabs::ComponentMemory::isComponentLocal(), cmlabs::ComponentMemory::lookupComponentID(), cmlabs::ComponentMemory::resetParameter(), cmlabs::ComponentMemory::setComponentData(), cmlabs::ComponentMemory::setComponentPerfStats(), cmlabs::ComponentMemory::setComponentPolicy(), cmlabs::ComponentMemory::setComponentSelfTrigger(), cmlabs::ComponentMemory::setComponentStats(), cmlabs::ComponentMemory::setParameter(), cmlabs::ComponentMemory::setParameter(), cmlabs::ComponentMemory::setParameter(), cmlabs::ComponentMemory::setPrivateData(), cmlabs::ComponentMemory::tweakParameter(), cmlabs::ComponentMemory::updateComponentInformation(), and cmlabs::ComponentMemory::updateComponentLocation().

◆ CHECKCOMPONENTMEMORYSERIALRETURN

#define CHECKCOMPONENTMEMORYSERIALRETURN ( a)
Value:
if (serial != master->getComponentShmemSerial()) {if (!open()) {mutex->leave();return a;}}

Definition at line 245 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::getPrivateDataKeys(), and cmlabs::ComponentMemory::getPrivateDataKeysAndTypes().

◆ COMPINFOUSAGE

#define COMPINFOUSAGE ( info)
Value:
(sizeof(ComponentInfoStruct) + info->paramSize + info->dataSize)

Total bytes used by a component record including its parameter and private-data areas.

Definition at line 191 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::deleteParameter(), and cmlabs::ComponentMemory::deletePrivateData().

◆ COMPONENT_CAN_MIGRATE

#define COMPONENT_CAN_MIGRATE   1

Migration-policy flag: component may be moved to another process/node.

Definition at line 75 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::canComponentMigrate(), and cmlabs::ComponentMemory::UnitTest().

◆ COMPSTATUS_FINISHED

#define COMPSTATUS_FINISHED   4

Component finished/stopped.

Definition at line 34 of file ComponentMemory.h.

◆ COMPSTATUS_IDLE

#define COMPSTATUS_IDLE   1

Component idle, waiting for triggers.

Definition at line 31 of file ComponentMemory.h.

◆ COMPSTATUS_RUNNING

#define COMPSTATUS_RUNNING   3

Component is executing a run.

Definition at line 33 of file ComponentMemory.h.

Referenced by cmlabs::PsyAPI::postOutputMessage(), cmlabs::ComponentMemory::UnitTest(), and cmlabs::PsyAPI::waitForNewMessage().

◆ COMPSTATUS_STARTING

#define COMPSTATUS_STARTING   2

Component is starting up.

Definition at line 32 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::addComponentStats().

◆ GETCOMPDATA

#define GETCOMPDATA ( header,
id )
Value:
(ComponentInfoStruct*)(GETCOMPOFFSET(header,id) ? ((char*)header) + (header->indexSize * sizeof(uint64)) + GETCOMPOFFSET(header,id) : NULL)
#define GETCOMPOFFSET(header, id)
Offset value for component id (0 = not present).

Record pointer for component id, or NULL.

Definition at line 46 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::addComponentStats(), cmlabs::ComponentMemory::addLocalPerformanceStats(), cmlabs::ComponentMemory::cancelComponentID(), cmlabs::ComponentMemory::confirmComponentID(), cmlabs::ComponentMemory::createComponent(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::createParameter(), cmlabs::ComponentMemory::deleteParameter(), cmlabs::ComponentMemory::deletePrivateData(), cmlabs::ComponentMemory::destroyComponent(), cmlabs::ComponentMemory::findProcessComponents(), cmlabs::ComponentMemory::getAllCatalogs(), cmlabs::ComponentMemory::getAllComponents(), cmlabs::ComponentMemory::getAllLocalComponents(), cmlabs::ComponentMemory::getAllLocalComponents(), cmlabs::ComponentMemory::getAllModules(), cmlabs::ComponentMemory::getComponentData(), cmlabs::ComponentMemory::getComponentID(), cmlabs::ComponentMemory::getComponentLocation(), cmlabs::ComponentMemory::getComponentName(), cmlabs::ComponentMemory::getComponentNameString(), cmlabs::ComponentMemory::getComponentNodeID(), cmlabs::ComponentMemory::getComponentPerfStats(), cmlabs::ComponentMemory::getComponentPolicy(), cmlabs::ComponentMemory::getComponentProcessID(), cmlabs::ComponentMemory::getComponentSelfTrigger(), cmlabs::ComponentMemory::getComponentStats(), cmlabs::ComponentMemory::getComponentType(), cmlabs::ComponentMemory::getPrivateDataKeys(), cmlabs::ComponentMemory::getPrivateDataKeysAndTypes(), cmlabs::ComponentMemory::isComponentLocal(), cmlabs::ComponentMemory::lookupComponentID(), cmlabs::ComponentMemory::setComponentData(), cmlabs::ComponentMemory::setComponentPerfStats(), cmlabs::ComponentMemory::setComponentPolicy(), cmlabs::ComponentMemory::setComponentSelfTrigger(), cmlabs::ComponentMemory::setComponentStats(), cmlabs::ComponentMemory::setPrivateData(), cmlabs::ComponentMemory::updateComponentInformation(), and cmlabs::ComponentMemory::updateComponentLocation().

◆ GETCOMPOFFSET

#define GETCOMPOFFSET ( header,
id )
Value:
*GETCOMPOFFSETP(header,id)
#define GETCOMPOFFSETP(header, id)
Pointer to the offset slot for component id.

Offset value for component id (0 = not present).

Definition at line 45 of file ComponentMemory.h.

◆ GETCOMPOFFSETP

#define GETCOMPOFFSETP ( header,
id )
Value:
(uint64*)(((char*)header) + sizeof(ComponentMemoryStruct) + (id*sizeof(uint64)))

Pointer to the offset slot for component id.

Definition at line 44 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::destroyComponent().

◆ NOTINUSE

#define NOTINUSE   65535

Sentinel for an unused index/queue slot.

Definition at line 38 of file ComponentMemory.h.

◆ PARAM_FLOAT

#define PARAM_FLOAT   3

float64 with default/min/max/interval (ParamFloatHeader).

Definition at line 67 of file ComponentMemory.h.

◆ PARAM_FLOAT_COLL

#define PARAM_FLOAT_COLL   6

Collection of float64 values with a selected index.

Definition at line 70 of file ComponentMemory.h.

◆ PARAM_INTEGER

#define PARAM_INTEGER   2

int64 with default/min/max/interval (ParamIntegerHeader).

Definition at line 66 of file ComponentMemory.h.

◆ PARAM_INTEGER_COLL

#define PARAM_INTEGER_COLL   5

Collection of int64 values with a selected index.

Definition at line 69 of file ComponentMemory.h.

◆ PARAM_STRING

#define PARAM_STRING   1

Single string value.

Definition at line 65 of file ComponentMemory.h.

◆ PARAM_STRING_COLL

#define PARAM_STRING_COLL   4

Collection of strings with a selected index.

Definition at line 68 of file ComponentMemory.h.

◆ PARAM_TYPE_COLL

#define PARAM_TYPE_COLL   7

Collection of type names with a selected index.

Definition at line 71 of file ComponentMemory.h.

◆ SELFTRIGGER_ALLOW

#define SELFTRIGGER_ALLOW   2

Explicitly allowed.

Definition at line 133 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::UnitTest().

◆ SELFTRIGGER_NONE

#define SELFTRIGGER_NONE   0

Self-triggering forbidden.

Definition at line 131 of file ComponentMemory.h.

◆ SELFTRIGGER_WARN

#define SELFTRIGGER_WARN   1

Allowed but logged as a warning.

Definition at line 132 of file ComponentMemory.h.

Referenced by cmlabs::ComponentMemory::UnitTest().