SST 15.0
Structural Simulation Toolkit
statnull.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_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& statName, const std::string& statSubId, Params& statParams) :
48 Statistic<T>(comp, statName, statSubId, statParams, true)
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& statName, const std::string& statSubId, Params& statParams) :
67 Statistic<std::tuple<Args...>>(comp, statName, statSubId, statParams, true)
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& statName, const std::string& statSubId, Params& statParams) :
86 Statistic<T>(comp, statName, statSubId, statParams, true)
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 NullStatistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParam) :
114 NullStatisticBase<T>(comp, statName, statSubId, statParam)
115 {}
116
117 ~NullStatistic() {}
118
119 void clearStatisticData() override
120 {
121 // Do Nothing
122 }
123
124 void registerOutputFields(StatisticFieldsOutput* UNUSED(statOutput)) override
125 {
126 // Do Nothing
127 }
128
129 void outputStatisticFields(StatisticFieldsOutput* UNUSED(statOutput), bool UNUSED(EndOfSimFlag)) override
130 {
131 // Do Nothing
132 }
133
134 bool isReady() const override { return true; }
135
136 bool isNullStatistic() const override { return true; }
137
138 static bool isLoaded() { return loaded_; }
139
140private:
141 inline static bool loaded_ = true;
142};
143
144template <>
145class NullStatistic<void> : public Statistic<void>
146{
147public:
148 SST_ELI_REGISTER_DERIVED(
151 "sst",
152 "NullStatistic",
153 SST_ELI_ELEMENT_VERSION(1,0,0),
154 "Null statistic for custom (void) stats"
155 )
156
157 SST_ELI_INTERFACE_INFO("Statistic<void>")
158
159 NullStatistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
160 Statistic<void>(comp, statName, statSubId, statParams, true)
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:62
Parameter store.
Definition params.h:58
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:123
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:170
Statistic(BaseComponent *comp, const std::string &stat_name, const std::string &stat_sub_id, Params &stat_params, bool null_stat=false)
Construct a Statistic.
Definition statbase.h:437