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