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