SST 15.0
Structural Simulation Toolkit
subcompSlotInfo.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_SUBCOMPSLOTINFO_H
13#define SST_CORE_ELI_SUBCOMPSLOTINFO_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::ElementInfoSubComponentSlot>& get()
26 {
27 static std::vector<SST::ElementInfoSubComponentSlot> var = {};
28 return var;
29 }
30};
31
32template <class T>
33struct InfoSubs<T, std::void_t<decltype(T::ELI_getSubComponentSlots())>>
34{
35 static const std::vector<SST::ElementInfoSubComponentSlot>& get() { return T::ELI_getSubComponentSlots(); }
36};
37
38class ProvidesSubComponentSlots
39{
40public:
41 const std::vector<ElementInfoSubComponentSlot>& getSubComponentSlots() const { return slots_; }
42
43 void toString(std::ostream& os) const;
44
45 template <class XMLNode>
46 void outputXML(XMLNode* node) const
47 {
48 int idx = 0;
49 for ( const ElementInfoSubComponentSlot& slot : slots_ ) {
50 auto* element = new XMLNode("SubComponentSlot");
51 element->SetAttribute("Index", idx);
52 element->SetAttribute("Name", slot.name);
53 element->SetAttribute("Description", slot.description ? slot.description : "none");
54 element->SetAttribute("Interface", slot.superclass ? slot.superclass : "none");
55 node->LinkEndChild(element);
56 ++idx;
57 }
58 }
59
60protected:
61 template <class T>
62 explicit ProvidesSubComponentSlots(T* UNUSED(t)) :
63 slots_(InfoSubs<T>::get())
64 {}
65
66private:
67 std::vector<ElementInfoSubComponentSlot> slots_;
68};
69
70} // namespace SST::ELI
71
72// clang-format off
73#define SST_ELI_DOCUMENT_SUBCOMPONENT_SLOTS(...) \
74 static const std::vector<SST::ElementInfoSubComponentSlot>& ELI_getSubComponentSlots() \
75 { \
76 static std::vector<SST::ElementInfoSubComponentSlot> var = { __VA_ARGS__ }; \
77 auto parent = SST::ELI::InfoSubs< \
78 std::conditional_t<(__EliDerivedLevel > __EliBaseLevel), __LocalEliBase, __ParentEliBase>>::get(); \
79 SST::ELI::combineEliInfo(var, parent); \
80 return var; \
81 }
82// clang-format on
83#define SST_ELI_DELETE_SUBCOMPONENT_SLOT(slot) { slot, nullptr, nullptr }
84
85#endif // SST_CORE_ELI_SUBCOMPSLOTINFO_H
Definition subcompSlotInfo.h:24
Definition elibase.h:67