SST  9.0.0
StructuralSimulationToolkit
subcompSlotInfo.h
1 #ifndef SST_CORE_SUBCOMPSLOTINFO_H
2 #define SST_CORE_SUBCOMPSLOTINFO_H
3 
4 #include <string>
5 #include <vector>
6 
7 #include <sst/core/eli/elibase.h>
8 
9 namespace SST {
10 namespace ELI {
11 
12 template <class T, class Enable=void>
13 struct InfoSubs {
14  static const std::vector<SST::ElementInfoSubComponentSlot>& get() {
15  static std::vector<SST::ElementInfoSubComponentSlot> var = { };
16  return var;
17  }
18 };
19 
20 template <class T>
21 struct InfoSubs<T,
22  typename MethodDetect<decltype(T::ELI_getSubComponentSlots())>::type> {
23  static const std::vector<SST::ElementInfoSubComponentSlot>& get() {
24  return T::ELI_getSubComponentSlots();
25  }
26 };
27 
29  public:
30  const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() const {
31  return slots_;
32  }
33 
34  void toString(std::ostream& os) const;
35 
36  template <class XMLNode> void outputXML(XMLNode* node) const {
37  int idx = 0;
38  for (const ElementInfoSubComponentSlot& slot : slots_){
39  auto* element = new XMLNode("SubComponentSlot");
40  element->SetAttribute("Index", idx);
41  element->SetAttribute("Name", slot.name);
42  element->SetAttribute("Description", slot.description ? slot.description : "none");
43  element->SetAttribute("Interface", slot.superclass ? slot.superclass : "none");
44  node->LinkEndChild(element);
45  ++idx;
46  }
47  }
48 
49  protected:
50  template <class T> ProvidesSubComponentSlots(T* UNUSED(t)) :
51  slots_(InfoSubs<T>::get())
52  {
53  }
54 
55  private:
56  std::vector<ElementInfoSubComponentSlot> slots_;
57 };
58 
59 }
60 }
61 
62 #define SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(...) \
63  static const std::vector<SST::ElementInfoSubComponentSlot>& ELI_getSubComponentSlots() { \
64  static std::vector<SST::ElementInfoSubComponentSlot> var = { __VA_ARGS__ } ; \
65  return var; \
66  }
67 
68 #endif
69 
Definition: elibase.h:95
Definition: elibase.h:105
Definition: subcompSlotInfo.h:28
Definition: subcompSlotInfo.h:13