SST 16.0.0
Structural Simulation Toolkit
configShared.h
1// Copyright 2009-2026 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-2026, 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 <cstdint>
20#include <cstdio>
21#include <iostream>
22#include <stdexcept>
23#include <string>
24
25
26namespace SST {
27
28/**
29 * Class to contain SST Simulation Configuration variables.
30 *
31 * NOTE: This class needs to be serialized for the sst.x executable,
32 * but not for the sst (wrapper compiled from the boot*.{h,cc} files)
33 * executable. To avoid having to compile all the serialization code
34 * into the bootstrap executable, the Config class is serialized in
35 * serialization/serialize_config.h.
36 */
38{
39 friend int ::main(int argc, char** argv);
40
41public:
42 virtual ~ConfigShared() {}
43
44 /**
45 ConfigShared constructor that it meant to be used when needing
46 a stand alone ConfigShared (i.e. for the bootstrap wrappers for
47 sst and sst-info
48 */
49 ConfigShared(bool suppress_print, bool include_libpath, bool include_env, bool include_verbose);
50
51protected:
52 void addLibraryPathOptions();
53 void addEnvironmentOptions();
54 void addVerboseOptions(bool sdl_avail);
55
56 ConfigShared() = default;
57
58
59private:
60 //// Libpath options
61
62
63 // lib path
64 SST_CONFIG_DECLARE_OPTION(std::string, libpath, "", &StandardConfigParsers::from_string<std::string>);
65
66 SST_CONFIG_DECLARE_OPTION(std::string, addLibPath, "",
67 std::bind(&StandardConfigParsers::append_string, ":", "", std::placeholders::_1, std::placeholders::_2));
68
69
70 //// Environment Options
71
72 SST_CONFIG_DECLARE_OPTION(bool, print_env, false, &StandardConfigParsers::flag_set_true);
73
74 SST_CONFIG_DECLARE_OPTION(bool, no_env_config, false, &StandardConfigParsers::flag_set_true);
75
76
77 //// Verbose Option
78 static int parse_verbosity(int32_t& val, std::string arg)
79 {
80 if ( arg == "" ) {
81 val++;
82 return 0;
83 }
84 try {
85 unsigned long value = stoul(arg);
86 val = value;
87 return 0;
88 }
89 catch ( const std::invalid_argument& e ) {
90 fprintf(stderr, "Failed to parse '%s' as number for option --verbose\n", arg.c_str());
91 return -1;
92 }
93 }
94
95 SST_CONFIG_DECLARE_OPTION(int32_t, verbose, 0, &ConfigShared::parse_verbosity);
96
97
98public:
99
100 std::string getLibPath(bool exclude_ext_paths = false) const;
101};
102
103} // namespace SST
104
105#endif // SST_CORE_CONFIGBASE_H
ConfigBase()
Default constructor used for serialization.
Definition configBase.h:591
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
std::string getLibPath(bool exclude_ext_paths=false) const
Get the library path for loading element libraries.
Definition configShared.cc:74