helics  2.8.1
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
helics::apps::App Class Referenceabstract

#include <helicsApp.hpp>

+ Inheritance diagram for helics::apps::App:

Public Member Functions

 App ()=default
 
 App (const std::string &defaultAppName, std::vector< std::string > args)
 
 App (const std::string &defaultAppName, int argc, char *argv[])
 
 App (const std::string &appName, const FederateInfo &fi)
 
 App (const std::string &appName, const std::shared_ptr< Core > &core, const FederateInfo &fi)
 
 App (const std::string &appName, CoreApp &core, const FederateInfo &fi)
 
 App (const std::string &appName, const std::string &jsonString)
 
 App (App &&other_app)=default
 
 App (const App &other_app)=delete
 
Appoperator= (App &&app)=default
 
Appoperator= (const App &app)=delete
 
void loadFile (const std::string &filename)
 
virtual void initialize ()
 
virtual void run ()
 
virtual void runTo (Time stopTime_input)=0
 
virtual void finalize ()
 
bool isActive () const
 
const CombinationFederateaccessUnderlyingFederate () const
 

Protected Member Functions

virtual void loadJsonFile (const std::string &jsonString)
 
void loadJsonFileConfiguration (const std::string &appName, const std::string &jsonString)
 
virtual void loadTextFile (const std::string &textFile)
 

Protected Attributes

std::shared_ptr< CombinationFederatefed
 the federate created for the Player
 
Time stopTime = Time::maxVal()
 the time the Player should stop
 
std::string masterFileName
 the name of the master file used to do the construction
 
bool useLocal {false}
 
bool fileLoaded {false}
 
bool deactivated {false}
 
bool quietMode {false}
 
bool helpMode {false}
 
std::vector< std::string > remArgs
 

Detailed Description

class defining a basic helics App

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

Constructor & Destructor Documentation

◆ App() [1/9]

helics::apps::App::App ( )
default

default constructor

◆ App() [2/9]

helics::apps::App::App ( const std::string &  defaultAppName,
std::vector< std::string >  args 
)

construct from command line arguments in a vector

Parameters
defaultAppNamethe name to use if not specified in one of the arguments
argsthe command line arguments to pass in a reverse vector

◆ App() [3/9]

helics::apps::App::App ( const std::string &  defaultAppName,
int  argc,
char *  argv[] 
)

construct from command line arguments

Parameters
defaultAppNamethe name to use if not specified in one of the arguments
argcthe number of arguments
argvthe strings in the input

◆ App() [4/9]

helics::apps::App::App ( const std::string &  appName,
const FederateInfo fi 
)

construct from a federate info object

Parameters
appNamethe name of the application, can be left empty to use a name specified in fi
fia pointer info object containing information on the desired federate configuration

◆ App() [5/9]

helics::apps::App::App ( const std::string &  appName,
const std::shared_ptr< Core > &  core,
const FederateInfo fi 
)

constructor taking a federate information structure and using the given core

Parameters
appNamethe name of the application, can be left empty to use a name specified in fi
corea pointer to core object which the federate can join
fia federate information structure

◆ App() [6/9]

helics::apps::App::App ( const std::string &  appName,
CoreApp &  core,
const FederateInfo fi 
)

constructor taking a federate information structure and using the given coreApp

Parameters
appNamethe name of the application, can be left empty to use a name specified in fi
corea pointer to core object which the federate can join
fia federate information structure

◆ App() [7/9]

helics::apps::App::App ( const std::string &  appName,
const std::string &  jsonString 
)

constructor taking a file with the required information

Parameters
appNamethe name of the application, can be left empty to use a name specified in jsonString
jsonStringfile or JSON string defining the federate information and other configuration

References masterFileName.

◆ App() [8/9]

helics::apps::App::App ( App &&  other_app)
default

move construction

◆ App() [9/9]

helics::apps::App::App ( const App other_app)
delete

don't allow the copy constructor

Member Function Documentation

◆ accessUnderlyingFederate()

const CombinationFederate& helics::apps::App::accessUnderlyingFederate ( ) const
inline

get a const reference to the federate

References fed.

◆ finalize()

void helics::apps::App::finalize ( )
virtual

finalize the Player federate

References fed.

◆ initialize()

void helics::apps::App::initialize ( )
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 in helics::apps::Source, and helics::apps::Player.

References fed, and helics::Federate::startup.

Referenced by helics::apps::Echo::runTo().

◆ isActive()

bool helics::apps::App::isActive ( ) const
inline

check if the Player is ready to run

◆ loadFile()

void helics::apps::App::loadFile ( const std::string &  filename)

load a file containing publication information

Parameters
filenamethe file containing the configuration and Player data accepted format are JSON, xml, and a Player format which is tab delimited or comma delimited

References loadJsonFile(), and loadTextFile().

◆ loadJsonFile()

void helics::apps::App::loadJsonFile ( const std::string &  jsonString)
protectedvirtual

load from a jsonString

Parameters
jsonStringeither a JSON filename or a string containing JSON

References loadJsonFileConfiguration().

Referenced by helics::apps::Clone::Clone(), and loadFile().

◆ loadJsonFileConfiguration()

void helics::apps::App::loadJsonFileConfiguration ( const std::string &  appName,
const std::string &  jsonString 
)
protected

load from a jsonString and check a field named appName for configuration options

Parameters
appNamethe name of the app which may be used in section of the JSON for some local configuration
jsonStringeither a JSON filename or a string containing JSON

References fed, and loadJson().

Referenced by loadJsonFile().

◆ loadTextFile()

void helics::apps::App::loadTextFile ( const std::string &  textFile)
protectedvirtual

load a text file

Referenced by loadFile().

◆ operator=() [1/2]

App& helics::apps::App::operator= ( App &&  app)
default

move assignment

Referenced by helics::apps::Echo::operator=().

◆ operator=() [2/2]

App& helics::apps::App::operator= ( const App app)
delete

don't allow the copy assignment, the default would fail anyway since federates are not copyable either

◆ runTo()

virtual void helics::apps::App::runTo ( Time  stopTime_input)
pure virtual

run the Player until the specified time

Parameters
stopTime_inputthe desired stop time

Implemented in helics::apps::Source, helics::apps::Player, helics::apps::Echo, helics::apps::Clone, helics::apps::Recorder, and helics::apps::Tracer.


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