SST  12.0.1
StructuralSimulationToolkit
statoutputjson.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_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 protected:
43  /** Perform a check of provided parameters
44  * @return True if all required parameters and options are acceptable
45  */
46  bool checkOutputParameters() override;
47 
48  /** Print out usage for this Statistic Output */
49  void printUsage() override;
50 
51  /** Indicate to Statistic Output that simulation started.
52  * Statistic output may perform any startup code here as necessary.
53  */
54  void startOfSimulation() override;
55 
56  /** Indicate to Statistic Output that simulation ended.
57  * Statistic output may perform any shutdown code here as necessary.
58  */
59  void endOfSimulation() override;
60 
61  /** Implementation function for the start of output.
62  * This will be called by the Statistic Processing Engine to indicate that
63  * a Statistic is about to send data to the Statistic Output for processing.
64  * @param statistic - Pointer to the statistic object than the output can
65  * retrieve data from.
66  */
67  void implStartOutputEntries(StatisticBase* statistic) override;
68 
69  /** Implementation function for the end of output.
70  * This will be called by the Statistic Processing Engine to indicate that
71  * a Statistic is finished sending data to the Statistic Output for processing.
72  * The Statistic Output can perform any output related functions here.
73  */
74  void implStopOutputEntries() override;
75 
76  /** Implementation functions for output.
77  * These will be called by the statistic to provide Statistic defined
78  * data to be output.
79  * @param fieldHandle - The handle to the registered statistic field.
80  * @param data - The data related to the registered field to be output.
81  */
82  void outputField(fieldHandle_t fieldHandle, int32_t data) override;
83  void outputField(fieldHandle_t fieldHandle, uint32_t data) override;
84  void outputField(fieldHandle_t fieldHandle, int64_t data) override;
85  void outputField(fieldHandle_t fieldHandle, uint64_t data) override;
86  void outputField(fieldHandle_t fieldHandle, float data) override;
87  void outputField(fieldHandle_t fieldHandle, double data) override;
88 
89  void printIndent();
90 
91 protected:
92  StatisticOutputJSON() { ; } // For serialization
93 
94 private:
95  bool openFile();
96  void closeFile();
97 
98 private:
99  FILE* m_hFile;
100  std::string m_FilePath;
101  std::string m_currentComponentName;
102  std::string m_currentStatisticName;
103  std::string m_currentStatisticSubId;
104  std::string m_currentStatisticType;
105  bool m_outputSimTime;
106  bool m_outputRank;
107  bool m_firstEntry;
108  bool m_firstField;
109  bool m_processedAnyStats;
110  int m_curIndentLevel;
111 };
112 
113 } // namespace Statistics
114 } // namespace SST
115 
116 #endif // SST_CORE_STATAPI_STATOUTPUTJSON_H
The class for statistics output to a JSON formatted file.
Definition: statoutputjson.h:26
void printUsage() override
Print out usage for this Statistic Output.
Definition: statoutputjson.cc:67
Forms the base class for statistics output generation within the SST core.
Definition: statoutput.h:49
void implStartOutputEntries(StatisticBase *statistic) override
Implementation function for the start of output.
Definition: statoutputjson.cc:123
Forms the base class for statistics gathering within SST.
Definition: statbase.h:63
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.
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputjson.cc:169
Definition: statoutput.h:142
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:80
bool checkOutputParameters() override
Perform a check of provided parameters.
Definition: statoutputjson.cc:36
Parameter store.
Definition: params.h:55
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputjson.cc:101