| helics 3.6.1

Classes | Functions
helics::BrokerFactory Namespace Reference

## Classes
class | BrokerBuilder
class | BrokerTypeBuilder

## Functions
void | defineBrokerBuilder (std::shared_ptr< BrokerBuilder > builder, std::string_view name, int code)
std::shared_ptr< Broker > | makeBroker (CoreType type, std::string_view name)
std::shared_ptr< Broker > | create (CoreType type, std::string_view configureString)
std::shared_ptr< Broker > | create (CoreType type, std::string_view brokerName, std::string_view configureString)
std::shared_ptr< Broker > | create (CoreType type, int argc, char *argv[])
std::shared_ptr< Broker > | create (CoreType type, std::string_view brokerName, int argc, char *argv[])
std::shared_ptr< Broker > | create (CoreType type, std::vector< std::string > args)
std::shared_ptr< Broker > | create (CoreType type, std::string_view brokerName, std::vector< std::string > args)
std::shared_ptr< Broker > | findBroker (std::string_view brokerName)
std::shared_ptr< Broker > | getConnectedBroker ()
std::shared_ptr< Broker > | getBrokerByIndex (size_t index)
std::shared_ptr< Broker > | findJoinableBrokerOfType (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, std::string_view errorString)
bool | copyBrokerIdentifier (std::string_view copyFromName, std::string_view copyToName)
void | unregisterBroker (std::string_view name)
void | addAssociatedBrokerType (std::string_view name, CoreType type)
void | displayHelp (CoreType type)
template<class BrokerTYPE >
std::shared_ptr< BrokerBuilder > | addBrokerType (std::string_view brokerTypeName, int code)

## Detailed Description

Factory for building Core API instances.

## Function Documentation

## ◆ abortAllBrokers()

void helics::BrokerFactory::abortAllBrokers | ( | int | errorCode,
|  | std::string_view | errorString
| ) |  |

abort all brokers

References cleanUpBrokers(), and getAllBrokers().

## ◆ addAssociatedBrokerType()

void helics::BrokerFactory::addAssociatedBrokerType | ( | std::string_view | name,
|  | CoreType | type
| ) |  |

add a type associated with a broker

## ◆ addBrokerType()

template<class BrokerTYPE >

std::shared_ptr<BrokerBuilder> helics::BrokerFactory::addBrokerType | ( | std::string_view | 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

  delay | the number of milliseconds to wait to ensure stuff is cleaned up

Returns
  the number of brokers still operating

## ◆ copyBrokerIdentifier()

bool helics::BrokerFactory::copyBrokerIdentifier | ( | std::string_view | copyFromName,
|  | std::string_view | 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,
|  | int | argc,
|  | char * | argv[]
| ) |  |

Create a broker from command line arguments

References create().

## ◆ create() [2/4]

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

Create a broker from command line arguments in a vector

References helics::EXTRACT, and registerBroker().

## ◆ create() [3/4]

std::shared_ptr< Broker > helics::BrokerFactory::create | ( | CoreType | type,
|  | std::string_view | configureString
| ) |  |

Creates a Broker object of the specified type.

Invokes initialize() on the instantiated Core object.

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

## ◆ 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 > | builder,
|  | std::string_view | 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 | ( | std::string_view | brokerName | ) |

locate a coreBroker by name

Parameters

  brokerName | the 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 | ( |  | ) |

get all available brokers

Referenced by abortAllBrokers(), helics::apps::BrokerServer::forceTerminate(), and terminateAllBrokers().

## ◆ getBrokerByIndex()

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

get a broker by index (0 based)

Parameters

  index | the 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

  broker | a pointer to a Broker object that should be able to be found globally
  type | the 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 | ( | std::string_view | name | ) |

remove a broker from the registry

Parameters

  name | the name of the broker to unregister

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