| helics 3.6.1

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

`#include <Source.hpp>`

Inheritance diagram for helics::apps::Source:

## Public Member Functions
| Source ()=default
| Source (std::vector< std::string > args)
| Source (int argc, char *argv[])
| Source (std::string_view name, const FederateInfo &fedInfo)
| Source (std::string_view name, const std::shared_ptr< Core > &core, const FederateInfo &fedInfo)
| Source (std::string_view name, CoreApp &core, const FederateInfo &fedInfo)
| Source (std::string_view name, const std::string &configString)
| Source (Source &&other_source)=default
Source & | operator= (Source &&fed)=default
virtual void | initialize () override
virtual void | runTo (Time stopTime_input) override
void | addPublication (std::string_view key, std::string_view generator, DataType type, Time period, std::string_view units=std::string_view())
void | addPublication (std::string_view key, DataType type, Time period, std::string_view units=std::string_view())
int | addSignalGenerator (std::string_view name, std::string_view type)
void | setStartTime (std::string_view key, Time startTime)
void | setPeriod (std::string_view key, Time period)
void | linkPublicationToGenerator (std::string_view key, std::string_view generator)
void | linkPublicationToGenerator (std::string_view key, int genIndex)
std::shared_ptr< SignalGenerator > | getGenerator (int index)
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)
virtual void | loadTextFile (const std::string &textFile)
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 source federate, which is capable of generating signals of various kinds and sending signals at the appropriate times

the source class is NOT threadsafe, don't try to use it from multiple threads without external protection, that will result in undefined behavior

## Constructor & Destructor Documentation

## ◆ Source() [1/8]

helics::apps::Source::Source | ( |  | ) |
| default

default constructor

## ◆ Source() [2/8]

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

construct from command line arguments in a vector

Parameters

  args | The vector of string, the remaining arguments are returned in the args

## ◆ Source() [3/8]

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

construct from command line arguments

Parameters

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

## ◆ Source() [4/8]

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

construct from a federate info object

Parameters

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

## ◆ Source() [5/8]

helics::apps::Source::Source | ( | 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 source object (can be empty to use defaults from fedInfo)
  core | a pointer to core object which the federate can join
  fedInfo | a federate information structure

## ◆ Source() [6/8]

helics::apps::Source::Source | ( | 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

## ◆ Source() [7/8]

helics::apps::Source::Source | ( | std::string_view | name,
|  | const std::string & | configString
| ) |  |

constructor taking a file with the required information

Parameters

  name | the name of the source object (can be empty to use defaults from fedInfo)
  configString | file a JSON or TOML file or string containing configuration informatino

## ◆ Source() [8/8]

helics::apps::Source::Source | ( | Source && | other_source | ) |
| default

move construction

## Member Function Documentation

## ◆ addPublication() [1/2]

void helics::apps::Source::addPublication | ( | std::string_view | key,
|  | DataType | type,
|  | Time | period,
|  | std::string_view | units = `std::string_view()`
| ) |  |
| inline

add a publication to a source

Parameters

  key | the key of the publication to add
  type | the type of the publication
  period | the period of the publication
  units | the units associated with the publication

## ◆ addPublication() [2/2]

void helics::apps::Source::addPublication | ( | std::string_view | key,
|  | std::string_view | generator,
|  | DataType | type,
|  | Time | period,
|  | std::string_view | units = `std::string_view()`
| ) |  |

add a publication to a source

Parameters

  key | the key of the publication to add
  generator | the name of the generator to link with
  type | the type of the publication
  period | the period of the publication
  units | the units associated with the publication

## ◆ addSignalGenerator()

int helics::apps::Source::addSignalGenerator | ( | std::string_view | name,
|  | std::string_view | type
| ) |  |

add a signal generator to the source object

Returns
  an index for later reference of the signal generator

## ◆ getGenerator()

std::shared_ptr< SignalGenerator > helics::apps::Source::getGenerator | ( | int | index | ) |

get a pointer to the signal generator

## ◆ initialize()

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

initialize the source federate

connect all sources with a generator

Reimplemented from helics::apps::App.

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

Referenced by runTo().

## ◆ linkPublicationToGenerator() [1/2]

void helics::apps::Source::linkPublicationToGenerator | ( | std::string_view | key,
|  | int | genIndex
| ) |  |

tie a publication to a signal generator

## ◆ linkPublicationToGenerator() [2/2]

void helics::apps::Source::linkPublicationToGenerator | ( | std::string_view | key,
|  | std::string_view | generator
| ) |  |

tie a publication to a signal generator

## ◆ operator=()

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

move assignment

## ◆ runTo()

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

run the source until the specified time

Parameters

  stopTime_input | the desired stop time

Implements helics::apps::App.

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

## ◆ setPeriod()

void helics::apps::Source::setPeriod | ( | std::string_view | key,
|  | Time | period
| ) |  |

set the start time for a publication

## ◆ setStartTime()

void helics::apps::Source::setStartTime | ( | std::string_view | key,
|  | Time | startTime
| ) |  |

set the start time for a publication

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

- Source.hpp
- Source.cpp