SST 15.0
Structural Simulation Toolkit
paramsInfo.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_PARAMS_INFO_H
13#define SST_CORE_ELI_PARAMS_INFO_H
14
15#include "sst/core/eli/elibase.h"
16
17#include <string>
18#include <vector>
19
20namespace SST::ELI {
21
22template <typename, typename = void>
24{
25 static const std::vector<SST::ElementInfoParam>& get()
26 {
27 static std::vector<SST::ElementInfoParam> var = {};
28 return var;
29 }
30};
31
32template <class T>
33struct GetParams<T, std::void_t<decltype(T::ELI_getParams())>>
34{
35 static const std::vector<SST::ElementInfoParam>& get() { return T::ELI_getParams(); }
36};
37
38class ProvidesParams
39{
40public:
41 const std::vector<ElementInfoParam>& getValidParams() const { return params_; }
42
43 void toString(std::ostream& os) const;
44
45 template <class XMLNode>
46 void outputXML(XMLNode* node) const
47 {
48 // Build the Element to Represent the Component
49 int idx = 0;
50 for ( const ElementInfoParam& param : params_ ) {
51 ;
52 // Build the Element to Represent the Parameter
53 auto* XMLParameterElement = new XMLNode("Parameter");
54 XMLParameterElement->SetAttribute("Index", idx);
55 XMLParameterElement->SetAttribute("Name", param.name);
56 XMLParameterElement->SetAttribute("Description", param.description ? param.description : "none");
57 XMLParameterElement->SetAttribute("Default", param.defaultValue ? param.defaultValue : "none");
58 node->LinkEndChild(XMLParameterElement);
59 ++idx;
60 }
61 }
62
63 const std::vector<std::string>& getParamNames() const { return allowedKeys; }
64
65protected:
66 template <class T>
67 explicit ProvidesParams(T* UNUSED(t)) :
68 params_(GetParams<T>::get())
69 {
70 init();
71 }
72
73private:
74 void init();
75
76 std::vector<std::string> allowedKeys;
77 std::vector<ElementInfoParam> params_;
78};
79
80} // namespace SST::ELI
81
82// clang-format off
83#define SST_ELI_DOCUMENT_PARAMS(...) \
84 static const std::vector<SST::ElementInfoParam>& ELI_getParams() \
85 { \
86 static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ }; \
87 auto parent = SST::ELI::GetParams< \
88 std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
89 SST::ELI::combineEliInfo(var, parent); \
90 return var; \
91 }
92// clang-format on
93
94#define SST_ELI_DELETE_PARAM(param) { param, nullptr, nullptr }
95
96#endif // SST_CORE_ELI_PARAMS_INFO_H
Definition paramsInfo.h:24
Describes Parameters to a Component.
Definition elibase.h:48