| helics 3.6.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, 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)
ActionMessage & | operator= (const ActionMessage &act)
ActionMessage & | operator= (ActionMessage &&act) noexcept
ActionMessage & | operator= (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< Message > | createMessageFromCommand (const ActionMessage &cmd)
std::unique_ptr< Message > | createMessageFromCommand (ActionMessage &&cmd)

## Detailed Description

class defining the primary multiMessage object used in HELICS

## Constructor & Destructor Documentation

## ◆ ActionMessage() [1/9]

helics::ActionMessage::ActionMessage | ( |  | ) |
| inline noexcept

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

  startingAction | from 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
| inline noexcept

get the action of the multiMessage

Referenced by helics::FederateState::addAction(), helics::appendMessage(), helics::apps::TypedBrokerServer::generateMessageResponse(), helics::prettyPrintString(), helics::TimeCoordinator::processConfigUpdateMessage(), helics::BaseTimeCoordinator::processDependencyUpdateMessage(), helics::FilterFederate::processDestFilterReturn(), helics::FilterFederate::processFilterReturn(), helics::FilterFederate::processMessageFilter(), helics::FederateState::processPostTerminationAction(), helics::BaseTimeCoordinator::processTimeMessage(), helics::TimeCoordinator::processTimeMessage(), helics::FederateState::routeMessage(), helics::FederateState::sendCommand(), helics::FederateState::setInterfaceProperty(), and helics::FederateState::setProperties().

## ◆ 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, helics::SmallBuffer::to_string(), 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
| ) |  |

generate a command from a raw data stream

References actionTime, helics::SmallBuffer::assign(), counter, depacketize(), dest_handle, dest_id, flags, helics::GlobalFederateId::getBaseTypePointer(), helics::InterfaceHandle::getBaseTypePointer(), messageID, payload, sequenceID, source_handle, source_id, Tdemin, Te, helics::timeZero, and Tso.

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

## ◆ 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

get the source GlobalHandle

References source_handle, and source_id.

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

## ◆ 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

set the string name associated with a actionMessage

References name(), and payload.

Referenced by helics::CoreBroker::addAlias(), helics::CommonCore::addDependency(), helics::CommonCore::addDestinationFilterToEndpoint(), helics::CoreBroker::addDestinationFilterToEndpoint(), helics::CommonCore::addSourceFilterToEndpoint(), helics::CoreBroker::addSourceFilterToEndpoint(), helics::CommonCore::connect(), helics::CoreBroker::dataLink(), helics::CommonCore::dataLink(), helics::NetworkCommsInterface::generateReplyToIncomingMessage(), helics::CommonCore::linkEndpoints(), helics::CoreBroker::linkEndpoints(), name(), helics::prettyPrintString(), helics::CommonCore::registerCloningFilter(), helics::CommonCore::registerDataSink(), helics::CommonCore::registerEndpoint(), helics::CommonCore::registerFederate(), helics::CommonCore::registerFilter(), helics::CommonCore::registerPublication(), helics::CommonCore::registerTargetedEndpoint(), helics::CommonCore::registerTranslator(), and helics::CommonCore::removeTarget().

## ◆ operator=() [1/3]

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

move assignment

## ◆ operator=() [2/3]

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

copy operator

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

## ◆ 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

  message | the 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 | ) |

set the action

Referenced by helics::CommonCore::addDestinationTarget(), helics::CommonCore::addSourceTarget(), helics::FilterFederate::destinationProcessMessage(), helics::BaseTimeCoordinator::generateTimeRequest(), helics::FilterFederate::processDestFilterReturn(), helics::FilterFederate::processFilterReturn(), helics::FilterFederate::processMessageFilter(), and helics::CommonCore::removeTarget().

## ◆ setDestination()

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

set the destination from a global handle

References dest_handle, dest_id, helics::GlobalHandle::fed_id, and helics::GlobalHandle::handle.

Referenced by helics::FederateState::closeInterface(), helics::FilterFederate::processMessageFilter(), helics::CommonCore::setInterfaceTag(), and helics::CommonCore::setValue().

## ◆ setExtraData()

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

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

References dest_handle.

Referenced by helics::CommsInterface::addRoute(), helics::TimeCoordinator::enteringExecMode(), helics::FederateState::finalize(), helics::NetworkCommsInterface::generateReplyToIncomingMessage(), helics::BaseTimeCoordinator::generateTimeRequest(), helics::CommsInterface::removeRoute(), helics::BaseTimeCoordinator::sendTimingInfo(), helics::TimeCoordinator::sendUpdatedExecRequest(), and helics::CommonCore::setIntegerProperty().

## ◆ setExtraDestData()

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

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

References source_handle.

Referenced by helics::BaseTimeCoordinator::generateTimeRequest(), helics::TimeCoordinator::sendUpdatedExecRequest(), helics::CommonCore::setHandleOption(), and helics::GlobalTimeCoordinator::updateTimeFactors().

## ◆ setSource()

void helics::ActionMessage::setSource | ( | GlobalHandle | hand | ) |
| inline

set the source from a global handle

References helics::GlobalHandle::fed_id, helics::GlobalHandle::handle, source_handle, and source_id.

Referenced by helics::CommonCore::addDestinationTarget(), helics::CommonCore::addSourceTarget(), helics::CommonCore::closeHandle(), helics::FederateState::closeInterface(), helics::FilterFederate::processFilterReturn(), helics::FilterFederate::processMessageFilter(), helics::CommonCore::removeTarget(), and helics::CommonCore::setInterfaceTag().

## ◆ swapSourceDest()

void helics::ActionMessage::swapSourceDest | ( |  | ) |
| inline noexcept

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

convert to a json string

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, helics::SmallBuffer::to_string(), and Tso.

Referenced by packetize_json(), and to_string().

## ◆ to_string() [1/2]

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

convert to a byte string

References helics::checkActionFlag(), serializedByteCount(), to_json_string(), toByteArray(), and helics::use_json_serialization_flag.

## ◆ 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] | data | pointer to memory to store the command
  | buffer_size | the 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:

- ActionMessage.hpp
- ActionMessage.cpp