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

Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone. More...

#include <Types.h>

Public Member Functions

bool isValid ()
 A type is valid if its root level is non-zero.
bool operator== (const PsyType &othertype) const
 Exact byte-wise equality of all levels (wildcards NOT honoured; use matches() for that).
bool operator!= (const PsyType &othertype) const
 Exact byte-wise inequality (wildcards NOT honoured).
bool operator< (const PsyType &othertype) const
 Lexicographic level-by-level ordering, so PsyType can be used as a std::map/std::multimap key.
bool operator> (const PsyType &othertype) const
uint16 operator[] (int i) const
bool setLevel (int i, uint16 value)
 Set an individual hierarchy level.
bool matches (PsyType &otherType) const
 Wildcard-aware type matching used by the subscription system.
std::string toString ()
 Render as dotted decimal notation, e.g. "2.201.3"; empty string if invalid.
std::string toString (std::map< uint16, std::string > *subtypes)
 Render as dotted notation, substituting readable names for level ids where available.
bool fromString (const char *text)
 Parse dotted decimal notation (e.g.

Public Attributes

uint16 levels [PSYTYPELEVELS]
 Hierarchy levels, most significant first; 0 terminates, 0xFFFF is a wildcard.

Detailed Description

Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.

A PsyType is a fixed array of 16 uint16 levels forming a dotted hierarchy, e.g. "2.201.3" is stored as levels = {2, 201, 3, 0, ...}. Level value 0 ends the hierarchy (a valid type must have levels[0] != 0) and the special value 0xFFFF acts as a wildcard in matches(). Subscriptions match message types via matches(), so a subscriber to "2.201.0xFFFF" receives all subtypes of "2.201".

t.fromString("2.201.3"); // parse dotted notation
std::string s = t.toString(); // "2.201.3"
if (t.matches(otherType)) { ... } // wildcard-aware comparison
Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.
Definition Types.h:123
bool matches(PsyType &otherType) const
Wildcard-aware type matching used by the subscription system.
Definition Types.h:173
bool fromString(const char *text)
Parse dotted decimal notation (e.g.
Definition Types.h:233
std::string toString()
Render as dotted decimal notation, e.g. "2.201.3"; empty string if invalid.
Definition Types.h:195
Note
POD with no constructor: embedded verbatim in DataMessageHeader and other wire structs, so its size (32 bytes) must never change. Use NOTYPE for the empty/unset value.

Definition at line 123 of file Types.h.

Member Function Documentation

◆ fromString()

bool PsyType::fromString ( const char * text)
inline

Parse dotted decimal notation (e.g.

"2.201.3") into the level array. All levels are reset first.

Parameters
textdotted type string
Returns
true if the result is a valid type

Definition at line 233 of file Types.h.

References isValid(), levels, and PSYTYPELEVELS.

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

◆ isValid()

bool PsyType::isValid ( )
inline

A type is valid if its root level is non-zero.

Definition at line 126 of file Types.h.

References levels.

Referenced by fromString(), and cmlabs::PsyAPI::postOutputMessage().

◆ matches()

bool PsyType::matches ( PsyType & otherType) const
inline

Wildcard-aware type matching used by the subscription system.

Two types match if every level is either equal or 0xFFFF on either side.

Parameters
otherTypethe type to compare against
Returns
true if the types match

Definition at line 173 of file Types.h.

References levels, and PSYTYPELEVELS.

◆ operator!=()

bool PsyType::operator!= ( const PsyType & othertype) const
inline

Exact byte-wise inequality (wildcards NOT honoured).

Definition at line 132 of file Types.h.

References levels.

◆ operator<()

bool PsyType::operator< ( const PsyType & othertype) const
inline

Lexicographic level-by-level ordering, so PsyType can be used as a std::map/std::multimap key.

Definition at line 136 of file Types.h.

References levels, and PSYTYPELEVELS.

◆ operator==()

bool PsyType::operator== ( const PsyType & othertype) const
inline

Exact byte-wise equality of all levels (wildcards NOT honoured; use matches() for that).

Definition at line 128 of file Types.h.

References levels.

◆ operator>()

bool PsyType::operator> ( const PsyType & othertype) const
inline

Definition at line 145 of file Types.h.

References levels, and PSYTYPELEVELS.

◆ operator[]()

uint16 PsyType::operator[] ( int i) const
inline

Definition at line 154 of file Types.h.

References levels, and PSYTYPELEVELS.

◆ setLevel()

bool PsyType::setLevel ( int i,
uint16 value )
inline

Set an individual hierarchy level.

Parameters
ilevel index (0..PSYTYPELEVELS-1)
valuelevel value (0 terminates, 0xFFFF = wildcard)
Returns
true if set

Definition at line 163 of file Types.h.

References levels, and PSYTYPELEVELS.

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

◆ toString() [1/2]

std::string PsyType::toString ( )
inline

Render as dotted decimal notation, e.g. "2.201.3"; empty string if invalid.

Definition at line 195 of file Types.h.

References levels, and PSYTYPELEVELS.

Referenced by toString().

◆ toString() [2/2]

std::string PsyType::toString ( std::map< uint16, std::string > * subtypes)
inline

Render as dotted notation, substituting readable names for level ids where available.

Parameters
subtypesmap of level id → name; NULL falls back to numeric toString()

Definition at line 208 of file Types.h.

References levels, PSYTYPELEVELS, and toString().

Member Data Documentation

◆ levels

uint16 PsyType::levels[PSYTYPELEVELS]

Hierarchy levels, most significant first; 0 terminates, 0xFFFF is a wildcard.

Definition at line 124 of file Types.h.

Referenced by fromString(), isValid(), matches(), operator!=(), operator<(), operator==(), operator>(), operator[](), setLevel(), toString(), and toString().


The documentation for this struct was generated from the following file:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/Types.h