12 #ifndef _SST_CORE_FACTORY_H
13 #define _SST_CORE_FACTORY_H
15 #include <sst/core/sst_types.h>
20 #include <sst/core/params.h>
21 #include <sst/core/eli/elementinfo.h>
24 extern int main(
int argc,
char **argv);
27 namespace Statistics {
28 class StatisticOutput;
37 class SSTElementPythonModule;
46 static Factory* getFactory() {
return instance; }
52 bool isPortNameValid(
const std::string &type,
const std::string port_name);
96 bool doesSubComponentExist(std::string type);
109 template <
class Base>
111 std::string elemlib, elem;
112 std::tie(elemlib, elem) = parseLoadName(type);
114 requireLibrary(elemlib);
115 std::lock_guard<std::recursive_mutex> lock(factoryMutex);
117 auto* lib = ELI::InfoDatabase::getLibrary<Base>(elemlib);
119 auto map = lib->getMap();
120 auto* info = lib->getInfo(elem);
122 auto* builderLib = Base::getBuilderLibrary(elemlib);
124 auto* fact = builderLib->getBuilder(elem);
140 template <
class Base,
class... CtorArgs>
142 std::string elemlib, elem;
143 std::tie(elemlib, elem) = parseLoadName(type);
145 requireLibrary(elemlib);
146 std::lock_guard<std::recursive_mutex> lock(factoryMutex);
148 auto* lib = ELI::InfoDatabase::getLibrary<Base>(elemlib);
150 auto map = lib->getMap();
151 auto* info = lib->getInfo(elem);
153 auto* builderLib = Base::getBuilderLibrary(elemlib);
155 auto* fact = builderLib->getBuilder(elem);
158 Base* ret = fact->create(std::forward<CtorArgs>(args)...);
165 notFound(Base::ELI_baseName(), type);
177 template <
class T,
class... Args>
180 const std::string& stat,
Params& params,
182 std::string elemlib, elem;
183 std::tie(elemlib, elem) = parseLoadName(type);
185 requireLibrary(elemlib);
187 auto* lib = ELI::BuilderDatabase::getLibrary<Statistics::Statistic<T>, Args...>(elemlib);
189 auto* fact = lib->getFactory(elem);
191 return fact->create(comp, statName, stat, params, std::forward<Args>(args)...);
195 out.
fatal(CALL_INFO, -1,
"can't find requested statistic %s.\n ", type.c_str());
206 void requireLibrary(std::string &elemlib);
208 void getLoadedLibraryNames(std::set<std::string>& lib_names);
209 void loadUnloadedLibraries(
const std::set<std::string>& lib_names);
247 friend int ::main(
int argc,
char **argv);
249 void notFound(
const std::string& baseName,
const std::string& type);
252 Factory(std::string searchPaths);
257 void operator=(
Factory const&);
262 bool findLibrary(std::string name,
bool showErrors=
true);
264 bool loadLibrary(std::string name,
bool showErrors=
true);
266 std::set<std::string> loaded_libraries;
268 std::string searchPaths;
271 std::string loadingComponentType;
273 std::pair<std::string, std::string> parseLoadName(
const std::string& wholename);
275 std::recursive_mutex factoryMutex;
285 #endif // SST_CORE_FACTORY_H
Output object provides consistent method for outputting data to stdout, stderr and/or sst debug file...
Definition: output.h:54
Component * CreateComponent(ComponentId_t id, std::string &componentname, Params ¶ms)
Attempt to create a new Component instantiation.
Definition: factory.cc:201
void RequireEvent(std::string eventname)
Ensure that an element library containing the required event is loaded.
Definition: factory.cc:546
bool isPortNameValid(const std::string &type, const std::string port_name)
Get a list of allowed ports for a given component type.
Definition: factory.cc:101
void pushAllowedKeys(const KeySet_t &keys)
Definition: params.cc:179
Main component object for the simulation.
Definition: component.h:32
bool hasLibrary(std::string elemlib)
Checks to see if library exists and can be loaded.
Definition: factory.cc:616
bool DoesComponentInfoStatisticNameExist(const std::string &type, const std::string &statisticName)
Determine if a statistic is defined in a components ElementInfoStatistic.
Definition: factory.cc:282
bool isSubComponentLoadableUsingAPI(std::string type)
Check to see if a given element type is loadable with a particular API.
Definition: factory.h:110
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:43
std::string GetComponentInfoStatisticUnits(const std::string &type, const std::string &statisticName)
Get the units of a statistic defined in the component's ElementInfoStatistic.
Definition: factory.cc:381
Statistics::Statistic< T > * CreateStatistic(std::string type, BaseComponent *comp, const std::string &statName, const std::string &stat, Params ¶ms, Args...args)
Instantiate a new Statistic.
Definition: factory.h:178
Module is a tag class used with the loadModule function.
Definition: module.h:22
Module * CreateModuleWithComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:454
Class to load Element Libraries.
Definition: elemLoader.h:25
uint8_t GetComponentInfoStatisticEnableLevel(const std::string &type, const std::string &statisticName)
Determine if a statistic is defined in a subcomponents ElementInfoStatistic.
Definition: factory.cc:332
void fatal(uint32_t line, const char *file, const char *func, int exit_code, const char *format,...) const
Output the fatal message with formatting as specified by the format parameter.
Definition: output.cc:155
Partition::SSTPartitioner * CreatePartitioner(std::string name, RankInfo total_ranks, RankInfo my_rank, int verbosity)
Return partitioner function.
Definition: factory.cc:557
Definition: rankInfo.h:21
Main component object for the simulation.
Definition: baseComponent.h:52
const Params::KeySet_t & getParamNames(const std::string &type)
Get a list of allowed param keys for a given component type.
Definition: factory.cc:158
Base * Create(const std::string &type, SST::Params ¶ms, CtorArgs &&...args)
General function for a given base class.
Definition: factory.h:141
Base class for Partitioning graphs.
Definition: sstpart.h:32
Parameter store.
Definition: params.h:45
void popAllowedKeys()
Removes the most recent set of keys considered allowed.
Definition: params.cc:185
SSTElementPythonModule * getPythonModule(std::string name)
Return Python Module creation function.
Definition: factory.cc:589
Class for instantiating Components, Links and the like out of element libraries.
Definition: factory.h:43
Base class for python modules in element libraries.
Definition: element_python.h:126
std::set< key_type, KeyCompare > KeySet_t
Definition: params.h:172
SubComponent * CreateSubComponent(std::string type, Component *comp, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:489
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition: subcomponent.h:30
bool DoesSubComponentSlotExist(const std::string &type, const std::string &slotName)
Determine if a SubComponentSlot is defined in a components ElementInfoStatistic.
Definition: factory.cc:241
Module * CreateModule(std::string type, Params ¶ms)
Instantiate a new Module.
Definition: factory.cc:416