SST 12.1.0
Structural Simulation Toolkit
statnull.h
1// Copyright 2009-2022 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-2022, 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
19namespace SST {
20namespace Statistics {
21
22// NOTE: When calling base class members of classes derived from
23// a templated base class. The user must use "this->" in
24// order to call base class members (to avoid a compiler
25// error) because they are "nondependant named" and the
26// templated base class is a "dependant named". The
27// compiler will not look in dependant named base classes
28// when looking up indepenedent names.
29// See: http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-members.html
30
31/**
32 \class NullStatistic
33
34 An empty statistic place holder.
35
36 @tparam T A template for holding the main data type of this statistic
37*/
38template <class T, bool B = std::is_fundamental<T>::value>
40{};
41
42template <class T>
43struct NullStatisticBase<T, true> : public Statistic<T>
44{
45
47 BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
48 Statistic<T>(comp, statName, statSubId, statParams)
49 {
50 // Set the Name of this Statistic
51 this->setStatisticTypeName("NULL");
52 }
53
54 void addData_impl(T UNUSED(data)) override {}
55
56 void addData_impl_Ntimes(uint64_t UNUSED(N), T UNUSED(data)) override {}
57};
58
59template <class... Args>
60struct NullStatisticBase<std::tuple<Args...>, false> : public Statistic<std::tuple<Args...>>
61{
62
64 BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
65 Statistic<std::tuple<Args...>>(comp, statName, statSubId, statParams)
66 {
67 // Set the Name of this Statistic
68 this->setStatisticTypeName("NULL");
69 }
70
71 void addData_impl(Args... UNUSED(data)) override {}
72
73 void addData_impl_Ntimes(uint64_t UNUSED(N), Args... UNUSED(data)) override {}
74};
75
76template <class T>
77struct NullStatisticBase<T, false> : public Statistic<T>
78{
79
81 BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
82 Statistic<T>(comp, statName, statSubId, statParams)
83 {
84 // Set the Name of this Statistic
85 this->setStatisticTypeName("NULL");
86 }
87
88 void addData_impl(T&& UNUSED(data)) override {}
89 void addData_impl(const T& UNUSED(data)) override {}
90
91 void addData_impl(uint64_t UNUSED(N), T&& UNUSED(data)) override {}
92 void addData_impl(uint64_t UNUSED(N), const T& UNUSED(data)) override {}
93};
94
95template <class T>
97{
98
99 SST_ELI_DECLARE_STATISTIC_TEMPLATE(
101 "sst",
102 "NullStatistic",
103 SST_ELI_ELEMENT_VERSION(1,0,0),
104 "Null object it ignore all collections",
105 "SST::Statistic<T>")
106
107 NullStatistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParam) :
108 NullStatisticBase<T>(comp, statName, statSubId, statParam)
109 {}
110
111 ~NullStatistic() {}
112
113 void clearStatisticData() override
114 {
115 // Do Nothing
116 }
117
118 void registerOutputFields(StatisticFieldsOutput* UNUSED(statOutput)) override
119 {
120 // Do Nothing
121 }
122
123 void outputStatisticFields(StatisticFieldsOutput* UNUSED(statOutput), bool UNUSED(EndOfSimFlag)) override
124 {
125 // Do Nothing
126 }
127
128 bool isReady() const override { return true; }
129
130 bool isNullStatistic() const override { return true; }
131
132 static bool isLoaded() { return loaded_; }
133
134private:
135 static bool loaded_;
136};
137
138template <class T>
139bool NullStatistic<T>::loaded_ = true;
140
141template <>
142struct NullStatistic<void> : public Statistic<void>
143{
144 SST_ELI_REGISTER_DERIVED(
147 "sst",
148 "NullStatistic",
149 SST_ELI_ELEMENT_VERSION(1,0,0),
150 "Null statistic for custom (void) stats"
151 )
152
153 SST_ELI_INTERFACE_INFO("Statistic<void>")
154
155 NullStatistic(BaseComponent* comp, const std::string& statName, const std::string& statSubId, Params& statParams) :
156 Statistic<void>(comp, statName, statSubId, statParams)
157 {
158 // Set the Name of this Statistic
159 this->setStatisticTypeName("NULL");
160 }
161};
162
163} // namespace Statistics
164} // namespace SST
165
166#endif // SST_CORE_STATAPI_STATNULL_H
Main component object for the simulation.
Definition: baseComponent.h:51
Parameter store.
Definition: params.h:56
Definition: statoutput.h:143
Forms the template defined base class for statistics gathering within SST.
Definition: statbase.h:361
Definition: statnull.h:40
An empty statistic place holder.
Definition: statnull.h:97