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

Accessor for the shared component registry. More...

#include <ComponentMemory.h>

Public Member Functions

 ComponentMemory (MasterMemory *master)
 ~ComponentMemory ()
bool getMemoryUsage (uint64 &alloc, uint64 &usage)
 Report allocation/usage of the component segment.
bool open ()
 Attach to the existing component segment.
bool create (uint32 indexSize)
 Create the component segment (master only).
std::vector< ComponentInfoStruct > * getAllComponents ()
 Snapshot all components.
std::vector< ComponentInfoStruct > * getAllLocalComponents ()
 Snapshot components on this node.
std::vector< ComponentInfoStruct > * getAllLocalComponents (uint8 type)
 Snapshot local components of type.
std::vector< ComponentInfoStruct > * getAllModules ()
 Snapshot all module components.
std::vector< ComponentInfoStruct > * getAllCatalogs ()
 Snapshot all catalog components.
bool writeComponentsToMsg (DataMessage *msg)
 Serialize all component records into msg.
bool writeComponentNamesToMsg (DataMessage *msg)
 Write just the component names into msg.
bool syncComponents (DataMessage *msg)
 Merge component records received from a remote node.
bool confirmComponentID (uint32 id)
 Mark a provisionally reserved component id as ready (syncStatus 2).
bool cancelComponentID (uint32 id)
 Release a provisionally reserved component id.
uint8 lookupComponentID (const char *name, uint32 &id)
 Look up a component by name without filtering on readiness.
bool createComponent (uint32 id, uint8 type, uint8 policy, uint8 selfTrigger, const char *name, uint64 size, uint16 nodeID, uint16 procID, uint64 time, uint32 &existingID)
 Register a component record.
bool destroyComponent (uint32 cid)
 Remove a component record and free its space.
bool getComponentName (uint32 cid, char *name, uint32 maxNameLen)
 Copy the component name into name.
std::string getComponentNameString (uint32 cid)
uint8 getComponentType (uint32 cid)
bool getComponentID (const char *name, uint32 &cid)
 Look up a component id by name.
ComponentStats getComponentStats (uint32 cid)
bool setComponentStats (uint32 cid, ComponentStats &stats)
 Overwrite the component's stats.
AveragePerfStats getComponentPerfStats (uint32 cid)
bool setComponentPerfStats (uint32 cid, AveragePerfStats &perfStruct)
 Store new performance averages.
bool isComponentLocal (uint32 cid)
bool isComponentLocal (const char *name)
bool getComponentLocation (uint32 cid, uint16 &nodeID, uint16 &procID)
 Get the node/process the component runs in.
uint8 getComponentPolicy (uint32 cid)
bool updateComponentInformation (uint32 cid, uint8 type, uint8 policy, uint8 selfTrigger, uint16 nodeID, uint16 procID)
 Update type/policy/self-trigger/location in one call.
bool setComponentPolicy (uint32 cid, uint8 policy)
bool setComponentPaused (uint32 cid, bool paused)
 Set or clear COMPONENT_PAUSED (stop / start).
bool isComponentPaused (uint32 cid)
 Set the migration policy.
uint8 getComponentSelfTrigger (uint32 cid)
bool setComponentSelfTrigger (uint32 cid, uint8 selfTrigger)
 Set the self-trigger policy.
uint16 getComponentNodeID (uint32 cid)
uint16 getComponentProcessID (uint32 cid)
bool updateComponentLocation (uint32 cid, uint16 nodeID, uint16 procID)
 Record a new location (after migration).
bool addComponentStats (uint32 cid, uint8 status, uint64 usageCPUTicks, DataMessage *inputMsg, DataMessage *outputMsg, uint32 runCount, uint32 cycleCount)
 Fold a run's activity into the component's stats (counters, rings, CPU ticks).
bool canComponentMigrate (uint32 cid)
std::list< uint16 > * findProcessComponents (uint16 procID)
 List ids of components in process procID.
char * getComponentData (uint32 cid, uint64 &size)
 Copy a component's whole data area (for migration).
bool setComponentData (uint32 cid, const char *data, uint64 size, bool wasMigrated)
 Replace a component's data area (after migration).
bool hasParameter (uint32 cid, const char *name)
bool deleteParameter (uint32 cid, const char *name)
 Remove the parameter.
bool addLocalPerformanceStats (std::list< PerfStats > &perfStats)
 Append PerfStats for all local components.
std::string printFriendly ()
std::string toXML (bool stats=true)
Private data (named binary blobs owned by a component)

Blobs are stored inline in the component record with optional mimetype.

bool setPrivateData (uint32 cid, const char *name, const char *data, uint64 size, const char *mimetype=NULL)
 Create/replace blob name.
uint64 getPrivateDataSize (uint32 cid, const char *name)
std::string getPrivateDataMimetype (uint32 cid, const char *name)
bool getPrivateData (uint32 cid, const char *name, char *data, uint64 maxSize)
 Copy blob into caller buffer data (max maxSize).
char * getPrivateDataCopy (uint32 cid, const char *name, uint64 &size)
bool deletePrivateData (uint32 cid, const char *name)
 Delete blob name.
std::map< std::string, std::string > getPrivateDataKeysAndTypes (uint32 cid)
std::list< std::string > getPrivateDataKeys (uint32 cid)
Parameter creation

Overloads create string/integer/float parameters or collections thereof; values are copied into the component record.

min/max/interval of 0 mean unconstrained.

Returns
true on success (false if the parameter exists with a different type).
bool createParameter (uint32 cid, const char *name, const char *val, const char *defaultValue=NULL)
bool createParameter (uint32 cid, const char *name, const char *val, uint32 count, uint32 defaultIndex)
bool createParameter (uint32 cid, const char *name, std::vector< std::string > values, const char *defaultValue=NULL)
bool createParameter (uint32 cid, const char *name, int64 *val, uint32 count, uint32 defaultIndex)
bool createParameter (uint32 cid, const char *name, std::vector< std::string > values, int64 defaultValue)
bool createParameter (uint32 cid, const char *name, std::vector< int64 > values, int64 defaultValue=0)
bool createParameter (uint32 cid, const char *name, float64 *val, uint32 count, uint32 defaultIndex)
bool createParameter (uint32 cid, const char *name, std::vector< std::string > values, float64 defaultValue)
bool createParameter (uint32 cid, const char *name, std::vector< float64 > values, float64 defaultValue=0)
bool createParameter (uint32 cid, const char *name, int64 val, int64 min=0, int64 max=0, int64 interval=0)
bool createParameter (uint32 cid, const char *name, float64 val, float64 min=0, float64 max=0, float64 interval=0)

Static Public Member Functions

static bool UnitTest ()
 Self-test.

Parameter access

Typed getters convert where sensible; getters return 0/empty on missing parameters.

Setters clamp to min/max where configured.

Returns
true on success (bool forms).
static const char * ParamTypeName (uint8 type)
uint8 getParameterDataType (uint32 cid, const char *name)
uint32 getParameterValueSize (uint32 cid, const char *name)
bool getParameter (uint32 cid, const char *name, char *val, uint32 maxSize)
bool getParameter (uint32 cid, const char *name, int64 &val)
bool getParameter (uint32 cid, const char *name, float64 &val)
std::string getParameterString (uint32 cid, const char *name, uint32 maxSize)
std::string getParameterString (uint32 cid, const char *name)
int64 getParameterInt (uint32 cid, const char *name)
float64 getParameterFloat (uint32 cid, const char *name)
bool getParameterAsBool (uint32 cid, const char *name)
bool setParameter (uint32 cid, const char *name, const char *val)
bool setParameter (uint32 cid, const char *name, int64 val)
bool setParameter (uint32 cid, const char *name, float64 val)
bool resetParameter (uint32 cid, const char *name)
 Restore the parameter's default value/index.
bool tweakParameter (uint32 cid, const char *name, int32 tweak)
 Step the value by tweak * interval (or collection index).
bool getParameterInfo (uint32 cid, std::vector< ParamInfo > &out)
 Every parameter of component cid, in creation order, with type, value, default, range, step and the collection entries.
std::string checkIntegrity ()
 Check the segment layout: every present component's record lies inside the used area, carries its own id, and the records follow each other in id order with no gap or overlap, ending exactly at usage.

Detailed Description

Accessor for the shared component registry.

One instance per process (created by MemoryManager). The node master calls create(); other processes open(). Every method locks the segment's named cross-process mutex and re-attaches when the segment was resized elsewhere (serial check). String/char* out parameters are copied into caller buffers; returned containers (vectors/lists) are heap-allocated and owned by the caller. The master pointer is borrowed.

uint32 cid; uint32 existing;
componentMemory->createComponent(cid, type, policy, SELFTRIGGER_NONE,
"MyModule", 4096, nodeID, procID, now, existing);
componentMemory->createParameter(cid, "Threshold", (int64)10, 0, 100, 1);
int64 v = componentMemory->getParameterInt(cid, "Threshold");
#define SELFTRIGGER_NONE
Self-triggering forbidden.

Definition at line 279 of file ComponentMemory.h.

Constructor & Destructor Documentation

◆ ComponentMemory()

cmlabs::ComponentMemory::ComponentMemory ( MasterMemory * master)
Parameters
masterSegment bookkeeping interface (borrowed, not owned).

Definition at line 14 of file ComponentMemory.cpp.

Referenced by UnitTest().

◆ ~ComponentMemory()

cmlabs::ComponentMemory::~ComponentMemory ( )

Definition at line 23 of file ComponentMemory.cpp.

References cmlabs::utils::CloseSharedMemorySegment().

Member Function Documentation

◆ addComponentStats()

◆ addLocalPerformanceStats()

◆ cancelComponentID()

bool cmlabs::ComponentMemory::cancelComponentID ( uint32 id)

◆ canComponentMigrate()

bool cmlabs::ComponentMemory::canComponentMigrate ( uint32 cid)
Returns
true if the component's policy allows migration.

Definition at line 842 of file ComponentMemory.cpp.

References COMPONENT_CAN_MIGRATE, and getComponentPolicy().

◆ checkIntegrity()

std::string cmlabs::ComponentMemory::checkIntegrity ( )

Check the segment layout: every present component's record lies inside the used area, carries its own id, and the records follow each other in id order with no gap or overlap, ending exactly at usage.

Returns
"" when consistent, else a description of the first problem (for tests and diagnostics). "string", "integer", "float", "string-list", "integer-list", "float-list", "type-list".

Definition at line 2639 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIALRETURN, COMPINFOUSAGE, GETCOMPDATA, GETCOMPOFFSET, cmlabs::ComponentInfoStruct::id, cmlabs::ComponentInfoStruct::size, and cmlabs::utils::StringFormat().

Referenced by cmlabs::ComponentMemoryLayoutUnitTest().

◆ confirmComponentID()

bool cmlabs::ComponentMemory::confirmComponentID ( uint32 id)

Mark a provisionally reserved component id as ready (syncStatus 2).

Returns
true on success.

Definition at line 440 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), syncComponents(), and UnitTest().

◆ create()

bool cmlabs::ComponentMemory::create ( uint32 indexSize)

Create the component segment (master only).

Parameters
indexSizeComponent-id capacity.
Returns
true on success.

Definition at line 206 of file ComponentMemory.cpp.

References COMPONENTMEMORYID, cmlabs::utils::CreateSharedMemorySegment(), cmlabs::GetTimeNow(), and cmlabs::utils::StringFormat().

◆ createComponent()

bool cmlabs::ComponentMemory::createComponent ( uint32 id,
uint8 type,
uint8 policy,
uint8 selfTrigger,
const char * name,
uint64 size,
uint16 nodeID,
uint16 procID,
uint64 time,
uint32 & existingID )

Register a component record.

Parameters
idRequested component id.
typeComponent type.
policyMigration policy.
selfTriggerSELFTRIGGER_* policy.
nameUnique component name.
sizeInitial record size in bytes.
nodeIDNode the component lives on.
procIDProcess the component lives in.
timeCreation timestamp (µs).
existingIDReceives the id of a pre-existing component with the same name, if any.
Returns
true on success.

Definition at line 550 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, cmlabs::ComponentInfoStruct::createdTime, GETCOMPDATA, getComponentID(), cmlabs::GetTimeNow(), LOG_MEMORY, LogPrint, MAXKEYNAMELEN, cmlabs::ComponentInfoStruct::name, cmlabs::ComponentInfoStruct::nodeID, cmlabs::ComponentInfoStruct::policy, cmlabs::ComponentInfoStruct::procID, cmlabs::ComponentInfoStruct::selfTrigger, cmlabs::ComponentInfoStruct::size, cmlabs::utils::strcpyavail(), stricmp, cmlabs::ComponentInfoStruct::syncStatus, and cmlabs::ComponentInfoStruct::type.

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), syncComponents(), and UnitTest().

◆ createParameter() [1/11]

◆ createParameter() [2/11]

◆ createParameter() [3/11]

◆ createParameter() [4/11]

◆ createParameter() [5/11]

◆ createParameter() [6/11]

◆ createParameter() [7/11]

bool cmlabs::ComponentMemory::createParameter ( uint32 cid,
const char * name,
std::vector< float64 > values,
float64 defaultValue = 0 )

Definition at line 1827 of file ComponentMemory.cpp.

References createParameter().

◆ createParameter() [8/11]

bool cmlabs::ComponentMemory::createParameter ( uint32 cid,
const char * name,
std::vector< int64 > values,
int64 defaultValue = 0 )

Definition at line 1799 of file ComponentMemory.cpp.

References createParameter().

◆ createParameter() [9/11]

bool cmlabs::ComponentMemory::createParameter ( uint32 cid,
const char * name,
std::vector< std::string > values,
const char * defaultValue = NULL )

Definition at line 1767 of file ComponentMemory.cpp.

References createParameter().

◆ createParameter() [10/11]

bool cmlabs::ComponentMemory::createParameter ( uint32 cid,
const char * name,
std::vector< std::string > values,
float64 defaultValue )

Definition at line 1813 of file ComponentMemory.cpp.

References cmlabs::utils::Ascii2Float64(), and createParameter().

◆ createParameter() [11/11]

bool cmlabs::ComponentMemory::createParameter ( uint32 cid,
const char * name,
std::vector< std::string > values,
int64 defaultValue )

Definition at line 1785 of file ComponentMemory.cpp.

References cmlabs::utils::Ascii2Int64(), and createParameter().

◆ deleteParameter()

bool cmlabs::ComponentMemory::deleteParameter ( uint32 cid,
const char * name )

◆ deletePrivateData()

bool cmlabs::ComponentMemory::deletePrivateData ( uint32 cid,
const char * name )

◆ destroyComponent()

bool cmlabs::ComponentMemory::destroyComponent ( uint32 cid)

Remove a component record and free its space.

Returns
true on success.

Definition at line 692 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, GETCOMPOFFSETP, and cmlabs::ComponentInfoStruct::size.

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), and UnitTest().

◆ findProcessComponents()

std::list< uint16 > * cmlabs::ComponentMemory::findProcessComponents ( uint16 procID)

List ids of components in process procID.

Returns
Caller-owned list.

Definition at line 824 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.

◆ getAllCatalogs()

std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllCatalogs ( )

Snapshot all catalog components.

Returns
Caller-owned vector.

Definition at line 190 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, COMP_CATALOG, COMP_WHITEBOARD, and GETCOMPDATA.

◆ getAllComponents()

std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllComponents ( )

Snapshot all components.

Returns
Caller-owned vector.

Definition at line 129 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.

Referenced by printFriendly(), toXML(), writeComponentNamesToMsg(), and writeComponentsToMsg().

◆ getAllLocalComponents() [1/2]

std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllLocalComponents ( )

Snapshot components on this node.

Returns
Caller-owned vector.

Definition at line 144 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.

◆ getAllLocalComponents() [2/2]

std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllLocalComponents ( uint8 type)

Snapshot local components of type.

Returns
Caller-owned vector.

Definition at line 159 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and GETCOMPDATA.

◆ getAllModules()

std::vector< ComponentInfoStruct > * cmlabs::ComponentMemory::getAllModules ( )

Snapshot all module components.

Returns
Caller-owned vector.

Definition at line 174 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, COMP_EXTERNAL, COMP_INTERNAL, and GETCOMPDATA.

◆ getComponentData()

char * cmlabs::ComponentMemory::getComponentData ( uint32 cid,
uint64 & size )

Copy a component's whole data area (for migration).

Parameters
cidComponent id.
sizeReceives byte count.
Returns
Caller-owned heap buffer (free with free()/delete[] per implementation), or NULL.

Definition at line 764 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::size.

◆ getComponentID()

bool cmlabs::ComponentMemory::getComponentID ( const char * name,
uint32 & cid )

Look up a component id by name.

Returns
true if found.

Definition at line 1240 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and stricmp.

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), createComponent(), isComponentLocal(), and UnitTest().

◆ getComponentLocation()

bool cmlabs::ComponentMemory::getComponentLocation ( uint32 cid,
uint16 & nodeID,
uint16 & procID )

Get the node/process the component runs in.

Returns
true if found.

Definition at line 978 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, and cmlabs::ComponentInfoStruct::procID.

Referenced by UnitTest().

◆ getComponentName()

bool cmlabs::ComponentMemory::getComponentName ( uint32 cid,
char * name,
uint32 maxNameLen )

Copy the component name into name.

Returns
true if found.

Definition at line 1105 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::name, and cmlabs::utils::strcpyavail().

Referenced by UnitTest().

◆ getComponentNameString()

std::string cmlabs::ComponentMemory::getComponentNameString ( uint32 cid)
Returns
Component name, or empty string if unknown.

Definition at line 1083 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::name.

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), and UnitTest().

◆ getComponentNodeID()

uint16 cmlabs::ComponentMemory::getComponentNodeID ( uint32 cid)
Returns
Node id hosting the component.

Definition at line 1003 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::nodeID.

Referenced by UnitTest().

◆ getComponentPerfStats()

AveragePerfStats cmlabs::ComponentMemory::getComponentPerfStats ( uint32 cid)
Returns
Copy of the windowed performance averages.

Definition at line 1172 of file ComponentMemory.cpp.

References GETCOMPDATA, open(), and cmlabs::ComponentInfoStruct::perfStats.

◆ getComponentPolicy()

uint8 cmlabs::ComponentMemory::getComponentPolicy ( uint32 cid)
Returns
Migration policy, 0 if unknown.

Definition at line 846 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::policy.

Referenced by canComponentMigrate().

◆ getComponentProcessID()

uint16 cmlabs::ComponentMemory::getComponentProcessID ( uint32 cid)
Returns
Process id hosting the component.

Definition at line 1025 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::procID.

Referenced by UnitTest().

◆ getComponentSelfTrigger()

uint8 cmlabs::ComponentMemory::getComponentSelfTrigger ( uint32 cid)
Returns
SELFTRIGGER_* policy.

Definition at line 935 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::selfTrigger.

Referenced by UnitTest().

◆ getComponentStats()

ComponentStats cmlabs::ComponentMemory::getComponentStats ( uint32 cid)
Returns
Copy of the component's stats (zeroed if unknown).

Definition at line 1148 of file ComponentMemory.cpp.

References GETCOMPDATA, open(), and cmlabs::ComponentInfoStruct::stats.

Referenced by UnitTest().

◆ getComponentType()

uint8 cmlabs::ComponentMemory::getComponentType ( uint32 cid)
Returns
Component type, 0 if unknown.

Definition at line 1126 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::type.

Referenced by UnitTest().

◆ getMemoryUsage()

bool cmlabs::ComponentMemory::getMemoryUsage ( uint64 & alloc,
uint64 & usage )

Report allocation/usage of the component segment.

Returns
true on success.

Definition at line 35 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL.

◆ getParameter() [1/3]

◆ getParameter() [2/3]

bool cmlabs::ComponentMemory::getParameter ( uint32 cid,
const char * name,
float64 & val )

◆ getParameter() [3/3]

bool cmlabs::ComponentMemory::getParameter ( uint32 cid,
const char * name,
int64 & val )

◆ getParameterAsBool()

bool cmlabs::ComponentMemory::getParameterAsBool ( uint32 cid,
const char * name )

◆ getParameterDataType()

uint8 cmlabs::ComponentMemory::getParameterDataType ( uint32 cid,
const char * name )
Returns
PARAM_* type, 0 if absent.

Definition at line 2081 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, getParameter(), and cmlabs::ParamHeader::type.

◆ getParameterFloat()

float64 cmlabs::ComponentMemory::getParameterFloat ( uint32 cid,
const char * name )

Definition at line 2193 of file ComponentMemory.cpp.

References getParameter().

Referenced by UnitTest().

◆ getParameterInfo()

◆ getParameterInt()

int64 cmlabs::ComponentMemory::getParameterInt ( uint32 cid,
const char * name )

Definition at line 2186 of file ComponentMemory.cpp.

References getParameter().

Referenced by cmlabs::ComponentMemoryLayoutUnitTest(), and UnitTest().

◆ getParameterString() [1/2]

std::string cmlabs::ComponentMemory::getParameterString ( uint32 cid,
const char * name )

◆ getParameterString() [2/2]

std::string cmlabs::ComponentMemory::getParameterString ( uint32 cid,
const char * name,
uint32 maxSize )

Definition at line 2138 of file ComponentMemory.cpp.

References getParameter().

Referenced by UnitTest().

◆ getParameterValueSize()

uint32 cmlabs::ComponentMemory::getParameterValueSize ( uint32 cid,
const char * name )

◆ getPrivateData()

bool cmlabs::ComponentMemory::getPrivateData ( uint32 cid,
const char * name,
char * data,
uint64 maxSize )

◆ getPrivateDataCopy()

char * cmlabs::ComponentMemory::getPrivateDataCopy ( uint32 cid,
const char * name,
uint64 & size )
Returns
Caller-owned heap copy of the blob, or NULL.

Definition at line 1463 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, getPrivateData(), and cmlabs::PrivateHeader::size.

◆ getPrivateDataKeys()

std::list< std::string > cmlabs::ComponentMemory::getPrivateDataKeys ( uint32 cid)

◆ getPrivateDataKeysAndTypes()

std::map< std::string, std::string > cmlabs::ComponentMemory::getPrivateDataKeysAndTypes ( uint32 cid)

◆ getPrivateDataMimetype()

std::string cmlabs::ComponentMemory::getPrivateDataMimetype ( uint32 cid,
const char * name )
Returns
Blob mimetype, empty if absent.

Definition at line 1524 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and getPrivateData().

◆ getPrivateDataSize()

uint64 cmlabs::ComponentMemory::getPrivateDataSize ( uint32 cid,
const char * name )
Returns
Blob size in bytes, 0 if absent.

Definition at line 1439 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, getPrivateData(), and cmlabs::PrivateHeader::size.

Referenced by UnitTest().

◆ hasParameter()

bool cmlabs::ComponentMemory::hasParameter ( uint32 cid,
const char * name )
Returns
true if the parameter exists.

Definition at line 2031 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, and getParameter().

◆ isComponentLocal() [1/2]

bool cmlabs::ComponentMemory::isComponentLocal ( const char * name)
Returns
true if the named component runs on this node.

Definition at line 1075 of file ComponentMemory.cpp.

References getComponentID(), and isComponentLocal().

◆ isComponentLocal() [2/2]

bool cmlabs::ComponentMemory::isComponentLocal ( uint32 cid)
Returns
true if the component runs on this node.

Definition at line 1048 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::nodeID.

Referenced by isComponentLocal().

◆ isComponentPaused()

bool cmlabs::ComponentMemory::isComponentPaused ( uint32 cid)

Set the migration policy.

Returns
true if COMPONENT_PAUSED is set.
true on success.

Definition at line 904 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, COMPONENT_PAUSED, and GETCOMPDATA.

◆ lookupComponentID()

uint8 cmlabs::ComponentMemory::lookupComponentID ( const char * name,
uint32 & id )

Look up a component by name without filtering on readiness.

Parameters
nameComponent name to look up.
idReceives the component id when found.
Returns
Sync status: 0 not there, 1 in-sync (reserved), 2 ready.

Definition at line 1260 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::name, stricmp, and cmlabs::ComponentInfoStruct::syncStatus.

◆ open()

bool cmlabs::ComponentMemory::open ( )

◆ ParamTypeName()

const char * cmlabs::ComponentMemory::ParamTypeName ( uint8 type)
static

◆ printFriendly()

std::string cmlabs::ComponentMemory::printFriendly ( )
Returns
Human-readable dump of the registry.

Definition at line 83 of file ComponentMemory.cpp.

References getAllComponents(), and cmlabs::utils::StringFormat().

◆ resetParameter()

bool cmlabs::ComponentMemory::resetParameter ( uint32 cid,
const char * name )

Restore the parameter's default value/index.

Returns
true on success.

Definition at line 2576 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, getParameter(), PARAM_FLOAT, PARAM_FLOAT_COLL, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING, PARAM_STRING_COLL, PARAM_TYPE_COLL, setParameter(), and cmlabs::ParamHeader::type.

Referenced by UnitTest().

◆ setComponentData()

bool cmlabs::ComponentMemory::setComponentData ( uint32 cid,
const char * data,
uint64 size,
bool wasMigrated )

Replace a component's data area (after migration).

Parameters
cidComponent id.
dataNew data area.
sizeByte count.
wasMigratedMarks a migration event.
Returns
true on success.

Definition at line 788 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentStats::migrationCount, cmlabs::ComponentInfoStruct::size, and cmlabs::ComponentInfoStruct::stats.

◆ setComponentPaused()

bool cmlabs::ComponentMemory::setComponentPaused ( uint32 cid,
bool paused )

Set or clear COMPONENT_PAUSED (stop / start).

Returns
true if the component exists.

Definition at line 894 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, COMPONENT_PAUSED, and GETCOMPDATA.

◆ setComponentPerfStats()

bool cmlabs::ComponentMemory::setComponentPerfStats ( uint32 cid,
AveragePerfStats & perfStruct )

Store new performance averages.

Returns
true on success.

Definition at line 1196 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::perfStats.

◆ setComponentPolicy()

bool cmlabs::ComponentMemory::setComponentPolicy ( uint32 cid,
uint8 policy )

◆ setComponentSelfTrigger()

bool cmlabs::ComponentMemory::setComponentSelfTrigger ( uint32 cid,
uint8 selfTrigger )

Set the self-trigger policy.

Returns
true on success.

Definition at line 956 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::selfTrigger.

◆ setComponentStats()

bool cmlabs::ComponentMemory::setComponentStats ( uint32 cid,
ComponentStats & stats )

Overwrite the component's stats.

Returns
true on success.

Definition at line 1218 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, and cmlabs::ComponentInfoStruct::stats.

◆ setParameter() [1/3]

◆ setParameter() [2/3]

bool cmlabs::ComponentMemory::setParameter ( uint32 cid,
const char * name,
float64 val )

◆ setParameter() [3/3]

bool cmlabs::ComponentMemory::setParameter ( uint32 cid,
const char * name,
int64 val )

◆ setPrivateData()

bool cmlabs::ComponentMemory::setPrivateData ( uint32 cid,
const char * name,
const char * data,
uint64 size,
const char * mimetype = NULL )

◆ syncComponents()

bool cmlabs::ComponentMemory::syncComponents ( DataMessage * msg)

Merge component records received from a remote node.

Returns
true on success.

Definition at line 524 of file ComponentMemory.cpp.

References confirmComponentID(), createComponent(), cmlabs::DataMessage::getInt(), cmlabs::DataMessage::getString(), and cmlabs::DataMessage::getTime().

◆ toXML()

std::string cmlabs::ComponentMemory::toXML ( bool stats = true)
Returns
XML dump of all components (optionally with stats).

Definition at line 107 of file ComponentMemory.cpp.

References getAllComponents(), and cmlabs::utils::StringFormat().

◆ tweakParameter()

◆ UnitTest()

bool cmlabs::ComponentMemory::UnitTest ( )
static

Self-test.

Returns
true if all checks pass.

Definition at line 2920 of file ComponentMemory.cpp.

References addComponentStats(), COMP_INTERNAL, COMPONENT_CAN_MIGRATE, ComponentMemory(), cmlabs::MemoryManager::componentMemory, COMPSTATUS_RUNNING, confirmComponentID(), cmlabs::DataMapsMemory::confirmTagID(), cmlabs::DataMapsMemory::confirmTypeLevelID(), cmlabs::MemoryManager::create(), createComponent(), cmlabs::DataMapsMemory::createNewTag(), cmlabs::DataMapsMemory::createNewTypeLevel(), createParameter(), cmlabs::ComponentStats::cycleCount, cmlabs::MemoryManager::dataMapsMemory, deleteParameter(), deletePrivateData(), destroyComponent(), cmlabs::unittest::detail(), DRAFTMSGSIZE, cmlabs::unittest::fail(), getComponentID(), getComponentLocation(), getComponentName(), getComponentNameString(), getComponentNodeID(), getComponentProcessID(), getComponentSelfTrigger(), getComponentStats(), getComponentType(), cmlabs::DataMessage::getInt(), getParameter(), getParameterFloat(), getParameterInfo(), getParameterInt(), getParameterString(), getParameterValueSize(), getPrivateData(), getPrivateDataSize(), cmlabs::DataMessage::getSize(), cmlabs::DataMapsMemory::getTagID(), cmlabs::DataMapsMemory::getTagName(), cmlabs::DataMapsMemory::getTypeLevelID(), cmlabs::DataMapsMemory::getTypeLevelName(), cmlabs::ComponentStats::msgInBytes, cmlabs::ComponentStats::msgInCount, cmlabs::ComponentStats::msgOutBytes, cmlabs::ComponentStats::msgOutCount, PARAM_FLOAT, PARAM_INTEGER, PARAM_INTEGER_COLL, PARAM_STRING_COLL, cmlabs::unittest::progress(), cmlabs::ComponentStats::recentInMsg, resetParameter(), cmlabs::ComponentStats::runCount, SELFTRIGGER_ALLOW, SELFTRIGGER_WARN, cmlabs::DataMessage::setInt(), setParameter(), setPrivateData(), cmlabs::DataMessage::setString(), cmlabs::utils::strcpyavail(), tweakParameter(), updateComponentLocation(), and cmlabs::ComponentStats::usageCPUTicks.

Referenced by cmlabs::Register_ComponentMemory_Tests().

◆ updateComponentInformation()

bool cmlabs::ComponentMemory::updateComponentInformation ( uint32 cid,
uint8 type,
uint8 policy,
uint8 selfTrigger,
uint16 nodeID,
uint16 procID )

◆ updateComponentLocation()

bool cmlabs::ComponentMemory::updateComponentLocation ( uint32 cid,
uint16 nodeID,
uint16 procID )

Record a new location (after migration).

Returns
true on success.

Definition at line 742 of file ComponentMemory.cpp.

References CHECKCOMPONENTMEMORYSERIAL, GETCOMPDATA, cmlabs::ComponentInfoStruct::nodeID, and cmlabs::ComponentInfoStruct::procID.

Referenced by UnitTest().

◆ writeComponentNamesToMsg()

bool cmlabs::ComponentMemory::writeComponentNamesToMsg ( DataMessage * msg)

Write just the component names into msg.

Returns
true on success.

Definition at line 483 of file ComponentMemory.cpp.

References getAllComponents(), and cmlabs::DataMessage::setString().

◆ writeComponentsToMsg()

bool cmlabs::ComponentMemory::writeComponentsToMsg ( DataMessage * msg)

Serialize all component records into msg.

Returns
true on success.

Definition at line 501 of file ComponentMemory.cpp.

References getAllComponents().


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