helics  3.0.1
Classes | Functions
helics::BrokerFactory Namespace Reference

Classes

class  BrokerBuilder
 
class  BrokerTypeBuilder
 

Functions

void defineBrokerBuilder (std::shared_ptr< BrokerBuilder > cb, const std::string &name, int code)
 
std::shared_ptr< BrokermakeBroker (CoreType type, const std::string &name)
 
std::shared_ptr< Brokercreate (CoreType type, const std::string &configureString)
 
std::shared_ptr< Brokercreate (CoreType type, const std::string &brokerName, const std::string &configureString)
 
std::shared_ptr< Brokercreate (CoreType type, int argc, char *argv[])
 
std::shared_ptr< Brokercreate (CoreType type, const std::string &brokerName, int argc, char *argv[])
 
std::shared_ptr< Brokercreate (CoreType type, std::vector< std::string > args)
 
std::shared_ptr< Brokercreate (CoreType type, const std::string &brokerName, std::vector< std::string > args)
 
std::shared_ptr< BrokerfindBroker (const std::string &brokerName)
 
std::shared_ptr< BrokergetConnectedBroker ()
 
std::shared_ptr< BrokergetBrokerByIndex (size_t index)
 
std::shared_ptr< BrokerfindJoinableBrokerOfType (CoreType type)
 
std::vector< std::shared_ptr< Broker > > getAllBrokers ()
 
bool brokersActive ()
 
bool registerBroker (const std::shared_ptr< Broker > &broker, CoreType type)
 
size_t cleanUpBrokers ()
 
size_t cleanUpBrokers (std::chrono::milliseconds delay)
 
void terminateAllBrokers ()
 
void abortAllBrokers (int errorCode, const std::string &errorString)
 
bool copyBrokerIdentifier (const std::string &copyFromName, const std::string &copyToName)
 
void unregisterBroker (const std::string &name)
 
void addAssociatedBrokerType (const std::string &name, CoreType type)
 
void displayHelp (CoreType type)
 
template<class BrokerTYPE >
std::shared_ptr< BrokerBuilderaddBrokerType (const std::string &brokerTypeName, int code)
 

Detailed Description

Factory for building Core API instances.

Function Documentation

◆ abortAllBrokers()

void helics::BrokerFactory::abortAllBrokers ( int  errorCode,
const std::string &  errorString 
)

abort all brokers

References cleanUpBrokers(), and getAllBrokers().

◆ addAssociatedBrokerType()

void helics::BrokerFactory::addAssociatedBrokerType ( const std::string &  name,
CoreType  type 
)

add a type associated with a broker

◆ addBrokerType()

template<class BrokerTYPE >
std::shared_ptr<BrokerBuilder> helics::BrokerFactory::addBrokerType ( const std::string &  brokerTypeName,
int  code 
)

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

References defineBrokerBuilder().

◆ brokersActive()

bool helics::BrokerFactory::brokersActive ( )

check if there are any active Brokers

Referenced by helics::apps::BrokerServer::hasActiveBrokers().

◆ cleanUpBrokers() [1/2]

size_t helics::BrokerFactory::cleanUpBrokers ( )

clean up unused brokers

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

Returns
the number of brokers still operating

Referenced by abortAllBrokers(), helics::cleanupHelicsLibrary(), helicsBrokerFree(), helicsCloseLibrary(), registerBroker(), and terminateAllBrokers().

◆ cleanUpBrokers() [2/2]

size_t helics::BrokerFactory::cleanUpBrokers ( std::chrono::milliseconds  delay)

clean up unused brokers

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

Parameters
delaythe number of milliseconds to wait to ensure stuff is cleaned up
Returns
the number of brokers still operating

◆ copyBrokerIdentifier()

bool helics::BrokerFactory::copyBrokerIdentifier ( const std::string &  copyFromName,
const std::string &  copyToName 
)

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

Returns
true if successful

◆ create() [1/4]

std::shared_ptr< Broker > helics::BrokerFactory::create ( CoreType  type,
const std::string &  brokerName,
std::vector< std::string >  args 
)

Create a broker from command line arguments in a vector

References registerBroker().

◆ create() [2/4]

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

Creates a Broker object of the specified type.

Invokes initialize() on the instantiated Core object.

Referenced by create(), helicsCreateBroker(), and helicsCreateBrokerFromArgs().

◆ create() [3/4]

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

Create a broker from command line arguments

References create().

◆ create() [4/4]

std::shared_ptr< Broker > helics::BrokerFactory::create ( CoreType  type,
std::vector< std::string >  args 
)

Create a broker from command line arguments in a vector

References create().

◆ defineBrokerBuilder()

void helics::BrokerFactory::defineBrokerBuilder ( std::shared_ptr< BrokerBuilder cb,
const std::string &  name,
int  code 
)

define a new Broker Builder from the builder give a name and build code

Referenced by addBrokerType().

◆ displayHelp()

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

display the help listing for a particular CoreType

References helics::DEFAULT, helics::TCP_SS, and helics::UNRECOGNIZED.

◆ findBroker()

std::shared_ptr< Broker > helics::BrokerFactory::findBroker ( const std::string &  brokerName)

locate a coreBroker by name

Parameters
brokerNamethe name of the broker
Returns
a shared_ptr to the Broker

References getBrokerByIndex(), and getConnectedBroker().

Referenced by helics::BrokerApp::BrokerApp(), helics::NetworkBrokerData::commandLineParser(), and helics::CoreBroker::unregister().

◆ findJoinableBrokerOfType()

std::shared_ptr< Broker > helics::BrokerFactory::findJoinableBrokerOfType ( CoreType  type)

try to find a joinable broker of a specific type

◆ getAllBrokers()

std::vector< std::shared_ptr< Broker > > helics::BrokerFactory::getAllBrokers ( )

◆ getBrokerByIndex()

std::shared_ptr< Broker > helics::BrokerFactory::getBrokerByIndex ( size_t  index)

get a broker by index (0 based)

Parameters
indexthe index counter value of the broker
Returns
a shared_ptr to the Broker

Referenced by findBroker().

◆ getConnectedBroker()

std::shared_ptr< Broker > helics::BrokerFactory::getConnectedBroker ( )

get the first available Connected broker

Returns
a shared_ptr to the Broker

Referenced by findBroker().

◆ registerBroker()

bool helics::BrokerFactory::registerBroker ( const std::shared_ptr< Broker > &  broker,
CoreType  type 
)

register a coreBroker so it can be found by others

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

Parameters
brokera pointer to a Broker object that should be able to be found globally
typethe core type associated with a broker
Returns
true if the registration was successful false otherwise

References cleanUpBrokers().

Referenced by create().

◆ terminateAllBrokers()

void helics::BrokerFactory::terminateAllBrokers ( )

terminate all running Brokers

References cleanUpBrokers(), and getAllBrokers().

◆ unregisterBroker()

void helics::BrokerFactory::unregisterBroker ( const std::string &  name)

remove a broker from the registry

Parameters
namethe name of the broker to unregister

Referenced by helics::CoreBroker::unregister().