SST  8.0.0
StructuralSimulationToolkit
statoutputjson.h
1 // Copyright 2009-2018 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-2018, 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:
30  /** Construct a StatOutputJSON
31  * @param outputParameters - Parameters used for this Statistic Output
32  */
33  StatisticOutputJSON(Params& outputParameters);
34 
35 protected:
36  /** Perform a check of provided parameters
37  * @return True if all required parameters and options are acceptable
38  */
39  bool checkOutputParameters() override;
40 
41  /** Print out usage for this Statistic Output */
42  void printUsage() override;
43 
44  /** Indicate to Statistic Output that simulation started.
45  * Statistic output may perform any startup code here as necessary.
46  */
47  void startOfSimulation() override;
48 
49  /** Indicate to Statistic Output that simulation ended.
50  * Statistic output may perform any shutdown code here as necessary.
51  */
52  void endOfSimulation() override;
53 
54  /** Implementation function for the start of output.
55  * This will be called by the Statistic Processing Engine to indicate that
56  * a Statistic is about to send data to the Statistic Output for processing.
57  * @param statistic - Pointer to the statistic object than the output can
58  * retrieve data from.
59  */
60  void implStartOutputEntries(StatisticBase* statistic) override;
61 
62  /** Implementation function for the end of output.
63  * This will be called by the Statistic Processing Engine to indicate that
64  * a Statistic is finished sending data to the Statistic Output for processing.
65  * The Statistic Output can perform any output related functions here.
66  */
67  void implStopOutputEntries() override;
68 
69  /** Implementation functions for output.
70  * These will be called by the statistic to provide Statistic defined
71  * data to be output.
72  * @param fieldHandle - The handle to the registered statistic field.
73  * @param data - The data related to the registered field to be output.
74  */
75  void implOutputField(fieldHandle_t fieldHandle, int32_t data) override;
76  void implOutputField(fieldHandle_t fieldHandle, uint32_t data) override;
77  void implOutputField(fieldHandle_t fieldHandle, int64_t data) override;
78  void implOutputField(fieldHandle_t fieldHandle, uint64_t data) override;
79  void implOutputField(fieldHandle_t fieldHandle, float data) override;
80  void implOutputField(fieldHandle_t fieldHandle, double data) override;
81 
82  void printIndent();
83 
84 protected:
85  StatisticOutputJSON() {;} // For serialization
86 
87 private:
88  bool openFile();
89  void closeFile();
90 
91 private:
92  FILE* m_hFile;
93  std::string m_FilePath;
94  std::string m_currentComponentName;
95  std::string m_currentStatisticName;
96  std::string m_currentStatisticSubId;
97  std::string m_currentStatisticType;
98  bool m_outputSimTime;
99  bool m_outputRank;
100  bool m_firstEntry;
101  bool m_firstField;
102  bool m_processedAnyStats;
103  int m_curIndentLevel;
104 
105 };
106 
107 } //namespace Statistics
108 } //namespace SST
109 
110 #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:47
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:61
void implStopOutputEntries() override
Implementation function for the end of output.
Definition: statoutputjson.cc:169
void implOutputField(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:45
void endOfSimulation() override
Indicate to Statistic Output that simulation ended.
Definition: statoutputjson.cc:101