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