A factory to create Simulator. More...
#include <SimulatorFactory.h>
Public Member Functions | |
Simulator * | createSimulator (std::string id, MonitoringManager *monitoringManager) |
Creates a Simulator based on its string id or return nullptr if there is no id in the map. More... | |
Simulator * | createSimulator (std::string id, MonitoringManager *monitoringManager, const char *file) |
Creates a Simulator using a specific simulator file based on its string id or return nullptr if there is no id in the map. More... | |
std::string | getInteractiveSimulator (const unsigned int index) |
get a interactive simulator name by its index More... | |
std::string | getNonInteractiveSimulator (const unsigned int index) |
get a non interactive simulator name by its index More... | |
int | getNumberOfInteractiveSimulators () |
give the number of interactive simulators registered More... | |
int | getNumberOfNonInteractiveSimulators () |
give the number of interactive simulators registered More... | |
bool | isInteractive (std::string id) |
return true if the registered simulator id is interactive More... | |
bool | isRegistered (std::string id) |
Returns true if id is in the map. More... | |
template<typename C > | |
bool | registerClass (std::string id, bool isInteractive) |
Register a class into the map A registered class can be created using createMonitorDisplay() More... | |
Static Public Member Functions | |
static SimulatorFactory * | getInstance () |
return the unique instance of the factory More... | |
Private Types | |
typedef Simulator *(* | CreateSimulatorFunctionPointer) (MonitoringManager *monitoringManager) |
typedef Simulator *(* | CreateSimulatorFunctionPointer2) (MonitoringManager *monitoringManager, const char *file) |
Private Member Functions | |
SimulatorFactory ()=default | |
Static Private Member Functions | |
template<typename C > | |
static Simulator * | createTheSimulator (MonitoringManager *monitoringManager) |
map the simulator name with the 1 parameter constructor. More... | |
template<typename C > | |
static Simulator * | createTheSimulator2 (MonitoringManager *monitoringManager, const char *file) |
map the simulator name with the 2 parameters constructor (using the given specific simulator file) More... | |
Private Attributes | |
std::vector< std::string > | interactiveSimulators |
list of interactive simulators More... | |
std::map< std::string, bool > | mapInteractive |
map between Simulator name as string to booleen, true if interactive More... | |
std::map< std::string, CreateSimulatorFunctionPointer > | mapObjectCreator |
A map between Simulator name as string to functions. More... | |
std::map< std::string, CreateSimulatorFunctionPointer2 > | mapObjectCreator2 |
A map between Simulator name as string to functions (for the 2nd constructor that uses a simulator file) More... | |
std::vector< std::string > | nonInteractiveSimulators |
list of non interactive simulators More... | |
Static Private Attributes | |
static SimulatorFactory * | instance = nullptr |
unique instance of the factory More... | |
A factory to create Simulator.
|
private |
|
private |
|
privatedefault |
Simulator * SimulatorFactory::createSimulator | ( | std::string | id, |
MonitoringManager * | monitoringManager | ||
) |
Creates a Simulator based on its string id or return nullptr if there is no id in the map.
References mapObjectCreator.
Referenced by MonitoringManager::buildPmlAndSimulatorfromPml(), and MonitoringManager::buildPmlAndSimulatorfromSimulator().
Simulator * SimulatorFactory::createSimulator | ( | std::string | id, |
MonitoringManager * | monitoringManager, | ||
const char * | file | ||
) |
Creates a Simulator using a specific simulator file based on its string id or return nullptr if there is no id in the map.
References mapObjectCreator2.
|
inlinestaticprivate |
map the simulator name with the 1 parameter constructor.
function whose pointers are inserted into the map
C | type of Simulator |
|
inlinestaticprivate |
map the simulator name with the 2 parameters constructor (using the given specific simulator file)
function whose pointers are inserted into the map
C | type of Simulator |
file | specific simulator file |
|
static |
return the unique instance of the factory
References instance, and SimulatorFactory().
Referenced by MonitoringManager::buildPmlAndSimulatorfromPml(), MonitoringManager::buildPmlAndSimulatorfromSimulator(), and MonitoringManagerFactory::createManager().
std::string SimulatorFactory::getInteractiveSimulator | ( | const unsigned int | index | ) |
get a interactive simulator name by its index
References interactiveSimulators.
std::string SimulatorFactory::getNonInteractiveSimulator | ( | const unsigned int | index | ) |
get a non interactive simulator name by its index
References nonInteractiveSimulators.
int SimulatorFactory::getNumberOfInteractiveSimulators | ( | ) |
give the number of interactive simulators registered
References interactiveSimulators.
int SimulatorFactory::getNumberOfNonInteractiveSimulators | ( | ) |
give the number of interactive simulators registered
References nonInteractiveSimulators.
bool SimulatorFactory::isInteractive | ( | std::string | id | ) |
return true if the registered simulator id is interactive
References mapInteractive.
Referenced by MonitoringManagerFactory::createManager().
bool SimulatorFactory::isRegistered | ( | std::string | id | ) |
Returns true if id is in the map.
References mapObjectCreator.
Referenced by MonitoringManagerFactory::createManager().
|
inline |
Register a class into the map A registered class can be created using createMonitorDisplay()
C | a subclass of Simulator |
id | unique id to associate with the Class C |
|
staticprivate |
unique instance of the factory
Referenced by getInstance().
|
private |
list of interactive simulators
Referenced by getInteractiveSimulator(), and getNumberOfInteractiveSimulators().
|
private |
map between Simulator name as string to booleen, true if interactive
Referenced by isInteractive().
|
private |
A map between Simulator name as string to functions.
Referenced by createSimulator(), and isRegistered().
|
private |
A map between Simulator name as string to functions (for the 2nd constructor that uses a simulator file)
Referenced by createSimulator().
|
private |
list of non interactive simulators
Referenced by getNonInteractiveSimulator(), and getNumberOfNonInteractiveSimulators().