SST  10.0.0
StructuralSimulationToolkit
statnull.h
1 // Copyright 2009-2020 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-2020, 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 
13 #ifndef _H_SST_CORE_NULL_STATISTIC_
14 #define _H_SST_CORE_NULL_STATISTIC_
15 
16 #include "sst/core/sst_types.h"
17 #include "sst/core/warnmacros.h"
18 
19 #include "sst/core/statapi/statbase.h"
20 
21 namespace SST {
22 namespace Statistics {
23 
24 // NOTE: When calling base class members of classes derived from
25 // a templated base class. The user must use "this->" in
26 // order to call base class members (to avoid a compiler
27 // error) because they are "nondependant named" and the
28 // templated base class is a "dependant named". The
29 // compiler will not look in dependant named base classes
30 // when looking up indepenedent names.
31 // See: http://www.parashift.com/c++-faq-lite/nondependent-name-lookup-members.html
32 
33 /**
34  \class NullStatistic
35 
36  An empty statistic place holder.
37 
38  @tparam T A template for holding the main data type of this statistic
39 */
40 template <class T, bool B = std::is_fundamental<T>::value>
42 
43 template <class T>
44 struct NullStatisticBase<T,true> : public Statistic<T> {
45 
46  NullStatisticBase(BaseComponent* comp, const std::string& statName,
47  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 
59 template <class... Args>
60 struct NullStatisticBase<std::tuple<Args...>,false> : public Statistic<std::tuple<Args...>> {
61 
62  NullStatisticBase(BaseComponent* comp, const std::string& statName,
63  const std::string& statSubId, Params& statParams)
64  : Statistic<std::tuple<Args...>>(comp, statName, statSubId, statParams)
65  {
66  // Set the Name of this Statistic
67  this->setStatisticTypeName("NULL");
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 
75 template <class T>
76 struct NullStatisticBase<T,false> : public Statistic<T> {
77 
78  NullStatisticBase(BaseComponent* comp, const std::string& statName,
79  const std::string& statSubId, Params& statParams)
80  : Statistic<T>(comp, statName, statSubId, statParams)
81  {
82  // Set the Name of this Statistic
83  this->setStatisticTypeName("NULL");
84  }
85 
86  void addData_impl(T&& UNUSED(data)) override {}
87  void addData_impl(const T& UNUSED(data)) override {}
88 
89  void addData_impl(uint64_t UNUSED(N), T&& UNUSED(data)) override {}
90  void addData_impl(uint64_t UNUSED(N), const T& UNUSED(data)) override {}
91 };
92 
93 template <class T>
94 struct NullStatistic : public NullStatisticBase<T> {
95 
96  SST_ELI_DECLARE_STATISTIC_TEMPLATE(
98  "sst",
99  "NullStatistic",
100  SST_ELI_ELEMENT_VERSION(1,0,0),
101  "Null object it ignore all collections",
102  "SST::Statistic<T>")
103 
104  NullStatistic(BaseComponent* comp, const std::string& statName,
105  const std::string& statSubId, Params& statParam)
106  : NullStatisticBase<T>(comp, statName, statSubId, statParam)
107  {}
108 
109  ~NullStatistic(){}
110 
111  void clearStatisticData() override
112  {
113  // Do Nothing
114  }
115 
116  void registerOutputFields(StatisticFieldsOutput* UNUSED(statOutput)) override
117  {
118  // Do Nothing
119  }
120 
121  void outputStatisticFields(StatisticFieldsOutput* UNUSED(statOutput), bool UNUSED(EndOfSimFlag)) override
122  {
123  // Do Nothing
124  }
125 
126  bool isReady() const override
127  {
128  return true;
129  }
130 
131  bool isNullStatistic() const override
132  {
133  return true;
134  }
135 
136  static bool isLoaded() {
137  return loaded_;
138  }
139  private:
140  static bool loaded_;
141 };
142 
143 template <class T> bool NullStatistic<T>::loaded_ = true;
144 
145 template <>
146 struct NullStatistic<void> : public Statistic<void>
147 {
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,
160  const std::string& statSubId, Params& statParams)
161  : Statistic<void>(comp, statName, statSubId, statParams)
162  {
163  // Set the Name of this Statistic
164  this->setStatisticTypeName("NULL");
165  }
166 };
167 
168 
169 } //namespace Statistics
170 } //namespace SST
171 
172 #endif
Definition: statnull.h:146
Definition: statnull.h:41
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:42
void Statistic has special meaning in that it does not collect fields in the usual way through the ad...
Definition: statbase.h:428
An empty statistic place holder.
Definition: statnull.h:94
Definition: statoutput.h:144
Main component object for the simulation.
Definition: baseComponent.h:52
Parameter store.
Definition: params.h:44