SST  14.1.0
StructuralSimulationToolkit
statoutputjson.h
1 // Copyright 2009-2024 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-2024, 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_STATOUTPUTJSON_H
13 #define SST_CORE_STATAPI_STATOUTPUTJSON_H
14 
15 #include "sst/core/sst_types.h"
16 #include "sst/core/statapi/statoutput.h"
17 
18 namespace SST {
19 namespace Statistics {
20 
21 /**
22  \class StatisticOutputJSON
23 
24  The class for statistics output to a JSON formatted file
25 */
27 {
28 public:
32  "sst",
33  "statoutputjson",
34  SST_ELI_ELEMENT_VERSION(1,0,0),
35  "Output to a JSON file")
36 
37  /** Construct a StatOutputJSON
38  * @param outputParameters - Parameters used for this Statistic Output
39  */
40  StatisticOutputJSON(Params& outputParameters);
41 
42  void serialize_order(SST::Core::Serialization::serializer& ser) override;
43  ImplementSerializable(SST::Statistics::StatisticOutputJSON)
44 
45 protected:
46  /** Perform a check of provided parameters
47  * @return True if all required parameters and options are acceptable
48  */
49  bool checkOutputParameters() override;
50 
51  /** Print out usage for this Statistic Output */
52  void printUsage() override;
53 
54  /** Indicate to Statistic Output that simulation started.
55  * Statistic output may perform any startup code here as necessary.
56  */
57  void startOfSimulation() override;
58 
59  /** Indicate to Statistic Output that simulation ended.
60  * Statistic output may perform any shutdown code here as necessary.
61  */
62  void endOfSimulation() override;
63 
64  /** Implementation function for the start of output.
65  * This will be called by the Statistic Processing Engine to indicate that
66  * a Statistic is about to send data to the Statistic Output for processing.
67  * @param statistic - Pointer to the statistic object than the output can
68  * retrieve data from.
69  */
70  void implStartOutputEntries(StatisticBase* statistic) override;
71 
72  /** Implementation function for the end of output.
73  * This will be called by the Statistic Processing Engine to indicate that
74  * a Statistic is finished sending data to the Statistic Output for processing.
75  * The Statistic Output can perform any output related functions here.
76  */
77  void implStopOutputEntries() override;
78 
79  /** Implementation functions for output.
80  * These will be called by the statistic to provide Statistic defined
81  * data to be output.
82  * @param fieldHandle - The handle to the registered statistic field.
83  * @param data - The data related to the registered field to be output.
84  */
85  void outputField(fieldHandle_t fieldHandle, int32_t data) override;
86  void outputField(fieldHandle_t fieldHandle, uint32_t data) override;
87  void outputField(fieldHandle_t fieldHandle, int64_t data) override;
88  void outputField(fieldHandle_t fieldHandle, uint64_t data) override;
89  void outputField(fieldHandle_t fieldHandle, float data) override;
90  void outputField(fieldHandle_t fieldHandle, double data) override;
91 
92  void printIndent();
93 
94 protected:
96  m_currentComponentName(""),
97  m_firstEntry(false),
98  m_processedAnyStats(false),
99  m_curIndentLevel(0)
100  {
101  ;
102  } // For serialization
103 
104 private:
105  bool openFile();
106  void closeFile();
107 
108 private:
109  FILE* m_hFile;
110  std::string m_FilePath;
111  std::string m_currentComponentName;
112  std::string m_currentStatisticName;
113  std::string m_currentStatisticSubId;
114  std::string m_currentStatisticType;
115  bool m_outputSimTime;
116  bool m_outputRank;
117  bool m_firstEntry;
118  bool m_firstField;
119  bool m_processedAnyStats;
120  int m_curIndentLevel;
121 };
122 
123 } // namespace Statistics
124 } // namespace SST
125 
126 #endif // SST_CORE_STATAPI_STATOUTPUTJSON_H
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition: serializer.h:43
The class for statistics output to a JSON formatted file.
Definition: statoutputjson.h:26
ImplementSerializable(SST::Statistics::StatisticOutputJSON) protected void printUsage() override
Perform a check of provided parameters.
Definition: statoutputjson.cc:64
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:50
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputjson.cc:120
Forms the base class for statistics gathering within SST.
Definition: statbase.h:45
Definition: action.cc:18
virtual bool checkOutputParameters()=0
Have the Statistic Output check its parameters.
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputjson.cc:168
Definition: statoutput.h:162
void outputField(fieldHandle_t fieldHandle, int32_t data) override
Implementation functions for output.
void startOfSimulation() override
Indicate to Statistic Output that simulation started.
Definition: statoutputjson.cc:77
Parameter store.
Definition: params.h:55
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputjson.cc:98
SST_ELI_REGISTER_DERIVED(StatisticOutput, StatisticOutputJSON, "sst", "statoutputjson", SST_ELI_ELEMENT_VERSION(1, 0, 0), "Output to a JSON file") StatisticOutputJSON(Params &outputParameters)
Construct a StatOutputJSON.