SST  9.1.0
StructuralSimulationToolkit
statnull.h
1 // Copyright 2009-2019 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-2019, 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 
57 template <class... Args>
58 struct NullStatisticBase<std::tuple<Args...>,false> : public Statistic<std::tuple<Args...>> {
59 
60  NullStatisticBase(BaseComponent* comp, const std::string& statName,
61  const std::string& statSubId, Params& statParams)
62  : Statistic<std::tuple<Args...>>(comp, statName, statSubId, statParams)
63  {
64  // Set the Name of this Statistic
65  this->setStatisticTypeName("NULL");
66  }
67 
68  void addData_impl(Args... UNUSED(data)) override {}
69 };
70 
71 template <class T>
72 struct NullStatisticBase<T,false> : public Statistic<T> {
73 
74  NullStatisticBase(BaseComponent* comp, const std::string& statName,
75  const std::string& statSubId, Params& statParams)
76  : Statistic<T>(comp, statName, statSubId, statParams)
77  {
78  // Set the Name of this Statistic
79  this->setStatisticTypeName("NULL");
80  }
81 
82  void addData_impl(T&& UNUSED(data)) override {}
83  void addData_impl(const T& UNUSED(data)) override {}
84 };
85 
86 template <class T>
87 struct NullStatistic : public NullStatisticBase<T> {
88 
89  SST_ELI_DECLARE_STATISTIC_TEMPLATE(
91  "sst",
92  "NullStatistic",
93  SST_ELI_ELEMENT_VERSION(1,0,0),
94  "Null object it ignore all collections",
95  "SST::Statistic<T>")
96 
97  NullStatistic(BaseComponent* comp, const std::string& statName,
98  const std::string& statSubId, Params& statParam)
99  : NullStatisticBase<T>(comp, statName, statSubId, statParam)
100  {}
101 
102  ~NullStatistic(){}
103 
104  void clearStatisticData() override
105  {
106  // Do Nothing
107  }
108 
109  void registerOutputFields(StatisticOutput* UNUSED(statOutput)) override
110  {
111  // Do Nothing
112  }
113 
114  void outputStatisticData(StatisticOutput* UNUSED(statOutput), bool UNUSED(EndOfSimFlag)) override
115  {
116  // Do Nothing
117  }
118 
119  bool isReady() const override
120  {
121  return true;
122  }
123 
124  bool isNullStatistic() const override
125  {
126  return true;
127  }
128 
129  static bool isLoaded() {
130  return loaded_;
131  }
132  private:
133  static bool loaded_;
134 };
135 
136 template <class T> bool NullStatistic<T>::loaded_ = true;
137 
138 } //namespace Statistics
139 } //namespace SST
140 
141 #endif
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:48
Definition: statnull.h:41
Forms the template defined base class for statistics gathering within SST.
Definition: elementinfo.h:43
An empty statistic place holder.
Definition: statnull.h:87
Main component object for the simulation.
Definition: baseComponent.h:52
Parameter store.
Definition: params.h:45