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

Registry of perch points parsed from PsySpec XML, with reserve/occupy/free bookkeeping. More...

#include <VantagePoints.h>

Public Member Functions

 VantagePoints ()
 ~VantagePoints ()
bool init (const char *xml)
 Parse the configuration from XML text.
bool init (XMLNode node)
 Parse the configuration from an already-parsed XML node.
uint32 reserveNextPoint (uint32 entityID)
 Reserve the best available (least-overlapping free) point for an entity.
bool occupyPoint (uint32 id, uint32 entityID)
 Mark a reserved point as occupied.
bool freePoint (uint32 id, uint32 entityID)
 Release a point held by entityID.
const char * getPointData (uint32 id)
 Opaque data string attached to a point in the XML.
const char * getPointLabel (uint32 id)
 Label of a point.

Static Public Member Functions

static bool UnitTest ()
 Self test.

Public Attributes

uint32 count
 Number of perch points.
VantageState state
 Current system state.

Detailed Description

Registry of perch points parsed from PsySpec XML, with reserve/occupy/free bookkeeping.

Definition at line 34 of file VantagePoints.h.

Constructor & Destructor Documentation

◆ VantagePoints()

cmlabs::VantagePoints::VantagePoints ( )

Definition at line 7 of file VantagePoints.cpp.

References count, cmlabs::IDLE, and state.

Referenced by UnitTest().

◆ ~VantagePoints()

cmlabs::VantagePoints::~VantagePoints ( )

Definition at line 16 of file VantagePoints.cpp.

Member Function Documentation

◆ freePoint()

bool cmlabs::VantagePoints::freePoint ( uint32 id,
uint32 entityID )

Release a point held by entityID.

Parameters
idPoint id.
entityIDHolder.
Returns
true on success.

Definition at line 223 of file VantagePoints.cpp.

References count, cmlabs::PerchPoint::entityID, cmlabs::FREE, cmlabs::RESERVED, cmlabs::SETTLED, cmlabs::PerchPoint::state, and state.

Referenced by UnitTest().

◆ getPointData()

const char * cmlabs::VantagePoints::getPointData ( uint32 id)

Opaque data string attached to a point in the XML.

Parameters
idPoint id.
Returns
Data text, or NULL for an unknown id.

Definition at line 117 of file VantagePoints.cpp.

References count, and cmlabs::PerchPoint::data.

Referenced by UnitTest().

◆ getPointLabel()

const char * cmlabs::VantagePoints::getPointLabel ( uint32 id)

Label of a point.

Parameters
idPoint id.
Returns
Label text, or NULL for an unknown id.

Definition at line 124 of file VantagePoints.cpp.

References count, and cmlabs::PerchPoint::label.

Referenced by UnitTest().

◆ init() [1/2]

bool cmlabs::VantagePoints::init ( const char * xml)

Parse the configuration from XML text.

Parameters
xmlPsySpec XML.
Returns
true on success.

Definition at line 19 of file VantagePoints.cpp.

References cmlabs::XMLResults::error, cmlabs::eXMLErrorNone, and init().

Referenced by init(), and UnitTest().

◆ init() [2/2]

◆ occupyPoint()

bool cmlabs::VantagePoints::occupyPoint ( uint32 id,
uint32 entityID )

Mark a reserved point as occupied.

Parameters
idPoint id.
entityIDMust match the reserving entity.
Returns
true on success.

Definition at line 207 of file VantagePoints.cpp.

References count, cmlabs::PerchPoint::entityID, cmlabs::OCCUPIED, cmlabs::RESERVED, cmlabs::SETTLED, cmlabs::PerchPoint::state, and state.

Referenced by UnitTest().

◆ reserveNextPoint()

uint32 cmlabs::VantagePoints::reserveNextPoint ( uint32 entityID)

Reserve the best available (least-overlapping free) point for an entity.

Parameters
entityIDClaiming entity.
Returns
Point id, or 0 when none is free.

Definition at line 132 of file VantagePoints.cpp.

References count, cmlabs::PerchPoint::entityID, cmlabs::FREE, cmlabs::GetTimeAgeMS(), cmlabs::GetTimeNow(), cmlabs::PerchPoint::id, cmlabs::IDLE, cmlabs::INMOTION, cmlabs::PerchPoint::lastVisit, cmlabs::PerchPoint::overlaps, cmlabs::RESERVED, cmlabs::PerchPoint::state, and state.

Referenced by UnitTest().

◆ UnitTest()

Member Data Documentation

◆ count

uint32 cmlabs::VantagePoints::count

Number of perch points.

Definition at line 58 of file VantagePoints.h.

Referenced by freePoint(), getPointData(), getPointLabel(), init(), occupyPoint(), reserveNextPoint(), UnitTest(), and VantagePoints().

◆ state

VantageState cmlabs::VantagePoints::state

Current system state.

Definition at line 59 of file VantagePoints.h.

Referenced by freePoint(), occupyPoint(), reserveNextPoint(), UnitTest(), and VantagePoints().


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