SST  12.0.1
StructuralSimulationToolkit
configGraphOutput.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_CONFIGGRAPH_OUTPUT_H
13 #define SST_CORE_CONFIGGRAPH_OUTPUT_H
14 
15 #include "sst/core/configGraph.h"
16 #include "sst/core/params.h"
17 
18 #include <cstdio>
19 #include <exception>
20 
21 namespace SST {
22 class ConfigGraph;
23 
24 namespace Core {
25 
26 class ConfigGraphOutputException : public std::exception
27 {
28 public:
29  ConfigGraphOutputException(const char* msg)
30  {
31  exMsg = (char*)malloc(sizeof(char) * (strlen(msg) + 1));
32  std::strcpy(exMsg, msg);
33  }
34 
35  virtual const char* what() const noexcept override { return exMsg; }
36 
37 protected:
38  char* exMsg;
39 };
40 
42 {
43 public:
44  ConfigGraphOutput(const char* path) { outputFile = fopen(path, "wt"); }
45 
46  virtual ~ConfigGraphOutput() { fclose(outputFile); }
47 
48  virtual void generate(const Config* cfg, ConfigGraph* graph) = 0;
49 
50 protected:
51  FILE* outputFile;
52 
53  /**
54  * Get a named global parameter set.
55  *
56  * @param name Name of the set to get
57  *
58  * @return returns a copy of the reqeusted global param set
59  *
60  */
61  static std::map<std::string, std::string> getGlobalParamSet(const std::string& name)
62  {
63  return Params::getGlobalParamSet(name);
64  }
65 
66 
67  /**
68  * Get a vector of the names of available global parameter sets.
69  *
70  * @return returns a vector of the names of available global param
71  * sets
72  *
73  */
74  static std::vector<std::string> getGlobalParamSetNames() { return Params::getGlobalParamSetNames(); }
75 
76 
77  /**
78  * Get a vector of the local keys
79  *
80  * @return returns a vector of the local keys in this Params
81  * object
82  *
83  */
84  std::vector<std::string> getParamsLocalKeys(const Params& params) const { return params.getLocalKeys(); }
85 
86 
87  /**
88  * Get a vector of the global param sets this Params object is
89  * subscribed to
90  *
91  * @return returns a vector of the global param sets his Params
92  * object is subscribed to
93  *
94  */
95  std::vector<std::string> getSubscribedGlobalParamSets(const Params& params) const
96  {
97  return params.getSubscribedGlobalParamSets();
98  }
99 };
100 
101 } // namespace Core
102 } // namespace SST
103 
104 #endif // SST_CORE_CONFIGGRAPH_OUTPUT_H
Definition: configGraphOutput.h:41
Class to contain SST Simulation Configuration variables.
Definition: config.h:29
std::vector< std::string > getParamsLocalKeys(const Params &params) const
Get a vector of the local keys.
Definition: configGraphOutput.h:84
A Configuration Graph A graph representing Components and Links.
Definition: configGraph.h:389
Definition: configGraphOutput.h:26
std::vector< std::string > getSubscribedGlobalParamSets(const Params &params) const
Get a vector of the global param sets this Params object is subscribed to.
Definition: configGraphOutput.h:95
static std::map< std::string, std::string > getGlobalParamSet(const std::string &name)
Get a named global parameter set.
Definition: configGraphOutput.h:61
Parameter store.
Definition: params.h:55
static std::vector< std::string > getGlobalParamSetNames()
Get a vector of the names of available global parameter sets.
Definition: configGraphOutput.h:74