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