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*
215 if (!lib->hasInfo(elem)){
216 lib->readdInfo(elem, info);
228 template <
class T>
static bool add(){
229 return Base::template addDerivedInfo<T>(T::ELI_getLibrary(), T::ELI_getName());
251 const unsigned major;
252 const unsigned minor;
253 const unsigned tertiary;
255 constexpr
unsigned getMajor() {
return major; }
256 constexpr
unsigned getMinor() {
return minor; }
257 constexpr
unsigned getTertiary() {
return tertiary; }
261 return ver.getMajor();
264 constexpr
unsigned SST_ELI_getMinorNumberFromVersion(SST_ELI_element_version_extraction ver) {
265 return ver.getMinor();
268 constexpr
unsigned SST_ELI_getTertiaryNumberFromVersion(SST_ELI_element_version_extraction ver) {
269 return ver.getTertiary();
277 #define SST_ELI_DECLARE_INFO(...) \
278 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<__VA_ARGS__,SST::ELI::ProvidesDefaultInfo,void>; \
279 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
280 BuilderImpl* info){ \
281 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
283 SST_ELI_DECLARE_INFO_COMMON()
286 #define SST_ELI_DECLARE_DEFAULT_INFO() \
287 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
288 template <class BuilderImpl> static bool addInfo(const std::string& elemlib, const std::string& elem, \
289 BuilderImpl* info){ \
290 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
292 SST_ELI_DECLARE_INFO_COMMON()
295 #define SST_ELI_DECLARE_INFO_EXTERN(...) \
296 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,__VA_ARGS__,void>; \
297 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
298 SST_ELI_DECLARE_INFO_COMMON()
300 #define SST_ELI_DECLARE_DEFAULT_INFO_EXTERN() \
301 using BuilderInfo = ::SST::ELI::BuilderInfoImpl<SST::ELI::ProvidesDefaultInfo,void>; \
302 static bool addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info); \
303 SST_ELI_DECLARE_INFO_COMMON()
305 #define SST_ELI_DEFINE_INFO_EXTERN(base) \
306 bool base::addInfo(const std::string& elemlib, const std::string& elem, BuilderInfo* info){ \
307 return ::SST::ELI::InfoDatabase::getLibrary<__LocalEliBase>(elemlib)->addInfo(elem,info); \
310 #define SST_ELI_EXTERN_DERIVED(base,cls,lib,name,version,desc) \
311 bool ELI_isLoaded(); \
312 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
314 #define SST_ELI_REGISTER_DERIVED(base,cls,lib,name,version,desc) \
315 bool ELI_isLoaded() { \
316 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
317 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
319 SST_ELI_DEFAULT_INFO(lib,name,ELI_FORWARD_AS_ONE(version),desc)
321 #define SST_ELI_REGISTER_EXTERN(base,cls) \
322 bool cls::ELI_isLoaded(){ \
323 return SST::ELI::InstantiateBuilder<base,cls>::isLoaded() \
324 && SST::ELI::InstantiateBuilderInfo<base,cls>::isLoaded(); \
330 #endif // SST_CORE_ELEMENTINFO_H
static bool addLoader(const std::string &lib, const std::string &name, std::function< void()> &&loader)
Definition: elibase.cc:32
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
Definition: elementinfo.h:124
Definition: elementinfo.h:236
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:43
Definition: elementinfo.h:183
Definition: elementinfo.h:222
Definition: elementinfo.h:88
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