SST 16.0.0
Structural Simulation Toolkit
statnull.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_STATAPI_STATNULL_H
13#define SST_CORE_STATAPI_STATNULL_H
14
15#include "sst/core/sst_types.h"
16#include "sst/core/statapi/statbase.h"
17#include "sst/core/warnmacros.h"
18
19#include <tuple>
20
21namespace SST::Statistics {
22
23// NOTE: When calling base class members of classes derived from
24// a templated base class. The user must use "this->" in
25// order to call base class members (to avoid a compiler
26// error) because they are "nondependant named" and the
27// templated base class is a "dependant named". The
28// compiler will not look in dependant named base classes
29// when looking up indepenedent names.
30// See: http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-members.html
31
32/**
33 \class NullStatistic
34
35 An empty statistic place holder.
36
37 @tparam T A template for holding the main data type of this statistic
38*/
39template <class T, bool = std::is_arithmetic_v<T>>
41
42template <class T>
43class NullStatisticBase<T, true> : public Statistic<T>
44{
45public:
46 NullStatisticBase(
47 BaseComponent* comp, const std::string& stat_name, const std::string& stat_sub_id, Params& stat_params) :
48 Statistic<T>(comp, stat_name, stat_sub_id, stat_params)
49 {}
50
51 void addData_impl(T UNUSED(data)) override {}
52
53 void addData_impl_Ntimes(uint64_t UNUSED(N), T UNUSED(data)) override {}
54
55 virtual const std::string& getStatTypeName() const override { return stat_type_; }
56
57private:
58 inline static const std::string stat_type_ = "NULL";
59};
60
61template <class... Args>
62class NullStatisticBase<std::tuple<Args...>, false> : public Statistic<std::tuple<Args...>>
63{
64public:
65 NullStatisticBase(
66 BaseComponent* comp, const std::string& stat_name, const std::string& stat_sub_id, Params& stat_params) :
67 Statistic<std::tuple<Args...>>(comp, stat_name, stat_sub_id, stat_params)
68 {}
69
70 void addData_impl(Args... UNUSED(data)) override {}
71
72 void addData_impl_Ntimes(uint64_t UNUSED(N), Args... UNUSED(data)) override {}
73
74 virtual const std::string& getStatTypeName() const override { return stat_type_; }
75
76private:
77 inline static const std::string stat_type_ = "NULL";
78};
79
80template <class T>
81class NullStatisticBase<T, false> : public Statistic<T>
82{
83public:
84 NullStatisticBase(
85 BaseComponent* comp, const std::string& stat_name, const std::string& stat_sub_id, Params& stat_params) :
86 Statistic<T>(comp, stat_name, stat_sub_id, stat_params)
87 {}
88
89 void addData_impl(T&& UNUSED(data)) override {}
90 void addData_impl(const T& UNUSED(data)) override {}
91
92 void addData_impl_Ntimes(uint64_t UNUSED(N), T&& UNUSED(data)) override {}
93 void addData_impl_Ntimes(uint64_t UNUSED(N), const T& UNUSED(data)) override {}
94
95 virtual const std::string& getStatTypeName() const override { return stat_type_; }
96
97private:
98 inline static const std::string stat_type_ = "NULL";
99};
100
101template <class T>
103{
104public:
105 SST_ELI_DECLARE_STATISTIC_TEMPLATE(
107 "sst",
108 "NullStatistic",
109 SST_ELI_ELEMENT_VERSION(1,0,0),
110 "Null object that ignores all collections",
111 "SST::Statistic<T>"
112 )
113
115 BaseComponent* comp, const std::string& stat_name, const std::string& stat_sub_id, Params& stat_params) :
116 NullStatisticBase<T>(comp, stat_name, stat_sub_id, stat_params)
117 {}
118
119 ~NullStatistic() {}
120
121 void clearStatisticData() override
122 {
123 // Do Nothing
124 }
125
126 void registerOutputFields(StatisticFieldsOutput* UNUSED(stat_output)) override
127 {
128 // Do Nothing
129 }
130
131 void outputStatisticFields(StatisticFieldsOutput* UNUSED(stat_output), bool UNUSED(end_of_sim_flag)) override
132 {
133 // Do Nothing
134 }
135
136 bool isReady() const override { return true; }
137
138 bool isNullStatistic() const override { return true; }
139
140 static bool isLoaded() { return true; }
141};
142
143template <>
144class NullStatistic<void> : public Statistic<void>
145{
146public:
147 SST_ELI_REGISTER_DERIVED(
150 "sst",
151 "NullStatistic",
152 SST_ELI_ELEMENT_VERSION(1,0,0),
153 "Null statistic for custom (void) stats"
154 )
155
156 SST_ELI_INTERFACE_INFO("Statistic<void>")
157
159 BaseComponent* comp, const std::string& stat_name, const std::string& stat_sub_id, Params& stat_params) :
160 Statistic<void>(comp, stat_name, stat_sub_id, stat_params)
161 {}
162
163 virtual std::string getELIName() const override { return "sst.NullStatistic"; }
164
165 virtual const std::string& getStatTypeName() const override { return stat_type_; }
166
167private:
168 inline static const std::string stat_type_ = "NULL";
169};
170
171} // namespace SST::Statistics
172
173#endif // SST_CORE_STATAPI_STATNULL_H
Main component object for the simulation.
Definition baseComponent.h:67
Parameter store.
Definition params.h:65
virtual const std::string & getStatTypeName() const override
Return the Statistic type name.
Definition statnull.h:95
virtual const std::string & getStatTypeName() const override
Return the Statistic type name.
Definition statnull.h:55
virtual const std::string & getStatTypeName() const override
Return the Statistic type name.
Definition statnull.h:74
Definition statnull.h:40
An empty statistic place holder.
Definition statnull.h:103
virtual const std::string & getStatTypeName() const
Return the Statistic type name.
Definition statbase.h:124
virtual std::string getELIName() const =0
Return the ELI type of the statistic The ELI registration macro creates this function automatically f...
Definition statoutput.h:172
Statistic(BaseComponent *comp, const std::string &stat_name, const std::string &stat_sub_id, Params &stat_params)
Construct a Statistic.
Definition statbase.h:473
Statistic(BaseComponent *comp, const std::string &stat_name, const std::string &stat_sub_id, Params &stat_params)
Construct a Statistic.
Definition statbase.h:432