SST 16.0.0
Structural Simulation Toolkit
attributeInfo.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_ATTRIBUTE_INFO_H
13#define SST_CORE_ELI_ATTRIBUTE_INFO_H
14
15#include "sst/core/eli/elibase.h"
16#include "sst/core/warnmacros.h"
17
18#include <ostream>
19#include <string>
20#include <type_traits>
21#include <vector>
22
23namespace SST::ELI {
24
25template <typename, typename = void>
27{
28 static const std::vector<SST::ElementInfoAttribute>& get()
29 {
30 static std::vector<SST::ElementInfoAttribute> var = {};
31 return var;
32 }
33};
34
35template <typename T>
36struct GetAttributes<T, std::void_t<decltype(T::ELI_getAttributes())>>
37{
38 static const std::vector<SST::ElementInfoAttribute>& get() { return T::ELI_getAttributes(); }
39};
40
41class ProvidesAttributes
42{
43public:
44 const std::vector<ElementInfoAttribute>& getAttributes() const { return attributes_; }
45
46 void toString(std::ostream& os) const;
47
48 template <class XMLNode>
49 void outputXML(XMLNode* node) const
50 {
51 // Build the Element to Represent the Component
52 int idx = 0;
53 for ( const ElementInfoAttribute& attribute : attributes_ ) {
54 ;
55 // Build the Element to Represent the Attribute
56 auto* XMLAttributeElement = new XMLNode("Attribute");
57 XMLAttributeElement->SetAttribute("Index", idx);
58 XMLAttributeElement->SetAttribute("Name", attribute.name);
59 XMLAttributeElement->SetAttribute("Value", attribute.value ? attribute.value : "none");
60 node->LinkEndChild(XMLAttributeElement);
61 ++idx;
62 }
63 }
64
65protected:
66 template <class T>
67 explicit ProvidesAttributes(T* UNUSED(t)) :
68 attributes_(GetAttributes<T>::get())
69 {}
70
71private:
72 std::vector<ElementInfoAttribute> attributes_;
73};
74
75} // namespace SST::ELI
76
77// clang-format off
78#define SST_ELI_DOCUMENT_ATTRIBUTES(...) \
79 static const std::vector<SST::ElementInfoAttribute>& ELI_getAttributes() \
80 { \
81 static std::vector<SST::ElementInfoAttribute> var = { __VA_ARGS__ }; \
82 auto parent = SST::ELI::GetAttributes< \
83 std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
84 SST::ELI::combineEliInfo(var, parent); \
85 return var; \
86 }
87// clang-format on
88
89#define SST_ELI_DELETE_ATTRIBUTE(attribute) { attribute, nullptr }
90
91#endif // SST_CORE_ELI_ATTRIBUTE_INFO_H
Definition attributeInfo.h:27
Definition elibase.h:82