SST 16.0.0
Structural Simulation Toolkit
defaultInfo.h
1// Copyright 2009-2026 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2026, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_ELI_DEFAULTINFO_H
13#define SST_CORE_ELI_DEFAULTINFO_H
14
15#include "sst/core/eli/elibase.h"
16
17#include <ostream>
18#include <string>
19#include <vector>
20
21namespace SST::ELI {
22
23class ProvidesDefaultInfo
24{
25 friend class ModuleDocOldEli;
26
27public:
28 const std::string& getLibrary() const { return lib_; }
29 const std::string& getDescription() const { return desc_; }
30 const std::string& getName() const { return name_; }
31 const std::vector<int>& getVersion() const { return version_; }
32 const std::string& getCompileFile() const { return file_; }
33 const std::vector<int>& getELICompiledVersion() const;
34 const std::string& getAlias() const { return alias_; }
35
36 std::string getELIVersionString() const;
37
38 void toString(std::ostream& os) const;
39
40 template <class XMLNode>
41 void outputXML(XMLNode* node) const
42 {
43 if ( !getAlias().empty() ) node->SetAttribute("Alias", getAlias().c_str());
44 node->SetAttribute("Name", getName().c_str());
45 node->SetAttribute("Description", getDescription().c_str());
46 }
47
48 template <class T>
49 ProvidesDefaultInfo(const std::string& lib, const std::string& name, T* UNUSED(t)) :
50 lib_(lib),
51 name_(name),
52 desc_(T::ELI_getDescription()),
53 version_(T::ELI_getVersion()),
54 file_(T::ELI_getCompileFile()),
55 alias_(GetAlias<T>::get())
56 {}
57
58protected:
59 template <class T>
60 explicit ProvidesDefaultInfo(T* t) :
61 ProvidesDefaultInfo(T::ELI_getLibrary(), T::ELI_getName(), t)
62 {}
63
64private:
65 std::string lib_;
66 std::string name_;
67 std::string desc_;
68 std::vector<int> version_;
69 std::string file_;
70 std::vector<int> compiled_;
71 std::string alias_;
72};
73
74} // namespace SST::ELI
75
76#define SST_ELI_INSERT_COMPILE_INFO() \
77 static const std::string ELI_getCompileFile() \
78 { \
79 return __FILE__; \
80 }
81
82#define SST_ELI_DEFAULT_INFO(lib, name, version, desc) \
83 SST_ELI_INSERT_COMPILE_INFO() \
84 static constexpr unsigned majorVersion() \
85 { \
86 return SST::SST_ELI_getMajorNumberFromVersion(version); \
87 } \
88 static constexpr unsigned minorVersion() \
89 { \
90 return SST::SST_ELI_getMinorNumberFromVersion(version); \
91 } \
92 static constexpr unsigned tertiaryVersion() \
93 { \
94 return SST::SST_ELI_getTertiaryNumberFromVersion(version); \
95 } \
96 static const std::vector<int>& ELI_getVersion() \
97 { \
98 static std::vector<int> var = version; \
99 return var; \
100 } \
101 static const char* ELI_getLibrary() \
102 { \
103 return lib; \
104 } \
105 static const char* ELI_getName() \
106 { \
107 return name; \
108 } \
109 static const char* ELI_getDescription() \
110 { \
111 return desc; \
112 }
113
114#define SST_ELI_ELEMENT_VERSION(...) { __VA_ARGS__ }
115
116#define SST_ELI_REGISTER_ALIAS(alias) \
117 static std::string ELI_getAlias() \
118 { \
119 return alias; \
120 }
121
122#endif // SST_CORE_ELI_DEFAULTINFO_H