SST  15.1.0
StructuralSimulationToolkit
defaultInfo.h
1 // Copyright 2009-2025 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-2025, 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 <string>
18 #include <vector>
19 
20 namespace SST::ELI {
21 
23 {
24  friend class ModuleDocOldEli;
25 
26 public:
27  const std::string& getLibrary() const { return lib_; }
28  const std::string& getDescription() const { return desc_; }
29  const std::string& getName() const { return name_; }
30  const std::vector<int>& getVersion() const { return version_; }
31  const std::string& getCompileFile() const { return file_; }
32  const std::vector<int>& getELICompiledVersion() const;
33  const std::string& getAlias() const { return alias_; }
34 
35  std::string getELIVersionString() const;
36 
37  void toString(std::ostream& os) const;
38 
39  template <class XMLNode>
40  void outputXML(XMLNode* node) const
41  {
42  if ( !getAlias().empty() ) node->SetAttribute("Alias", getAlias().c_str());
43  node->SetAttribute("Name", getName().c_str());
44  node->SetAttribute("Description", getDescription().c_str());
45  }
46 
47  template <class T>
48  ProvidesDefaultInfo(const std::string& lib, const std::string& name, T* UNUSED(t)) :
49  lib_(lib),
50  name_(name),
51  desc_(T::ELI_getDescription()),
52  version_(T::ELI_getVersion()),
53  file_(T::ELI_getCompileFile()),
54  alias_(GetAlias<T>::get())
55  {}
56 
57 protected:
58  template <class T>
59  explicit ProvidesDefaultInfo(T* t) :
60  ProvidesDefaultInfo(T::ELI_getLibrary(), T::ELI_getName(), t)
61  {}
62 
63 private:
64  std::string lib_;
65  std::string name_;
66  std::string desc_;
67  std::vector<int> version_;
68  std::string file_;
69  std::vector<int> compiled_;
70  std::string alias_;
71 };
72 
73 } // namespace SST::ELI
74 
75 #define SST_ELI_INSERT_COMPILE_INFO() \
76  static const std::string ELI_getCompileFile() \
77  { \
78  return __FILE__; \
79  }
80 
81 #define SST_ELI_DEFAULT_INFO(lib, name, version, desc) \
82  SST_ELI_INSERT_COMPILE_INFO() \
83  static constexpr unsigned majorVersion() \
84  { \
85  return SST::SST_ELI_getMajorNumberFromVersion(version); \
86  } \
87  static constexpr unsigned minorVersion() \
88  { \
89  return SST::SST_ELI_getMinorNumberFromVersion(version); \
90  } \
91  static constexpr unsigned tertiaryVersion() \
92  { \
93  return SST::SST_ELI_getTertiaryNumberFromVersion(version); \
94  } \
95  static const std::vector<int>& ELI_getVersion() \
96  { \
97  static std::vector<int> var = version; \
98  return var; \
99  } \
100  static const char* ELI_getLibrary() \
101  { \
102  return lib; \
103  } \
104  static const char* ELI_getName() \
105  { \
106  return name; \
107  } \
108  static const char* ELI_getDescription() \
109  { \
110  return desc; \
111  }
112 
113 #define SST_ELI_ELEMENT_VERSION(...) { __VA_ARGS__ }
114 
115 #define SST_ELI_REGISTER_ALIAS(alias) \
116  static std::string ELI_getAlias() \
117  { \
118  return alias; \
119  }
120 
121 #endif // SST_CORE_ELI_DEFAULTINFO_H
Definition: attributeInfo.h:22
Definition: elibase.h:152
Definition: defaultInfo.h:22