SST 16.1.0
Structural Simulation Toolkit
component.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_COMPONENT_H
13#define SST_CORE_COMPONENT_H
14
15#include "sst/core/baseComponent.h"
16#include "sst/core/eli/elementinfo.h"
17#include "sst/core/sst_types.h"
18
19#include <cstdint>
20#include <map>
21
22using namespace SST::Statistics;
23
24namespace SST {
25class SubComponent;
26
27/**
28 * Main component object for the simulation.
29 * All models inherit from this.
30 */
31class Component : public BaseComponent
32{
33public:
34 SST_ELI_DECLARE_BASE(Component)
35 // declare extern to limit compile times
36 SST_ELI_DECLARE_CTOR_EXTERN(ComponentId_t,SST::Params&)
37 // These categories will print in sst-info in the order they are
38 // listed here
40 ELI::ProvidesCategory,
41 ELI::ProvidesParams,
42 ELI::ProvidesPorts,
43 ELI::ProvidesSubComponentSlots,
44 ELI::ProvidesStats,
45 ELI::ProvidesCheckpointable,
46 ELI::ProvidesProfilePoints,
47 ELI::ProvidesAttributes)
48
49 /** Constructor. Generally only called by the factory class.
50 @param id Unique component ID
51 */
52 explicit Component(ComponentId_t id);
53 virtual ~Component() override = default;
54
55
56 void serialize_order(SST::Core::Serialization::serializer& ser) override;
57
58 ImplementSerializable(SST::Component)
59
60protected:
61 friend class SubComponent;
62 Component() = default; // For Serialization only
63
64private:
65 friend class BaseComponent;
66 std::map<SimTime_t, Clock::Group*> clock_groups_;
67
68 Clock::Group* getClockGroup(TimeConverter tc) override;
69
70 // This is for serializing anything that needs to happen after all the SubComponents are serialized
71 void serialize_final(SST::Core::Serialization::serializer& ser) override;
72};
73
74} // namespace SST
75
76// These macros allow you to register a base class for a set of
77// components that have the same (or substantially the same) ELI
78// information. ELI information can be defined in the base class, and
79// will be inherited by the child classes.
80#define SST_ELI_REGISTER_COMPONENT_BASE(cls) \
81 SST_ELI_DECLARE_NEW_BASE(SST::Component,::cls) \
82 SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&)
83
84#define SST_ELI_REGISTER_COMPONENT_DERIVED_BASE(cls, base) \
85 SST_ELI_DECLARE_NEW_BASE(::base,::cls) \
86 SST_ELI_NEW_BASE_CTOR(SST::ComponentId_t,SST::Params&)
87
88// 'x' is needed because you can't pass ##__VAR_ARGS__ as the first
89// item to the macro or you end up with a leading comma that won't
90// compile.
91#define ELI_GET_COMPONENT_DEFAULT(x, arg1, ...) arg1
92
93#define SST_ELI_REGISTER_COMPONENT(cls, lib, name, version, desc, cat, ...) \
94 SST_ELI_REGISTER_DERIVED(ELI_GET_COMPONENT_DEFAULT(,##__VA_ARGS__,SST::Component),cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
95 SST_ELI_CATEGORY_INFO(cat)
96
97#endif // SST_CORE_COMPONENT_H
A Clock class.
Definition clock.h:40
SST_ELI_DECLARE_INFO_EXTERN(ELI::ProvidesCategory, ELI::ProvidesParams, ELI::ProvidesPorts, ELI::ProvidesSubComponentSlots, ELI::ProvidesStats, ELI::ProvidesCheckpointable, ELI::ProvidesProfilePoints, ELI::ProvidesAttributes) explicit Component(ComponentId_t id)
Constructor.
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:43
Parameter store.
Definition params.h:65
SubComponent is a class loadable through the factory which allows dynamic functionality to be added t...
Definition subcomponent.h:29
A class to convert between a component's view of time and the core's view of time.
Definition timeConverter.h:31