12 #ifndef SST_CORE_ELEMENTINFO_H
13 #define SST_CORE_ELEMENTINFO_H
15 #include "sst/core/sst_types.h"
16 #include "sst/core/warnmacros.h"
17 #include "sst/core/params.h"
19 #include "sst/core/eli/paramsInfo.h"
20 #include "sst/core/eli/statsInfo.h"
21 #include "sst/core/eli/defaultInfo.h"
22 #include "sst/core/eli/portsInfo.h"
23 #include "sst/core/eli/subcompSlotInfo.h"
24 #include "sst/core/eli/interfaceInfo.h"
25 #include "sst/core/eli/categoryInfo.h"
26 #include "sst/core/eli/elementbuilder.h"
31 #include "sst/core/eli/elibase.h"
41 namespace Statistics {
57 static T*
get(
const std::string& elemlib,
const std::string& elem){
58 if (!infos_)
return nullptr;
60 auto libiter = infos_->find(elemlib);
61 if (libiter != infos_->end()){
62 auto& submap = libiter->second;
63 auto elemiter = submap.find(elem);
64 if (elemiter != submap.end()){
65 return elemiter->second;
71 static void add(
const std::string& elemlib,
const std::string& elem, T* info){
73 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
74 new std::map<std::string, std::map<std::string, T*>>);
77 (*infos_)[elemlib][elem] = info;
81 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
83 template <
class T> std::unique_ptr<std::map<std::string,std::map<std::string,T*>>>
DataBase<T>::infos_;
86 template <
class Policy,
class... Policies>
92 const std::string& elem,
94 : Policy(args...),
Parent(elemlib, elem, args...)
99 template <
class XMLNode>
void outputXML(XMLNode* node){
100 Policy::outputXML(node);
101 Parent::outputXML(node);
104 void toString(std::ostream& os)
const {
105 Parent::toString(os);
106 Policy::toString(os);
116 template <
class XMLNode>
void outputXML(XMLNode* UNUSED(node)){}
118 void toString(std::ostream& UNUSED(os))
const {}
122 template <
class Base,
class T>
124 static bool isLoaded() {
128 static const bool loaded;
134 using BaseInfo =
typename Base::BuilderInfo;
141 BaseInfo* getInfo(
const std::string& name) {
142 auto iter = infos_.find(name);
143 if (iter == infos_.end()){
150 bool hasInfo(
const std::string& name)
const {
151 return infos_.find(name) != infos_.end();
154 int numEntries()
const {
155 return infos_.size();
158 const std::map<std::string, BaseInfo*>& getMap()
const {
162 void readdInfo(
const std::string& name, BaseInfo* info){
166 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>
185 using BaseInfo=
typename Library::BaseInfo;
186 using Map=std::map<std::string,Library*>;
188 static Library* getLibrary(
const std::string& name){
192 auto iter = libraries->find(name);
193 if (iter == libraries->end()){
194 auto* info =
new Library(name);
195 (*libraries)[name] = info;
204 static Map* libraries;
207 template <
class Base>
typename InfoLibraryDatabase<Base>::Map*
210 template <
class Base,
class Info>
213 const std::string& elem,
215 elemlib_(elemlib), elem_(elem), info_(info)
219 void load()
override {
221 if (!lib->hasInfo(elem_)){
222 lib->readdInfo(elem_, info_);
226 std::string elemlib_;
245 template <
class T>
static bool add(){
246 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
268 const unsigned major;
269 const unsigned minor;
270 const unsigned tertiary;
272 constexpr
unsigned getMajor()
const {
return major; }
273 constexpr
unsigned getMinor()
const {
return minor; }
274 constexpr
unsigned getTertiary()
const {
return tertiary; }
278 return ver.getMajor();
281 constexpr
unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
282 return ver.getMinor();
285 constexpr
unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
286 return ver.getTertiary();
294 #define SST_ELI_DECLARE_INFO(...) \
295 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__,SST::ELI::ProvidesDefaultInfo,void>; \
296 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
297 BuilderImpl* info){ \
298 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
300 SST_ELI_DECLARE_INFO_COMMON()
303 #define SST_ELI_DECLARE_DEFAULT_INFO() \
304 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
305 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
306 BuilderImpl* info){ \
307 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
309 SST_ELI_DECLARE_INFO_COMMON()
312 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
313 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,__VA_ARGS__,void>; \
314 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
315 SST_ELI_DECLARE_INFO_COMMON()
317 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
318 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
319 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
320 SST_ELI_DECLARE_INFO_COMMON()
322 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
323 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info){ \
324 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
327 #define SST_ELI_EXTERN_DERIVED(base,cls,lib,name,version,desc) \
328 bool ELI_isLoaded(); \
329 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
331 #define SST_ELI_REGISTER_DERIVED(base,cls,lib,name,version,desc) \
332 bool ELI_isLoaded() { \
333 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
334 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
336 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
338 #define SST_ELI_REGISTER_EXTERN(base,cls) \
339 bool cls::ELI_isLoaded(){ \
340 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
341 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
347 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:211
Forms the base class for statistics gathering within SST.
Definition: statbase.h:64
Definition: elementinfo.h:123
Definition: elementinfo.h:253
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:42
Definition: elementinfo.h:182
Definition: elementinfo.h:239
Definition: elementinfo.h:87
Definition: elibase.h:107
Definition: elementinfo.h:131
Definition: rankInfo.h:21
Definition: elementinfo.h:55
Base class for python modules in element libraries.
Definition: element_python.h:133
static bool addLoader(const std::string &lib, const std::string &name, LibraryLoader *loader)
Definition: elibase.cc:29