| helics 3.6.1

Public Member Functions | List of all members
helics::apps::Player Class Reference

`#include <Player.hpp>`

Inheritance diagram for helics::apps::Player:

## Public Member Functions
| Player ()=default
| Player (std::vector< std::string > args)
| Player (int argc, char *argv[])
| Player (std::string_view name, const FederateInfo &fedInfo)
| Player (std::string_view name, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo)
| Player (std::string_view name, CoreApp &core, const FederateInfo &fedInfo)
| Player (std::string_view appName, const std::string &configString)
| Player (Player &&other_player)=default
Player & | operator= (Player &&fed)=default
virtual void | initialize () override
virtual void | runTo (Time stopTime_input) override
void | addPublication (std::string_view name, DataType type, std::string_view pubUnits=std::string_view())
template<class valType >
std::enable_if_t< helicsType< valType >) !=DataType::HELICS_CUSTOM > | addPublication (std::string_view key, std::string_view pubUnits=std::string_view())
void | addEndpoint (std::string_view endpointName, std::string_view endpointType=std::string_view())
template<class valType >
void | addPoint (Time pubTime, std::string_view key, const valType &val)
template<class valType >
void | addPoint (Time pubTime, int iteration, std::string_view key, const valType &val)
void | addMessage (Time sendTime, std::string_view src, std::string_view dest, std::string_view payload)
void | addMessage (Time sendTime, Time actionTime, std::string_view src, std::string_view dest, std::string_view payload)
auto | pointCount () const
auto | messageCount () const
auto | publicationCount () const
auto | endpointCount () const
const auto & | getPoint (int index) const
const auto & | getMessage (int index) const
Public Member Functions inherited from helics::apps::App
| App ()=default
| App (std::string_view defaultAppName, std::vector< std::string > args)
| App (std::string_view defaultAppName, int argc, char *argv[])
| App (std::string_view appName, const FederateInfo &fedInfo)
| App (std::string_view appName, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo)
| App (std::string_view appName, CoreApp &core, const FederateInfo &fedInfo)
| App (std::string_view appName, const std::string &configString)
| App (App &&other_app)=default
| App (const App &other_app)=delete
App & | operator= (App &&app)=default
App & | operator= (const App &app)=delete
void | loadFile (const std::string &filename, bool enableFederateInterfaceRegistration=true)
virtual void | run ()
virtual void | finalize ()
bool | isActive () const
const CombinationFederate & | accessUnderlyingFederate () const
std::shared_ptr< CombinationFederate > | getUnderlyingFederatePointer ()

## Additional Inherited Members
Protected Member Functions inherited from helics::apps::App
void | loadJsonFileConfiguration (const std::string &appName, const std::string &jsonString, bool enableFederateInterfaceRegistration)
void | loadInputFiles ()
void | loadConfigOptions (AppTextParser &aparser)
Protected Attributes inherited from helics::apps::App
std::shared_ptr< CombinationFederate > | fed
| the federate created for the App
Time | stopTime = Time::maxVal()
| the time the App should stop
std::string | configFileName
| name of the config file used for constructing the federate
std::string | inputFileName
| the name of the app input file
std::string | outFileName
| the name of any output file
bool | useLocal {false}
bool | fileLoaded {false}
bool | deactivated {false}
bool | quietMode {false}
bool | helpMode {false}
std::vector< std::string > | remArgs

## Detailed Description

class implementing a Player object, which is capable of reading a file and generating interfaces and sending signals at the appropriate times

the Player class is not thread-safe, don't try to use it from multiple threads without external protection, that will result in undefined behavior

## Constructor & Destructor Documentation

## ◆ Player() [1/8]

helics::apps::Player::Player | ( |  | ) |
| default

default constructor

## ◆ Player() [2/8]

helics::apps::Player::Player | ( | std::vector< std::string > | args | ) |
| explicit

construct from command line arguments in a vector

Parameters

  args | the command line arguments to pass in a reverse vector

## ◆ Player() [3/8]

helics::apps::Player::Player | ( | int | argc,
|  | char * | argv[]
| ) |  |

construct from command line arguments

Parameters

  argc | the number of arguments
  argv | the strings in the input

## ◆ Player() [4/8]

helics::apps::Player::Player | ( | std::string_view | name,
|  | const FederateInfo & | fedInfo
| ) |  |
| explicit

construct from a federate info object

Parameters

  name | the name of the federate (can be empty to use defaults from fedInfo)
  fedInfo | a pointer info object containing information on the desired federate configuration

## ◆ Player() [5/8]

helics::apps::Player::Player | ( | std::string_view | name,
|  | const std::shared_ptr< Core > & | core,
|  | const FederateInfo & | fedInfo
| ) |  |

constructor taking a federate information structure and using the given core

Parameters

  name | the name of the federate (can be empty to use defaults from fedInfo)
  core | a pointer to core object which the federate can join
  fedInfo | a federate information structure

## ◆ Player() [6/8]

helics::apps::Player::Player | ( | std::string_view | name,
|  | CoreApp & | core,
|  | const FederateInfo & | fedInfo
| ) |  |

constructor taking a federate information structure and using the given core

Parameters

  name | the name of the federate (can be empty to use defaults from fedInfo)
  core | a coreApp object that can be joined
  fedInfo | a federate information structure

## ◆ Player() [7/8]

helics::apps::Player::Player | ( | std::string_view | appName,
|  | const std::string & | configString
| ) |  |

constructor taking a file with the required information

Parameters

  appName | the name of the app
  configString | JSON, TOML or text file or JSON string defining the federate information and other configuration

## ◆ Player() [8/8]

helics::apps::Player::Player | ( | Player && | other_player | ) |
| default

move construction

## Member Function Documentation

## ◆ addEndpoint()

void helics::apps::Player::addEndpoint | ( | std::string_view | endpointName,
|  | std::string_view | endpointType = `std::string_view()`
| ) |  |

add an endpoint to the Player

Parameters

  endpointName | the name of the endpoint
  endpointType | the named type of the endpoint

## ◆ addMessage() [1/2]

void helics::apps::Player::addMessage | ( | Time | sendTime,
|  | std::string_view | src,
|  | std::string_view | dest,
|  | std::string_view | payload
| ) |  |

add a message to a Player queue

Parameters

  sendTime | the time the message should be sent
  src | the source endpoint of the message
  dest | the destination endpoint of the message
  payload | the payload of the message

## ◆ addMessage() [2/2]

void helics::apps::Player::addMessage | ( | Time | sendTime,
|  | Time | actionTime,
|  | std::string_view | src,
|  | std::string_view | dest,
|  | std::string_view | payload
| ) |  |

add an event for a specific time to a Player queue

Parameters

  sendTime | the time the message should be sent
  actionTime | the eventTime listed for the message
  src | the source endpoint of the message
  dest | the destination endpoint of the message
  payload | the payload of the message

## ◆ addPoint() [1/2]

template<class valType >

void helics::apps::Player::addPoint | ( | Time | pubTime,
|  | int | iteration,
|  | std::string_view | key,
|  | const valType & | val
| ) |  |
| inline

add a data point to publish through a Player

Parameters

  pubTime | the time of the publication
  iteration | the iteration count on which the value should be published
  key | the key for the publication
  val | the value to publish

## ◆ addPoint() [2/2]

template<class valType >

void helics::apps::Player::addPoint | ( | Time | pubTime,
|  | std::string_view | key,
|  | const valType & | val
| ) |  |
| inline

add a data point to publish through a Player

Parameters

  pubTime | the time of the publication
  key | the key for the publication
  val | the value to publish

## ◆ addPublication() [1/2]

template<class valType >

std::enable_if_t<helicsType<valType>) != DataType::HELICS_CUSTOM> helics::apps::Player::addPublication | ( | std::string_view | key,
|  | std::string_view | pubUnits = `std::string_view()`
| ) |  |
| inline

add a publication to a Player

Parameters

  key | the key of the publication to add
  pubUnits | the units associated with the publication

## ◆ addPublication() [2/2]

void helics::apps::Player::addPublication | ( | std::string_view | name,
|  | DataType | type,
|  | std::string_view | pubUnits = `std::string_view()`
| ) |  |

add a publication to a Player

Parameters

  name | the identifier of the publication to add
  type | the type of the publication
  pubUnits | the units associated with the publication

## ◆ endpointCount()

auto helics::apps::Player::endpointCount | ( |  | ) | const
| inline

get the number of endpoints

## ◆ getMessage()

const auto& helics::apps::Player::getMessage | ( | int | index | ) | const
| inline

get the messages from an index

## ◆ getPoint()

const auto& helics::apps::Player::getPoint | ( | int | index | ) | const
| inline

get the point from an index

## ◆ initialize()

void helics::apps::Player::initialize | ( |  | ) |
| override virtual

initialize the Player federate

generate all the publications and organize the points, the final publication count will be available after this time and the Player will enter the initialization mode, which means it will not be possible to add more publications calling run will automatically do this if necessary

Reimplemented from helics::apps::App.

References helics::apps::App::fed, and helics::Federate::STARTUP.

Referenced by runTo().

## ◆ messageCount()

auto helics::apps::Player::messageCount | ( |  | ) | const
| inline

get the number of messages loaded

## ◆ operator=()

Player& helics::apps::Player::operator= | ( | Player && | fed | ) |
| default

move assignment

## ◆ pointCount()

auto helics::apps::Player::pointCount | ( |  | ) | const
| inline

get the number of points loaded

## ◆ publicationCount()

auto helics::apps::Player::publicationCount | ( |  | ) | const
| inline

get the number of publications

## ◆ runTo()

void helics::apps::Player::runTo | ( | Time | stopTime_input | ) |
| override virtual

run the Player until the specified time

Parameters

  stopTime_input | the desired stop time

Implements helics::apps::App.

References helics::Federate::EXECUTING, helics::apps::App::fed, helics::FORCE_ITERATION, initialize(), helics::isValidIndex(), helics::Federate::STARTUP, and helics::timeZero.

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

- Player.hpp
- Player.cpp