SST 15.0
Structural Simulation Toolkit
configGraphOutput.h
1// Copyright 2009-2025 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-2025, 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#include "sst/core/util/filesystem.h"
18
19#include <cstdio>
20#include <cstdlib>
21#include <cstring>
22#include <exception>
23#include <map>
24#include <string>
25#include <vector>
26
27namespace SST {
28class ConfigGraph;
29
30namespace Core {
31
32/**
33 * Exception handler class for graph configuration.
34 * Provides the interface to handle errors through the throw exception.
35 */
36class ConfigGraphOutputException : public std::exception
37{
38public:
39 explicit ConfigGraphOutputException(const char* msg)
40 {
41 exMsg = (char*)malloc(sizeof(char) * (strlen(msg) + 1));
42 std::strcpy(exMsg, msg);
43 }
44
45 /**
46 * @return Exception Message
47 */
48 virtual const char* what() const noexcept override { return exMsg; }
49
50 /**
51 * Exception message generated on call.
52 */
53
54protected:
55 char* exMsg;
56};
57
58/**
59 * Outputs configuration data to a specified file path.
60 */
61class ConfigGraphOutput
62{
63public:
64 explicit ConfigGraphOutput(const char* path);
65
66 virtual ~ConfigGraphOutput() { fclose(outputFile); }
67
68 /**
69 * @param cfg Constant pointer to SST configuration
70 * @param graph Constant pointer to SST configuration graph
71 * @return void
72 */
73 virtual void generate(const Config* cfg, ConfigGraph* graph) = 0;
74
75protected:
76 FILE* outputFile;
77
78 /**
79 * Get a named shared parameter set.
80 *
81 * @param name Name of the set to get
82 *
83 * @return returns a copy of the reqeusted shared param set
84 *
85 */
86 static std::map<std::string, std::string> getSharedParamSet(const std::string& name)
87 {
88 return Params::getSharedParamSet(name);
89 }
90
91
92 [[deprecated("getGlobalParamSet() has been deprecated and will be removed in SST 16. Please use "
93 "getSharedParamSet()")]]
94 static std::map<std::string, std::string> getGlobalParamSet(const std::string& name)
95 {
96 return getSharedParamSet(name);
97 }
98 /**
99 * Get a vector of the names of available shared parameter sets.
100 *
101 * @return returns a vector of the names of available shared param
102 * sets
103 *
104 */
105 static std::vector<std::string> getSharedParamSetNames() { return Params::getSharedParamSetNames(); }
106
107 [[deprecated("getGlobalParamSetNames() has been deprecated and will be removed in SST 16. Please use "
108 "getSharedParamSetNames()")]]
109 static std::vector<std::string> getGlobalParamSetNames()
110 {
111 return getSharedParamSetNames();
112 }
113
114 /**
115 * Get a vector of the local keys
116 *
117 * @return returns a vector of the local keys in this Params
118 * object
119 *
120 */
121 std::vector<std::string> getParamsLocalKeys(const Params& params) const { return params.getLocalKeys(); }
122
123
124 /**
125 * Get a vector of the shared param sets this Params object is
126 * subscribed to
127 *
128 * @return returns a vector of the shared param sets his Params
129 * object is subscribed to
130 *
131 */
132 std::vector<std::string> getSubscribedSharedParamSets(const Params& params) const
133 {
134 return params.getSubscribedSharedParamSets();
135 }
136
137 [[deprecated("getSubscribedGlobalParamSets() has been deprecated and will be removed in SST 16. Please use "
138 "getSubscribedSharedParamSets()")]]
139 std::vector<std::string> getSubscribedGlobalParamSets(const Params& params) const
140 {
141 return getSubscribedSharedParamSets(params);
142 }
143};
144
145} // namespace Core
146} // namespace SST
147
148#endif // SST_CORE_CONFIGGRAPH_OUTPUT_H
A Configuration Graph A graph representing Components and Links.
Definition configGraph.h:450
Class to contain SST Simulation Configuration variables.
Definition config.h:41
char * exMsg
Exception message generated on call.
Definition configGraphOutput.h:55
virtual const char * what() const noexcept override
Definition configGraphOutput.h:48
std::vector< std::string > getParamsLocalKeys(const Params &params) const
Get a vector of the local keys.
Definition configGraphOutput.h:121
std::vector< std::string > getSubscribedSharedParamSets(const Params &params) const
Get a vector of the shared param sets this Params object is subscribed to.
Definition configGraphOutput.h:132
static std::vector< std::string > getSharedParamSetNames()
Get a vector of the names of available shared parameter sets.
Definition configGraphOutput.h:105
virtual void generate(const Config *cfg, ConfigGraph *graph)=0
static std::map< std::string, std::string > getSharedParamSet(const std::string &name)
Get a named shared parameter set.
Definition configGraphOutput.h:86
Parameter store.
Definition params.h:58