helics  2.8.1
Classes | Public Member Functions | Static Public Member Functions | List of all members
helics::MessageFederateManager Class Reference

#include <MessageFederateManager.hpp>

Public Member Functions

 MessageFederateManager (Core *coreOb, MessageFederate *mFed, local_federate_id id)
 
EndpointregisterEndpoint (const std::string &name, const std::string &type)
 
void registerKnownCommunicationPath (const Endpoint &localEndpoint, const std::string &remoteEndpoint)
 give the core a hint for known communication paths Specifying a path that is not present will cause the simulation to abort with an error message More...
 
void subscribe (const Endpoint &ept, const std::string &pubName)
 
bool hasMessage () const
 
uint64_t pendingMessages () const
 
std::unique_ptr< MessagegetMessage ()
 
void sendMessage (const Endpoint &source, const std::string &dest, const data_view &message)
 
void sendMessage (const Endpoint &source, const std::string &dest, const data_view &message, Time sendTime)
 
void sendMessage (const Endpoint &source, std::unique_ptr< Message > message)
 
void updateTime (Time newTime, Time oldTime)
 
void startupToInitializeStateTransition ()
 
void initializeToExecuteStateTransition (iteration_result result)
 
std::string localQuery (const std::string &queryStr) const
 
EndpointgetEndpoint (const std::string &name)
 
const EndpointgetEndpoint (const std::string &name) const
 
EndpointgetEndpoint (int index)
 
const EndpointgetEndpoint (int index) const
 
void setEndpointNotificationCallback (const std::function< void(Endpoint &, Time)> &callback)
 
void disconnect ()
 
int getEndpointCount () const
 
void addSourceFilter (const Endpoint &ept, const std::string &filterName)
 
void addDestinationFilter (const Endpoint &ept, const std::string &filterName)
 

Static Public Member Functions

static bool hasMessage (const Endpoint &ept)
 
static uint64_t pendingMessages (const Endpoint &ept)
 
static std::unique_ptr< MessagegetMessage (const Endpoint &ept)
 
static void setEndpointNotificationCallback (const Endpoint &ept, const std::function< void(Endpoint &, Time)> &callback)
 

Detailed Description

class handling the implementation details of a value Federate

the functions will parallel those in message Federate and contain the actual implementation details

Constructor & Destructor Documentation

◆ MessageFederateManager()

helics::MessageFederateManager::MessageFederateManager ( Core coreOb,
MessageFederate mFed,
local_federate_id  id 
)

construct from a pointer to a core and a specified federate id

Member Function Documentation

◆ addDestinationFilter()

void helics::MessageFederateManager::addDestinationFilter ( const Endpoint ept,
const std::string &  filterName 
)

add a named filter to an endpoint for all message going to the endpoint

References helics::Core::addDestinationTarget().

◆ addSourceFilter()

void helics::MessageFederateManager::addSourceFilter ( const Endpoint ept,
const std::string &  filterName 
)

add a named filter to an endpoint for all message coming from the endpoint

References helics::Core::addSourceTarget().

◆ disconnect()

void helics::MessageFederateManager::disconnect ( )

disconnect from the coreObject

◆ getEndpoint()

Endpoint & helics::MessageFederateManager::getEndpoint ( const std::string &  name)

get the id of a registered publication from its id

Parameters
namethe publication id
Returns
ivalid_publication_id if name is not recognized otherwise returns the publication_id

◆ getEndpointCount()

int helics::MessageFederateManager::getEndpointCount ( ) const

get the number of registered endpoints

◆ getMessage()

std::unique_ptr< Message > helics::MessageFederateManager::getMessage ( const Endpoint ept)
static

receive a packet from a particular endpoint

Parameters
eptthe identifier for the endpoint
Returns
a message object

◆ hasMessage()

bool helics::MessageFederateManager::hasMessage ( ) const

check if the federate has any outstanding messages

◆ initializeToExecuteStateTransition()

void helics::MessageFederateManager::initializeToExecuteStateTransition ( iteration_result  result)

transition from initialize to execution State

References helics::initializationTime, helics::next_step, helics::timeZero, and updateTime().

◆ localQuery()

std::string helics::MessageFederateManager::localQuery ( const std::string &  queryStr) const

generate results for a local query

◆ pendingMessages() [1/2]

uint64_t helics::MessageFederateManager::pendingMessages ( ) const

Returns the number of pending receives for the specified destination endpoint.

Returns the number of pending receives for the specified destination endpoint.

this function is not preferred in multi-threaded contexts due to the required locking prefer to just use getMessage until it returns an invalid Message.

◆ pendingMessages() [2/2]

uint64_t helics::MessageFederateManager::pendingMessages ( const Endpoint ept)
static

Returns the number of pending receives for the specified destination endpoint.

◆ registerEndpoint()

Endpoint & helics::MessageFederateManager::registerEndpoint ( const std::string &  name,
const std::string &  type 
)

register an endpoint

call is only valid in startup mode

Parameters
namethe name of the endpoint
typethe defined type of the interface for endpoint checking if requested

References helics::Core::registerEndpoint().

◆ registerKnownCommunicationPath()

void helics::MessageFederateManager::registerKnownCommunicationPath ( const Endpoint localEndpoint,
const std::string &  remoteEndpoint 
)

give the core a hint for known communication paths Specifying a path that is not present will cause the simulation to abort with an error message

Parameters
localEndpointthe local endpoint of a known communication pair
remoteEndpointof a communication pair

References helics::Endpoint::getName(), and helics::Core::registerFrequentCommunicationsPair().

◆ setEndpointNotificationCallback() [1/2]

void helics::MessageFederateManager::setEndpointNotificationCallback ( const Endpoint ept,
const std::function< void(Endpoint &, Time)> &  callback 
)
static

register a callback function to call when the specified endpoint receives a message

Parameters
eptthe endpoint id to register the callback for
callbackthe function to call

◆ setEndpointNotificationCallback() [2/2]

void helics::MessageFederateManager::setEndpointNotificationCallback ( const std::function< void(Endpoint &, Time)> &  callback)

register a callback function to call when any endpoint receives a message

there can only be one generic callback

Parameters
callbackthe function to call

◆ startupToInitializeStateTransition()

void helics::MessageFederateManager::startupToInitializeStateTransition ( )

transition from Startup To the Initialize State

◆ subscribe()

void helics::MessageFederateManager::subscribe ( const Endpoint ept,
const std::string &  pubName 
)

subscribe to valueFederate publication to be delivered as Messages to the given endpoint

Parameters
eptthe specified endpoint to deliver the values
pubNamethe name of the publication to subscribe

References helics::Core::addSourceTarget().

◆ updateTime()

void helics::MessageFederateManager::updateTime ( Time  newTime,
Time  oldTime 
)

update the time from oldTime to newTime

Parameters
newTimethe newTime of the federate
oldTimethe oldTime of the federate

find the id

References helics::Core::receiveAny(), and helics::Core::receiveCountAny().

Referenced by initializeToExecuteStateTransition().


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