SST  9.0.0
StructuralSimulationToolkit
paramsInfo.h
1 #ifndef SST_CORE_PARAMS_INFO_H
2 #define SST_CORE_PARAMS_INFO_H
3 
4 #include <vector>
5 #include <string>
6 #include <sst/core/params.h>
7 #include <sst/core/eli/elibase.h>
8 
9 namespace SST {
10 namespace ELI {
11 
12 template <class T, class Enable=void>
13 struct GetParams {
14  static const std::vector<SST::ElementInfoParam>& get() {
15  static std::vector<SST::ElementInfoParam> var = { };
16  return var;
17  }
18 };
19 
20 template <class T>
21 struct GetParams<T,
22  typename MethodDetect<decltype(T::ELI_getParams())>::type> {
23  static const std::vector<SST::ElementInfoParam>& get() {
24  return T::ELI_getParams();
25  }
26 };
27 
29  public:
30  const std::vector<ElementInfoParam>& getValidParams() const {
31  return params_;
32  }
33 
34  void toString(std::ostream& os) const;
35 
36  template <class XMLNode> void outputXML(XMLNode* node) const {
37  // Build the Element to Represent the Component
38  int idx = 0;
39  for (const ElementInfoParam& param : params_){;
40  // Build the Element to Represent the Parameter
41  auto* XMLParameterElement = new XMLNode("Parameter");
42  XMLParameterElement->SetAttribute("Index", idx);
43  XMLParameterElement->SetAttribute("Name", param.name);
44  XMLParameterElement->SetAttribute("Description", param.description ? param.description : "none");
45  XMLParameterElement->SetAttribute("Default", param.defaultValue ? param.defaultValue : "none");
46  node->LinkEndChild(XMLParameterElement);
47  ++idx;
48  }
49  }
50 
51  const Params::KeySet_t& getParamNames() const {
52  return allowedKeys;
53  }
54 
55  protected:
56  template <class T> ProvidesParams(T* UNUSED(t)) :
57  params_(GetParams<T>::get())
58  {
59  init();
60  }
61 
62 
63 private:
64  void init();
65 
66  Params::KeySet_t allowedKeys;
67  std::vector<ElementInfoParam> params_;
68 };
69 
70 }
71 }
72 
73 #define SST_ELI_DOCUMENT_PARAMS(...) \
74  static const std::vector<SST::ElementInfoParam>& ELI_getParams() { \
75  static std::vector<SST::ElementInfoParam> var = { __VA_ARGS__ } ; \
76  return var; \
77  }
78 
79 #endif
Definition: paramsInfo.h:13
Definition: elibase.h:105
Definition: paramsInfo.h:28
Describes Parameters to a Component.
Definition: elibase.h:46
std::set< key_type, KeyCompare > KeySet_t
Definition: params.h:172