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

Specification of a message to post when a trigger fires (or a crank completes). More...

#include <Subscriptions.h>

Collaboration diagram for cmlabs::PostSpec:
[legend]

Public Member Functions

std::string toXML ()
 Serialise as a <post ...>...</post> XML element including content children.
bool fromXML (const char *xml)
 Parse from an XML string containing a <post .../> element.
bool fromXML (XMLNode &node)
 Parse from an already-parsed <post> XML node, including its <content> children.
bool contentFromXML (XMLNode &node)
 Collect inline <content> entries (and contentkey/content attributes) from the XML node into the packed content buffer.
uint32 addContentToMsg (DataMessage *msg)
 Unpack the inline content entries into msg as typed user entries.

Public Attributes

uint32 to
 Addressee component id (0 = publish to subscribers).
PsyType type
 Type of the posted message.
PsyContext context
 Context the post applies in.
PsyContext contextchange
 Context switch the posted message announces (NOCONTEXT if none).
uint32 tag
 Tag for the posted message.
uint64 ttl
 Time-to-live of the posted message in microseconds.
uint8 policy
 Delivery policy flags (e.g.
uint32 contentCount
 Number of inline content entries packed into content.
char name [MAXKEYNAMELEN+1]
 Name of this post spec.
char content [MAXCONTENTLEN+1]
 Packed content entries: "||T||key||value" repeated (T = S, I or F).

Detailed Description

Specification of a message to post when a trigger fires (or a crank completes).

Describes the outgoing message: addressee, type, contexts, tag, ttl, policy, plus optional inline content entries. Content is packed into the fixed content buffer as a "||T||key||value" token list (T = S/I/F for string/integer/float) so the whole spec stays a flat fixed-size POD; addContentToMsg() unpacks it into a real DataMessage at post time.

Definition at line 270 of file Subscriptions.h.

Member Function Documentation

◆ addContentToMsg()

uint32 cmlabs::PostSpec::addContentToMsg ( DataMessage * msg)
inline

Unpack the inline content entries into msg as typed user entries.

Parameters
msgthe message being posted (entries are set on it)
Returns
number of entries added

Definition at line 380 of file Subscriptions.h.

References cmlabs::utils::Ascii2Float64(), cmlabs::utils::Ascii2Int64(), content, contentCount, cmlabs::DataMessage::setFloat(), cmlabs::DataMessage::setInt(), cmlabs::DataMessage::setString(), and cmlabs::utils::TextListSplit().

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

◆ contentFromXML()

bool cmlabs::PostSpec::contentFromXML ( XMLNode & node)
inline

Collect inline <content> entries (and contentkey/content attributes) from the XML node into the packed content buffer.

Parameters
nodethe XML node.
Returns
true.

Definition at line 346 of file Subscriptions.h.

References content, contentCount, cmlabs::html::DecodeHTML(), cmlabs::XMLNode::getAttribute(), cmlabs::XMLNode::getChildNode(), MAXCONTENTLEN, cmlabs::XMLNode::nChildNode(), cmlabs::utils::strcpyavail(), stricmp, and cmlabs::utils::StringFormat().

Referenced by fromXML().

◆ fromXML() [1/2]

bool cmlabs::PostSpec::fromXML ( const char * xml)
inline

Parse from an XML string containing a <post .../> element.

Parameters
xmlXML text.
Returns
true if all attributes were present and valid.

Definition at line 319 of file Subscriptions.h.

References cmlabs::XMLResults::error, cmlabs::eXMLErrorNone, fromXML(), and cmlabs::XMLNode::isEmpty().

Referenced by fromXML(), and Java_com_cmlabs_cmsdk_cmsdkJNI_PostSpec_1fromXML_1_1SWIG_10().

◆ fromXML() [2/2]

bool cmlabs::PostSpec::fromXML ( XMLNode & node)
inline

Parse from an already-parsed <post> XML node, including its <content> children.

Parameters
nodethe XML node.
Returns
true if all attributes were present and valid.

Definition at line 329 of file Subscriptions.h.

References cmlabs::utils::Ascii2Uint32(), cmlabs::utils::Ascii2Uint64(), contentFromXML(), context, contextchange, cmlabs::XMLNode::getAttribute(), MAXKEYNAMELEN, name, policy, cmlabs::utils::strcpyavail(), tag, to, ttl, and type.

◆ toXML()

std::string cmlabs::PostSpec::toXML ( )
inline

Serialise as a <post ...>...</post> XML element including content children.

Definition at line 283 of file Subscriptions.h.

References content, contentCount, context, contextchange, cmlabs::html::EncodeHTML(), name, policy, cmlabs::utils::StringFormat(), tag, cmlabs::utils::TextListSplit(), to, ttl, and type.

Referenced by cmlabs::TriggerSpec::toXML(), and cmlabs::TriggerSpec::UnitTest().

Member Data Documentation

◆ content

char cmlabs::PostSpec::content[MAXCONTENTLEN+1]

◆ contentCount

uint32 cmlabs::PostSpec::contentCount

Number of inline content entries packed into content.

Definition at line 278 of file Subscriptions.h.

Referenced by addContentToMsg(), contentFromXML(), toXML(), and cmlabs::TriggerSpec::UnitTest().

◆ context

PsyContext cmlabs::PostSpec::context

Context the post applies in.

Definition at line 273 of file Subscriptions.h.

Referenced by fromXML(), and toXML().

◆ contextchange

PsyContext cmlabs::PostSpec::contextchange

Context switch the posted message announces (NOCONTEXT if none).

Definition at line 274 of file Subscriptions.h.

Referenced by fromXML(), cmlabs::PsyAPI::postOutputMessage(), and toXML().

◆ name

◆ policy

uint8 cmlabs::PostSpec::policy

Delivery policy flags (e.g.

MESSAGE_NON_GUARANTEED).

Definition at line 277 of file Subscriptions.h.

Referenced by fromXML(), cmlabs::PsyAPI::postOutputMessage(), and toXML().

◆ tag

uint32 cmlabs::PostSpec::tag

Tag for the posted message.

Definition at line 275 of file Subscriptions.h.

Referenced by fromXML(), cmlabs::PsyAPI::postOutputMessage(), and toXML().

◆ to

uint32 cmlabs::PostSpec::to

Addressee component id (0 = publish to subscribers).

Definition at line 271 of file Subscriptions.h.

Referenced by fromXML(), cmlabs::PsyAPI::postOutputMessage(), toXML(), and cmlabs::TriggerSpec::UnitTest().

◆ ttl

uint64 cmlabs::PostSpec::ttl

Time-to-live of the posted message in microseconds.

Definition at line 276 of file Subscriptions.h.

Referenced by fromXML(), cmlabs::PsyAPI::postOutputMessage(), and toXML().

◆ type


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