SST 15.0
Structural Simulation Toolkit
configShared.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_CONFIGSHARED_H
13#define SST_CORE_CONFIGSHARED_H
14
15#include "sst/core/configBase.h"
16#include "sst/core/sst_types.h"
17#include "sst/core/warnmacros.h"
18
19#include <iostream>
20
21
22namespace SST {
23
24/**
25 * Class to contain SST Simulation Configuration variables.
26 *
27 * NOTE: This class needs to be serialized for the sst.x executable,
28 * but not for the sst (wrapper compiled from the boot*.{h,cc} files)
29 * executable. To avoid having to compile all the serialization code
30 * into the bootstrap executable, the Config class is serialized in
31 * serialization/serialize_config.h.
32 */
34{
35public:
36 virtual ~ConfigShared() {}
37
38 /**
39 ConfigShared constructor that it meant to be used when needing
40 a stand alone ConfigShared (i.e. for the bootstrap wrappers for
41 sst and sst-info
42 */
43 ConfigShared(bool suppress_print, bool include_libpath, bool include_env, bool include_verbose);
44
45protected:
46 void addLibraryPathOptions();
47 void addEnvironmentOptions();
48 void addVerboseOptions(bool sdl_avail);
49
50 /**
51 ConfigShared constructor for child classes
52 */
53 ConfigShared(bool suppress_print, std::vector<AnnotationInfo> annotations);
54
55 /**
56 Default constructor used for serialization. At this point,
57 my_rank is no longer needed, so just initialize to 0,0.
58 */
61 {}
62
63 // Variables that will need to be serialized by child class since
64 // this class does not serialize itself due to being used in the
65 // bootwrapper executables.
66
67 //// Libpath options
68 std::string libpath_ = "";
69 std::string addlibpath_ = "";
70
71 //// Environment Options
72 bool print_env_ = false;
73 bool no_env_config_ = false;
74
75 //// Verbose Option
76 int verbose_ = 0;
77
78private:
79 //// Libpath options
80
81 // lib path
82 int setLibPath(const std::string& arg)
83 {
84 libpath_ = arg;
85 return 0;
86 }
87
88 // add to lib path
89 int setAddLibPath(const std::string& arg)
90 {
91 if ( addlibpath_.length() > 0 ) addlibpath_ += std::string(":");
92 addlibpath_ += arg;
93 return 0;
94 }
95
96 //// Environment Options
97
98 int enablePrintEnv(const std::string& UNUSED(arg))
99 {
100 printf("enablePrintEnv()\n");
101 print_env_ = true;
102 return 0;
103 }
104
105 int disableEnvConfig(const std::string& UNUSED(arg))
106 {
107 printf("disableEnvConfig()\n");
108 no_env_config_ = true;
109 return 0;
110 }
111
112 //// Verbose Option
113
114 int setVerbosity(const std::string& arg)
115 {
116 if ( arg == "" ) {
117 verbose_++;
118 return 0;
119 }
120 try {
121 unsigned long val = stoul(arg);
122 verbose_ = val;
123 return 0;
124 }
125 catch ( std::invalid_argument& e ) {
126 fprintf(stderr, "Failed to parse '%s' as number for option --verbose\n", arg.c_str());
127 return -1;
128 }
129 }
130
131
132public:
133 /**
134 Controls whether the environment variables that SST sees are
135 printed out
136 */
137 bool print_env() const { return print_env_; }
138
139 bool no_env_config() const { return no_env_config_; }
140
141 int verbose() const { return verbose_; }
142
143 std::string libpath() const { return libpath_; }
144 std::string addLibPath() const { return addlibpath_; }
145
146 std::string getLibPath() const;
147};
148
149} // namespace SST
150
151#endif // SST_CORE_CONFIGBASE_H
ConfigBase(bool suppress_print)
ConfigBase constructor.
Definition configBase.h:115
bool print_env() const
Controls whether the environment variables that SST sees are printed out.
Definition configShared.h:137
std::string getLibPath() const
Get the library path for loading element libraries.
Definition configShared.cc:81
ConfigShared(bool suppress_print, bool include_libpath, bool include_env, bool include_verbose)
ConfigShared constructor that it meant to be used when needing a stand alone ConfigShared (i....
Definition configShared.cc:23
ConfigShared()
Default constructor used for serialization.
Definition configShared.h:59