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>
18 #include <sst/core/statapi/statfieldinfo.h>
20 #include <sst/core/eli/paramsInfo.h>
21 #include <sst/core/eli/statsInfo.h>
22 #include <sst/core/eli/defaultInfo.h>
23 #include <sst/core/eli/portsInfo.h>
24 #include <sst/core/eli/subcompSlotInfo.h>
25 #include <sst/core/eli/interfaceInfo.h>
26 #include <sst/core/eli/categoryInfo.h>
27 #include <sst/core/eli/elementbuilder.h>
32 #include <sst/core/eli/elibase.h>
42 namespace Statistics {
58 static T*
get(
const std::string& elemlib,
const std::string& elem){
59 if (!infos_)
return nullptr;
61 auto libiter = infos_->find(elemlib);
62 if (libiter != infos_->end()){
63 auto& submap = libiter->second;
64 auto elemiter = submap.find(elem);
65 if (elemiter != submap.end()){
66 return elemiter->second;
72 static void add(
const std::string& elemlib,
const std::string& elem, T* info){
74 infos_ = std::unique_ptr<std::map<std::string, std::map<std::string, T*>>>(
75 new std::map<std::string, std::map<std::string, T*>>);
78 (*infos_)[elemlib][elem] = info;
82 static std::unique_ptr<std::map<std::string, std::map<std::string, T*>>> infos_;
84 template <
class T> std::unique_ptr<std::map<std::string,std::map<std::string,T*>>>
DataBase<T>::infos_;
87 template <
class Policy,
class... Policies>
93 const std::string& elem,
95 : Policy(args...),
Parent(elemlib, elem, args...)
100 template <
class XMLNode>
void outputXML(XMLNode* node){
101 Policy::outputXML(node);
102 Parent::outputXML(node);
105 void toString(std::ostream& os)
const {
106 Parent::toString(os);
107 Policy::toString(os);
117 template <
class XMLNode>
void outputXML(XMLNode* UNUSED(node)){}
119 void toString(std::ostream& UNUSED(os))
const {}
123 template <
class Base,
class T>
125 static bool isLoaded() {
129 static const bool loaded;
135 using BaseInfo =
typename Base::BuilderInfo;
142 BaseInfo* getInfo(
const std::string& name) {
143 auto iter = infos_.find(name);
144 if (iter == infos_.end()){
151 bool hasInfo(
const std::string& name)
const {
152 return infos_.find(name) != infos_.end();
155 int numEntries()
const {
156 return infos_.size();
159 const std::map<std::string, BaseInfo*>& getMap()
const {
163 void readdInfo(
const std::string& name, BaseInfo* info){
167 bool addInfo(
const std::string& elem, BaseInfo* info){
168 readdInfo(elem, info);
170 addLoader(name_, elem, info);
175 void addLoader(
const std::string& lib,
const std::string& name, BaseInfo* info);
177 std::map<std::string, BaseInfo*> infos_;
182 template <
class Base>
186 using BaseInfo=
typename Library::BaseInfo;
187 using Map=std::map<std::string,Library*>;
189 static Library* getLibrary(
const std::string& name){
193 auto iter = libraries->find(name);
194 if (iter == libraries->end()){
195 auto* info =
new Library(name);
196 (*libraries)[name] = info;
205 static Map* libraries;
208 template <
class Base>
typename InfoLibraryDatabase<Base>::Map*
211 template <
class Base,
class Info>
214 const std::string& elem,
216 elemlib_(elemlib), elem_(elem), info_(info)
220 void load()
override {
222 if (!lib->hasInfo(elem_)){
223 lib->readdInfo(elem_, info_);
227 std::string elemlib_;
246 template <
class T>
static bool add(){
247 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
269 const unsigned major;
270 const unsigned minor;
271 const unsigned tertiary;
273 constexpr
unsigned getMajor() {
return major; }
274 constexpr
unsigned getMinor() {
return minor; }
275 constexpr
unsigned getTertiary() {
return tertiary; }
279 return ver.getMajor();
282 constexpr
unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
283 return ver.getMinor();
286 constexpr
unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
287 return ver.getTertiary();
295 #define SST_ELI_DECLARE_INFO(...) \
296 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__,SST::ELI::ProvidesDefaultInfo,void>; \
297 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
298 BuilderImpl* info){ \
299 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
301 SST_ELI_DECLARE_INFO_COMMON()
304 #define SST_ELI_DECLARE_DEFAULT_INFO() \
305 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
306 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
307 BuilderImpl* info){ \
308 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
310 SST_ELI_DECLARE_INFO_COMMON()
313 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
314 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,__VA_ARGS__,void>; \
315 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
316 SST_ELI_DECLARE_INFO_COMMON()
318 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
319 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
320 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
321 SST_ELI_DECLARE_INFO_COMMON()
323 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
324 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info){ \
325 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
328 #define SST_ELI_EXTERN_DERIVED(base,cls,lib,name,version,desc) \
329 bool ELI_isLoaded(); \
330 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
332 #define SST_ELI_REGISTER_DERIVED(base,cls,lib,name,version,desc) \
333 bool ELI_isLoaded() { \
334 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
335 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
337 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
339 #define SST_ELI_REGISTER_EXTERN(base,cls) \
340 bool cls::ELI_isLoaded(){ \
341 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
342 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
348 #endif // SST_CORE_ELEMENTINFO_H
Definition: elementinfo.h:212
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
Definition: elementinfo.h:124
Definition: elementinfo.h:254
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:43
Definition: elementinfo.h:183
Definition: elementinfo.h:240
Definition: elementinfo.h:88
Definition: elibase.h:107
Definition: elementinfo.h:132
Definition: rankInfo.h:21
Definition: elementinfo.h:56
Base class for python modules in element libraries.
Definition: element_python.h:126
static bool addLoader(const std::string &lib, const std::string &name, LibraryLoader *loader)
Definition: elibase.cc:32