helics  3.0.1
Classes | Functions
helics::CoreFactory Namespace Reference

Classes

class  CoreBuilder
 
class  CoreTypeBuilder
 

Functions

void defineCoreBuilder (std::shared_ptr< CoreBuilder > cb, const std::string &name, int code)
 
std::shared_ptr< CoremakeCore (CoreType type, const std::string &name)
 
std::shared_ptr< CoregetEmptyCore ()
 
std::shared_ptr< Corecreate (const std::string &initializationString)
 
std::shared_ptr< Corecreate (CoreType type, const std::string &configureString)
 
std::shared_ptr< Corecreate (CoreType type, const std::string &coreName, const std::string &configureString)
 
std::shared_ptr< Corecreate (std::vector< std::string > args)
 
std::shared_ptr< Corecreate (CoreType type, std::vector< std::string > args)
 
std::shared_ptr< Corecreate (CoreType type, const std::string &coreName, std::vector< std::string > args)
 
std::shared_ptr< Corecreate (int argc, char *argv[])
 
std::shared_ptr< Corecreate (CoreType type, int argc, char *argv[])
 
std::shared_ptr< Corecreate (CoreType type, const std::string &coreName, int argc, char *argv[])
 
std::shared_ptr< CoreFindOrCreate (CoreType type, const std::string &coreName, std::vector< std::string > args)
 
std::shared_ptr< CoreFindOrCreate (CoreType type, const std::string &coreName, const std::string &configureString)
 
std::shared_ptr< CoreFindOrCreate (CoreType type, const std::string &coreName, int argc, char *argv[])
 
std::shared_ptr< CorefindCore (const std::string &name)
 
std::shared_ptr< CorefindJoinableCoreOfType (CoreType type)
 
bool registerCore (const std::shared_ptr< Core > &core, CoreType type)
 
size_t cleanUpCores ()
 
size_t cleanUpCores (std::chrono::milliseconds delay)
 
void terminateAllCores ()
 
void abortAllCores (int errorCode, const std::string &errorString)
 
size_t getCoreCount ()
 
bool copyCoreIdentifier (const std::string &copyFromName, const std::string &copyToName)
 
void unregisterCore (const std::string &name)
 
void addAssociatedCoreType (const std::string &name, CoreType type)
 
void displayHelp (CoreType type)
 
template<class CoreTYPE >
std::shared_ptr< CoreBuilderaddCoreType (const std::string &coreTypeName, int code)
 

Detailed Description

Factory for building Core API instances. available core types

Function Documentation

◆ abortAllCores()

void helics::CoreFactory::abortAllCores ( int  errorCode,
const std::string &  errorString 
)

abort all cores

References abortAllCores(), cleanUpCores(), and helics::gLocalCoreId().

Referenced by abortAllCores().

◆ addAssociatedCoreType()

void helics::CoreFactory::addAssociatedCoreType ( const std::string &  name,
CoreType  type 
)

add a type associated with a core

References addAssociatedCoreType().

Referenced by addAssociatedCoreType().

◆ addCoreType()

template<class CoreTYPE >
std::shared_ptr<CoreBuilder> helics::CoreFactory::addCoreType ( const std::string &  coreTypeName,
int  code 
)

template function to create a builder and link it into the library

◆ cleanUpCores() [1/2]

size_t helics::CoreFactory::cleanUpCores ( )

clean up unused cores

when Cores are unregistered they get put in a holding area that gets cleaned up when a new Core is registered or when the clean up function is called this prevents some odd threading issues

Returns
the number of cores still operating

References cleanUpCores().

Referenced by abortAllCores(), cleanUpCores(), helics::cleanupHelicsLibrary(), helics::Federate::Federate(), helicsCloseLibrary(), helicsCoreFree(), helicsFederateFree(), registerCore(), and terminateAllCores().

◆ cleanUpCores() [2/2]

size_t helics::CoreFactory::cleanUpCores ( std::chrono::milliseconds  delay)

clean up unused cores

when Cores are unregistered they get put in a holding area that gets cleaned up when a new Core is registered or when the clean up function is called this prevents some odd threading issues

Parameters
delaythe delay time in milliseconds to wait for the cores to finish before destroying
Returns
the number of cores still operating

References cleanUpCores().

◆ copyCoreIdentifier()

bool helics::CoreFactory::copyCoreIdentifier ( const std::string &  copyFromName,
const std::string &  copyToName 
)

make a copy of the core pointer to allow access to the new name

Returns
true if the copyFromName was found and the copy successful

References copyCoreIdentifier().

Referenced by copyCoreIdentifier().

◆ create() [1/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
const std::string &  configureString 
)

Creates a Core API object of the specified type.

Invokes initialize() on the instantiated Core object.

◆ create() [2/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
const std::string &  coreName,
const std::string &  configureString 
)

create a core from a type, name, and initializationString

Parameters
typethe type of core to create
coreNamethe name for the core
configureStringa string containing arguments for configuration of the core

References registerCore().

◆ create() [3/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
const std::string &  coreName,
int  argc,
char *  argv[] 
)

create a core from a type, name, and arguments

Parameters
typethe type of core to create
coreNamethe name for the core
argcthe number of arguments
argvthe actual argument parameters
Returns
a pointer to the created core

References registerCore().

◆ create() [4/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
const std::string &  coreName,
std::vector< std::string >  args 
)

create a core from a type, name, and arguments

Parameters
typethe type of core to create
coreNamethe name for the core
argsa vector of reversed command line arguments
Returns
a pointer to the created core

References registerCore().

◆ create() [5/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
int  argc,
char *  argv[] 
)

create a core from a type and command line arguments

Parameters
typethe type of core to create
argcthe number of command line arguments
argvthe actual string parameters for the command line

◆ create() [6/8]

std::shared_ptr< Core > helics::CoreFactory::create ( CoreType  type,
std::vector< std::string >  args 
)

create a core from a type and command line arguments

Parameters
typethe type of core to create
argsa vector of reversed command line arguments

◆ create() [7/8]

std::shared_ptr< Core > helics::CoreFactory::create ( int  argc,
char *  argv[] 
)

create a core from arguments

an argument of '–coretype' must be specified to define the type, otherwise the default type is used

Parameters
argcthe number of arguments
argvthe actual argument parameters
Returns
a pointer to the created core

◆ create() [8/8]

std::shared_ptr< Core > helics::CoreFactory::create ( std::vector< std::string >  args)

create a core from arguments

an argument of '–coretype' must be specified to define the type, otherwise the default type is used

Parameters
argsa vector of reversed command line arguments
Returns
a pointer to the created core

◆ displayHelp()

void helics::CoreFactory::displayHelp ( CoreType  type = CoreType::UNRECOGNIZED)

display the help listing for a particular CoreType

◆ findCore()

std::shared_ptr< Core > helics::CoreFactory::findCore ( const std::string &  name)

locate a registered Core by name

Parameters
namethe name of the core to find
Returns
a shared_ptr to the testCore

References findCore().

Referenced by helics::CoreApp::CoreApp(), findCore(), FindOrCreate(), and helics::CommonCore::unregister().

◆ findJoinableCoreOfType()

std::shared_ptr< Core > helics::CoreFactory::findJoinableCoreOfType ( CoreType  type)

try to find a joinable core of a specific type

References findJoinableCoreOfType().

Referenced by helics::Federate::Federate(), and findJoinableCoreOfType().

◆ FindOrCreate() [1/3]

std::shared_ptr< Core > helics::CoreFactory::FindOrCreate ( CoreType  type,
const std::string &  coreName,
const std::string &  configureString 
)

tries to find a named core if it fails it creates a new one

References findCore(), FindOrCreate(), and registerCore().

◆ FindOrCreate() [2/3]

std::shared_ptr< Core > helics::CoreFactory::FindOrCreate ( CoreType  type,
const std::string &  coreName,
int  argc,
char *  argv[] 
)

tries to find a named core if it fails it creates a new one

References findCore(), FindOrCreate(), and registerCore().

◆ FindOrCreate() [3/3]

std::shared_ptr< Core > helics::CoreFactory::FindOrCreate ( CoreType  type,
const std::string &  coreName,
std::vector< std::string >  args 
)

tries to find a named core if it fails it creates a new one

References findCore(), FindOrCreate(), and registerCore().

Referenced by helics::Federate::Federate(), FindOrCreate(), helicsCreateCore(), and helicsCreateCoreFromArgs().

◆ getCoreCount()

size_t helics::CoreFactory::getCoreCount ( )

get the current number of cores

References getCoreCount().

Referenced by getCoreCount().

◆ getEmptyCore()

std::shared_ptr< Core > helics::CoreFactory::getEmptyCore ( )

◆ registerCore()

bool helics::CoreFactory::registerCore ( const std::shared_ptr< Core > &  core,
CoreType  type 
)

register a testCore so it can be found by others

also cleans up any leftover Cores that were previously unregistered this can be controlled by calling cleanUpCores earlier if desired

Parameters
corea pointer to a testCore object that should be found globally
typethe type of core to create
Returns
true if the registration was successful false otherwise

References cleanUpCores(), and registerCore().

Referenced by create(), FindOrCreate(), and registerCore().

◆ terminateAllCores()

void helics::CoreFactory::terminateAllCores ( )

terminate All existing cores

References cleanUpCores(), and terminateAllCores().

Referenced by terminateAllCores().

◆ unregisterCore()

void helics::CoreFactory::unregisterCore ( const std::string &  name)

remove a Core from the registry

Parameters
namethe name of the Core to unregister

References unregisterCore().

Referenced by helics::CommonCore::unregister(), and unregisterCore().