12 #ifndef SST_CORE_ELI_ELEMENTINFO_H
13 #define SST_CORE_ELI_ELEMENTINFO_H
15 #include "sst/core/eli/attributeInfo.h"
16 #include "sst/core/eli/categoryInfo.h"
17 #include "sst/core/eli/defaultInfo.h"
18 #include "sst/core/eli/elementbuilder.h"
19 #include "sst/core/eli/elibase.h"
20 #include "sst/core/eli/interfaceInfo.h"
21 #include "sst/core/eli/paramsInfo.h"
22 #include "sst/core/eli/portsInfo.h"
23 #include "sst/core/eli/profilePointInfo.h"
24 #include "sst/core/eli/simpleInfo.h"
25 #include "sst/core/eli/statsInfo.h"
26 #include "sst/core/eli/subcompSlotInfo.h"
27 #include "sst/core/params.h"
28 #include "sst/core/sst_types.h"
29 #include "sst/core/warnmacros.h"
42 namespace Statistics {
48 class SSTElementPythonModule;
60 static T* get(
const std::string& elemlib,
const std::string& elem)
62 if ( !infos_ )
return nullptr;
64 auto libiter = infos_->find(elemlib);
65 if ( libiter != infos_->end() ) {
66 auto& submap = libiter->second;
67 auto elemiter = submap.find(elem);
68 if ( elemiter != submap.end() ) {
return elemiter->second; }
73 static void add(
const std::string& elemlib,
const std::string& elem, T* info)
76 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
77 new std::map<std::string, std::map<std::string, T*>>);
80 (*infos_)[elemlib][elem] = info;
84 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
89 template <
class Policy,
class... Policies>
95 template <
class... Args>
96 BuilderInfoImpl(
const std::string& elemlib,
const std::string& elem, Args&&... args) :
98 Parent(elemlib, elem, args...)
103 template <
class XMLNode>
104 void outputXML(XMLNode* node)
106 Policy::outputXML(node);
107 Parent::outputXML(node);
110 void toString(std::ostream& os)
const
112 Policy::toString(os);
113 Parent::toString(os);
121 template <
class... Args>
125 template <
class XMLNode>
126 void outputXML(XMLNode* UNUSED(node))
129 void toString(std::ostream& UNUSED(os))
const {}
132 template <
class Base,
class T>
135 static bool isLoaded() {
return loaded; }
137 static const bool loaded;
140 template <
class Base>
144 using BaseInfo =
typename Base::BuilderInfo;
146 InfoLibrary(
const std::string& name) : name_(name) {}
148 BaseInfo* getInfo(
const std::string& name)
150 auto iter = infos_.find(name);
151 if ( iter == infos_.end() ) {
return nullptr; }
157 bool hasInfo(
const std::string& name)
const {
return infos_.find(name) != infos_.end(); }
159 int numEntries()
const {
return infos_.size(); }
161 const std::map<std::string, BaseInfo*>& getMap()
const {
return infos_; }
163 void readdInfo(
const std::string& name, BaseInfo* info) { infos_[name] = info; }
165 bool addInfo(
const std::string& elem, BaseInfo* info)
167 readdInfo(elem, info);
169 addLoader(name_, elem, info);
174 void addLoader(
const std::string& lib,
const std::string& name, BaseInfo* info);
176 std::map<std::string, BaseInfo*> infos_;
181 template <
class Base>
186 using BaseInfo =
typename Library::BaseInfo;
187 using Map = std::map<std::string, Library*>;
189 static std::vector<std::string> getRegisteredElementNames()
194 std::vector<std::string> ret;
196 for (
auto x : (*libraries) ) {
197 for (
auto& y : x.second->getMap() ) {
198 ret.push_back(x.first +
"." + y.first);
204 static Library* getLibrary(
const std::string& name)
206 if ( !libraries ) { libraries =
new Map; }
207 auto iter = libraries->find(name);
208 if ( iter == libraries->end() ) {
209 auto* info =
new Library(name);
210 (*libraries)[name] = info;
220 static Map* libraries;
223 template <
class Base>
226 template <
class Base,
class Info>
229 InfoLoader(
const std::string& elemlib,
const std::string& elem, Info* info) :
238 if ( !lib->hasInfo(elem_) ) { lib->readdInfo(elem_, info_); }
242 std::string elemlib_;
247 template <
class Base>
255 template <
class Base>
266 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
269 template <
class Base,
class T>
281 static std::vector<std::string> getRegisteredElementNames()
287 void force_instantiate_bool(
bool b,
const char* name);
292 static bool ELI_isLoaded() {
return T::ELI_isLoaded(); }
303 const unsigned major;
304 const unsigned minor;
305 const unsigned tertiary;
307 constexpr
unsigned getMajor()
const {
return major; }
308 constexpr
unsigned getMinor()
const {
return minor; }
309 constexpr
unsigned getTertiary()
const {
return tertiary; }
315 return ver.getMajor();
319 SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver)
321 return ver.getMinor();
325 SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver)
327 return ver.getTertiary();
334 #define SST_ELI_DECLARE_INFO(...) \
335 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__, SST::ELI::ProvidesDefaultInfo, void>; \
336 template <class BuilderImpl> \
337 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \
339 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
341 SST_ELI_DECLARE_INFO_COMMON()
343 #define SST_ELI_DECLARE_DEFAULT_INFO() \
344 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \
345 template <class BuilderImpl> \
346 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderImpl* info) \
348 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
350 SST_ELI_DECLARE_INFO_COMMON()
352 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
353 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, __VA_ARGS__, void>; \
354 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
355 SST_ELI_DECLARE_INFO_COMMON()
357 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
358 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo, void>; \
359 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
360 SST_ELI_DECLARE_INFO_COMMON()
362 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
363 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info) \
365 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem, info); \
368 #define SST_ELI_EXTERN_DERIVED(base, cls, lib, name, version, desc) \
369 bool ELI_isLoaded(); \
370 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc)
377 #ifdef __INTEL_COMPILER
378 #define SST_ELI_FORCE_INSTANTIATION(base, cls) \
380 struct ELI_ForceRegister \
382 ELI_ForceRegister() \
384 bool b = SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
385 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
386 SST::ELI::force_instantiate_bool(b, #cls); \
389 ELI_ForceRegister<cls> force_instantiate;
394 #define SST_ELI_EXPORT(cls) template class SST::ELI::ForceExport<cls>;
396 #define SST_ELI_FORCE_INSTANTIATION(base, cls)
397 #define SST_ELI_EXPORT(cls)
408 #define SST_ELI_REGISTER_DERIVED(base, cls, lib, name, version, desc) \
409 static constexpr int __EliDerivedLevel = std::is_same<base, cls>::value ? __EliBaseLevel : __EliBaseLevel + 1; \
410 static bool ELI_isLoaded() \
412 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
413 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
415 SST_ELI_FORCE_INSTANTIATION(base, cls) \
416 SST_ELI_DEFAULT_INFO(lib, name, ELI_FORWARD_AS_ONE(version), desc)
418 #define SST_ELI_REGISTER_EXTERN(base, cls) \
419 bool cls::ELI_isLoaded() \
421 return SST::ELI::InstantiateBuilder<base, cls>::isLoaded() && \
422 SST::ELI::InstantiateBuilderInfo<base, cls>::isLoaded(); \
Definition: elementinfo.h:91
Definition: elementinfo.h:58
Definition: elementinfo.h:183
Definition: elementinfo.h:142
static bool addLoader(const std::string &lib, const std::string &name, LibraryLoader *loader)
Definition: elibase.cc:28
Definition: elementinfo.h:257
Definition: elementinfo.h:291
Definition: elementinfo.h:273
Definition: elementinfo.h:228
Definition: elementinfo.h:134
Definition: elibase.h:135