helics  3.5.2
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, GlobalFederateId sourceId, GlobalFederateId destId)
 
 ActionMessage (ActionMessage &&act) noexcept
 
 ActionMessage (std::unique_ptr< Message > message)
 
 ActionMessage (const std::string &bytes)
 
 ActionMessage (const std::vector< char > &bytes)
 
 ActionMessage (const void *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 (GlobalHandle hand)
 
void setDestination (GlobalHandle hand)
 
const std::vector< std::string > & getStringData () const
 
void name (std::string_view name)
 
std::string_view name () const
 
void clearStringData ()
 
void setStringData (std::string_view string1)
 
void setStringData (std::string_view string1, std::string_view string2)
 
void setStringData (std::string_view string1, std::string_view string2, std::string_view string3)
 
void setStringData (std::string_view string1, std::string_view string2, std::string_view string3, std::string_view string4)
 
const std::string & getString (int index) const
 
void setString (int index, std::string_view str)
 
GlobalHandle getSource () const
 
GlobalHandle 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 (std::byte *data, std::size_t 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
 
std::size_t fromByteArray (const std::byte *data, std::size_t buffer_size)
 
std::size_t depacketize (const void *data, std::size_t buffer_size)
 
std::size_t from_string (std::string_view data)
 
bool from_json_string (std::string_view data)
 
std::size_t from_vector (const std::vector< char > &data)
 

Public Attributes

int32_t messageID {0}
 8 – multiMessage ID for a variety of purposes
 
GlobalFederateId source_id {parent_broker_id}
 12 – for federate_id or route_id
 
InterfaceHandle source_handle {}
 16 – for local handle or local code
 
GlobalFederateId dest_id {parent_broker_id}
 20 fed_id for a targeted multiMessage
 
InterfaceHandle dest_handle {}
 24 local handle for a targeted multiMessage
 
uint16_t counter {0}
 26 counter for filter tracking or multiMessage counter
 
uint16_t flags {0}
 28 set of messageFlags
 
uint32_t sequenceID {0}
 32 a sequence number for ordering
 
Time actionTime {timeZero}
 40 the time an action took place or will take place //32
 
Time Te {timeZero}
 48 event time
 
Time Tdemin {timeZero}
 56 min dependent event time
 
Time Tso {timeZero}
 64 the second order dependent time
 
SmallBuffer payload
 buffer to contain the data payload
 

Friends

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

Detailed Description

class defining the primary multiMessage 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,
GlobalFederateId  sourceId,
GlobalFederateId  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 void *  data,
size_t  size 
)

construct from a data pointer and size

References from_string().

◆ ~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()

std::size_t helics::ActionMessage::depacketize ( const void *  data,
std::size_t  buffer_size 
)

load a command from a packetized stream /ref packetize

Returns
the number of bytes used

References from_json_string(), and fromByteArray().

Referenced by fromByteArray().

◆ from_json_string()

bool helics::ActionMessage::from_json_string ( std::string_view  data)

read a command from a json string

Returns
true if successful

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

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

◆ from_string()

std::size_t helics::ActionMessage::from_string ( std::string_view  data)

read a command from a string

Returns
number of bytes read

References 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 from_json_string(), and fromByteArray().

Referenced by ActionMessage().

◆ fromByteArray()

std::size_t helics::ActionMessage::fromByteArray ( const std::byte *  data,
std::size_t  buffer_size 
)

◆ getDest()

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

get the global destination handle

References dest_handle, and dest_id.

Referenced by helics::FilterFederate::processMessageFilter().

◆ getExtraData()

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

get the extra piece of integer data

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

Referenced by helics::FederateState::setProperties().

◆ getExtraDestData()

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

get the extra piece of integer data used in the destination

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

Referenced by helics::FederateState::setInterfaceProperty().

◆ getSource()

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

◆ getStringData()

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

get the reference to the string data vector

◆ name() [1/2]

std::string_view helics::ActionMessage::name ( ) const
inline

get the string name associated with an action Message

References payload, and helics::SmallBuffer::to_string().

◆ name() [2/2]

void helics::ActionMessage::name ( std::string_view  name)
inline

◆ 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 multiMessage with a simple header and tail sequence

◆ packetize_json()

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

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

References to_json_string().

◆ serializedByteCount()

int helics::ActionMessage::serializedByteCount ( ) const

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

References payload, and helics::SmallBuffer::size().

Referenced by to_string(), and to_vector().

◆ setAction()

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

◆ setDestination()

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

◆ setExtraData()

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

◆ setExtraDestData()

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

◆ setSource()

void helics::ActionMessage::setSource ( GlobalHandle  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 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 serializedByteCount(), and toByteArray().

◆ to_vector() [2/2]

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

convert to a byte vector using a reference

References serializedByteCount(), and toByteArray().

◆ toByteArray()

int helics::ActionMessage::toByteArray ( std::byte *  data,
std::size_t  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::GlobalFederateId::baseValue(), helics::InterfaceHandle::baseValue(), counter, helics::SmallBuffer::data(), dest_handle, dest_id, flags, messageID, payload, sequenceID, helics::SmallBuffer::size(), 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 multiMessage object that moves all the information from the ActionMessage into newly allocated memory for the multiMessage

◆ createMessageFromCommand [2/2]

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

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


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