helics  2.8.1
Public Member Functions | Public Attributes | Friends | List of all members
helics::ActionMessage Class Reference

#include <ActionMessage.hpp>

Public Member Functions

 ActionMessage () noexcept
 
 ActionMessage (action_message_def::action_t startingAction)
 
 ActionMessage (action_message_def::action_t startingAction, global_federate_id sourceId, global_federate_id destId)
 
 ActionMessage (ActionMessage &&act) noexcept
 
 ActionMessage (std::unique_ptr< Message > message)
 
 ActionMessage (const std::string &bytes)
 
 ActionMessage (const std::vector< char > &bytes)
 
 ActionMessage (const char *data, size_t size)
 
 ~ActionMessage ()
 
 ActionMessage (const ActionMessage &act)
 
ActionMessageoperator= (const ActionMessage &act)
 
ActionMessageoperator= (ActionMessage &&act) noexcept
 
ActionMessageoperator= (std::unique_ptr< Message > message) noexcept
 
action_message_def::action_t action () const noexcept
 
void setAction (action_message_def::action_t newAction)
 
void setSource (global_handle hand)
 
void setDestination (global_handle hand)
 
const std::vector< std::string > & getStringData () const
 
void clearStringData ()
 
void setStringData (const std::string &string1)
 
void setStringData (const std::string &string1, const std::string &string2)
 
void setStringData (const std::string &string1, const std::string &string2, const std::string &string3)
 
void setStringData (const std::string &string1, const std::string &string2, const std::string &string3, const std::string &string4)
 
const std::string & getString (int index) const
 
void setString (int index, const std::string &str)
 
global_handle getSource () const
 
global_handle getDest () const
 
void swapSourceDest () noexcept
 
void setExtraData (int32_t data)
 
int32_t getExtraData () const
 
void setExtraDestData (int32_t data)
 
int32_t getExtraDestData () const
 
int serializedByteCount () const
 
int toByteArray (char *data, int buffer_size) const
 
void to_string (std::string &data) const
 
std::string to_string () const
 
std::string to_json_string () const
 
std::string packetize () const
 
void packetize (std::string &data) const
 
std::string packetize_json () const
 
void to_vector (std::vector< char > &data) const
 
std::vector< char > to_vector () const
 
int fromByteArray (const char *data, int buffer_size)
 
int depacketize (const char *data, int buffer_size)
 
std::size_t from_string (const std::string &data)
 
bool from_json_string (const std::string &data)
 
std::size_t from_vector (const std::vector< char > &data)
 

Public Attributes

int32_t messageID {0}
 8 – message ID for a variety of purposes
 
global_federate_id source_id {parent_broker_id}
 12 – for federate_id or route_id
 
interface_handle source_handle {}
 16 – for local handle or local code
 
global_federate_id dest_id {parent_broker_id}
 20 fed_id for a targeted message
 
interface_handle dest_handle {}
 24 local handle for a targeted message
 
uint16_t counter {0}
 26 counter for filter tracking or message counter
 
uint16_t flags {0}
 28 set of messageFlags
 
uint32_t sequenceID {0}
 a sequence number for ordering
 
Time actionTime {timeZero}
 40 the time an action took place or will take place //32
 
std::string payload
 
std::string & name
 alias payload to a name reference for registration functions
 
Time Te {timeZero}
 48 event time
 
Time Tdemin {timeZero}
 56 min dependent event time
 
Time Tso {timeZero}
 64 the second order dependent time
 

Friends

std::unique_ptr< MessagecreateMessageFromCommand (const ActionMessage &cmd)
 
std::unique_ptr< MessagecreateMessageFromCommand (ActionMessage &&cmd)
 

Detailed Description

class defining the primary message object used in HELICS

Constructor & Destructor Documentation

◆ ActionMessage() [1/9]

helics::ActionMessage::ActionMessage ( )
inlinenoexcept

default constructor

◆ ActionMessage() [2/9]

helics::ActionMessage::ActionMessage ( action_message_def::action_t  startingAction)

construct from an action type

this is intended to be an implicit constructor

Parameters
startingActionfrom an action message definition

◆ ActionMessage() [3/9]

helics::ActionMessage::ActionMessage ( action_message_def::action_t  startingAction,
global_federate_id  sourceId,
global_federate_id  destId 
)

construct from action, source and destination id's

◆ ActionMessage() [4/9]

helics::ActionMessage::ActionMessage ( ActionMessage &&  act)
noexcept

move constructor

◆ ActionMessage() [5/9]

helics::ActionMessage::ActionMessage ( std::unique_ptr< Message message)
explicit

build an action message from a message

◆ ActionMessage() [6/9]

helics::ActionMessage::ActionMessage ( const std::string &  bytes)
explicit

construct from a string

References from_string().

◆ ActionMessage() [7/9]

helics::ActionMessage::ActionMessage ( const std::vector< char > &  bytes)
explicit

construct from a data vector

References from_vector().

◆ ActionMessage() [8/9]

helics::ActionMessage::ActionMessage ( const char *  data,
size_t  size 
)
explicit

construct from a data pointer and size

References data, from_json_string(), and fromByteArray().

◆ ~ActionMessage()

helics::ActionMessage::~ActionMessage ( )
default

destructor

◆ ActionMessage() [9/9]

helics::ActionMessage::ActionMessage ( const ActionMessage act)

copy constructor

Member Function Documentation

◆ action()

action_message_def::action_t helics::ActionMessage::action ( ) const
inlinenoexcept

◆ depacketize()

int helics::ActionMessage::depacketize ( const char *  data,
int  buffer_size 
)

load a command from a packetized stream /ref packetize

Returns
the number of bytes used

References data, from_json_string(), and fromByteArray().

Referenced by fromByteArray().

◆ from_json_string()

bool helics::ActionMessage::from_json_string ( const std::string &  data)

read a command from a json string

Returns
true if successful

References actionTime, counter, data, dest_handle, dest_id, flags, loadJsonStr(), messageID, payload, sequenceID, source_handle, source_id, Tdemin, Te, and Tso.

Referenced by ActionMessage(), depacketize(), from_string(), and from_vector().

◆ from_string()

std::size_t helics::ActionMessage::from_string ( const std::string &  data)

read a command from a string

Returns
number of bytes read

References data, from_json_string(), and fromByteArray().

Referenced by ActionMessage().

◆ from_vector()

std::size_t helics::ActionMessage::from_vector ( const std::vector< char > &  data)

read a command from a char vector

References data, from_json_string(), and fromByteArray().

Referenced by ActionMessage().

◆ fromByteArray()

int helics::ActionMessage::fromByteArray ( const char *  data,
int  buffer_size 
)

◆ getDest()

global_handle helics::ActionMessage::getDest ( ) const
inline

get the global destination handle

References dest_handle, and dest_id.

◆ getExtraData()

int32_t helics::ActionMessage::getExtraData ( ) const
inline

get the extra piece of integer data

References helics::interface_handle::baseValue(), and dest_handle.

◆ getExtraDestData()

int32_t helics::ActionMessage::getExtraDestData ( ) const
inline

get the extra piece of integer data used in the destination

References helics::interface_handle::baseValue(), and source_handle.

◆ getSource()

global_handle helics::ActionMessage::getSource ( ) const
inline

get the source global_handle

References source_handle, and source_id.

◆ getStringData()

const std::vector<std::string>& helics::ActionMessage::getStringData ( ) const
inline

get the reference to the string data vector

◆ operator=() [1/3]

ActionMessage & helics::ActionMessage::operator= ( ActionMessage &&  act)
noexcept

move assignment

◆ operator=() [2/3]

ActionMessage & helics::ActionMessage::operator= ( const ActionMessage act)

◆ operator=() [3/3]

ActionMessage & helics::ActionMessage::operator= ( std::unique_ptr< Message message)
noexcept

move assignment from message data into the actionMessage

take ownership of the message and move the contents out then destroy the message shell

Parameters
messagethe message to move.

◆ packetize()

std::string helics::ActionMessage::packetize ( ) const

packetize the message with a simple header and tail sequence

References data.

◆ packetize_json()

std::string helics::ActionMessage::packetize_json ( ) const

packetize the message with a simple header and tail sequence using json serialization

References data, and to_json_string().

◆ serializedByteCount()

int helics::ActionMessage::serializedByteCount ( ) const

generate a size of the message in bytes if it were to be serialized

References payload.

Referenced by to_string(), and to_vector().

◆ setAction()

void helics::ActionMessage::setAction ( action_message_def::action_t  newAction)

◆ setDestination()

void helics::ActionMessage::setDestination ( global_handle  hand)
inline

◆ setExtraData()

void helics::ActionMessage::setExtraData ( int32_t  data)
inline

set some extra piece of data if the full destination is not used

References data, and dest_handle.

Referenced by helics::CommsInterface::addRoute(), helics::NetworkCommsInterface::generateReplyToIncomingMessage(), and helics::CommsInterface::removeRoute().

◆ setExtraDestData()

void helics::ActionMessage::setExtraDestData ( int32_t  data)
inline

set some extra piece of data if the full source is not used

References data, and source_handle.

Referenced by helics::CommonCore::setHandleOption().

◆ setSource()

void helics::ActionMessage::setSource ( global_handle  hand)
inline

◆ swapSourceDest()

void helics::ActionMessage::swapSourceDest ( )
inlinenoexcept

swap the source and destination

References dest_handle, dest_id, source_handle, and source_id.

◆ to_json_string()

std::string helics::ActionMessage::to_json_string ( ) const

◆ to_string() [1/2]

std::string helics::ActionMessage::to_string ( ) const

◆ to_string() [2/2]

void helics::ActionMessage::to_string ( std::string &  data) const

convert to a string using a reference

References data, serializedByteCount(), and toByteArray().

Referenced by helics::appendMessage(), and helics::zeromq::ZmqRequestSets::transmit().

◆ to_vector() [1/2]

std::vector< char > helics::ActionMessage::to_vector ( ) const

convert a command to a byte vector

References data, serializedByteCount(), and toByteArray().

◆ to_vector() [2/2]

void helics::ActionMessage::to_vector ( std::vector< char > &  data) const

covert to a byte vector using a reference

References data, serializedByteCount(), and toByteArray().

◆ toByteArray()

int helics::ActionMessage::toByteArray ( char *  data,
int  buffer_size 
) const

convert a command to a raw data bytes

Parameters
[out]datapointer to memory to store the command
buffer_sizethe size of the buffer
Returns
the size of the buffer actually used

References actionTime, helics::interface_handle::baseValue(), helics::global_federate_id::baseValue(), counter, data, dest_handle, dest_id, flags, messageID, payload, sequenceID, source_handle, source_id, Tdemin, Te, and Tso.

Referenced by to_string(), and to_vector().

Friends And Related Function Documentation

◆ createMessageFromCommand [1/2]

std::unique_ptr<Message> createMessageFromCommand ( ActionMessage &&  cmd)
friend

create a new message object that moves all the information from the ActionMessage into newly allocated memory for the message

◆ createMessageFromCommand [2/2]

std::unique_ptr<Message> createMessageFromCommand ( const ActionMessage cmd)
friend

create a new message object that copies all the information from the ActionMessage into newly allocated memory for the message

Member Data Documentation

◆ payload

std::string helics::ActionMessage::payload

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