SST  6.0.0
StructuralSimulationToolkit
envconfig.h
1 
2 #ifndef _H_SST_CORE_ENV_CONFIG_H
3 #define _H_SST_CORE_ENV_CONFIG_H
4 
5 #include <string>
6 #include <map>
7 #include <set>
8 #include <vector>
9 #include <iostream>
10 #include <cstdio>
11 #include <cstdlib>
12 #include <climits>
13 
14 namespace SST {
15 namespace Core {
16 namespace Environment {
17 
18 /***
19 \class EnvironmentConfigGroup envconfig.h "sst/core/env/envconfig.h"
20 
21 Specifies a class which contains a group of key=value pairs. A group
22 is a logical unit of management for collecting configuration parameters.
23 For instance, these might relate to an specific dependency or element
24 etc.
25 
26 Grouping of key=value pairs allows entire lists of parameters to be
27 removed from the configuration system when needed.
28 
29 In general the core expects to default to either the "default" group
30 or the "SSTCore" group, with the configuration populating the "SSTCore"
31 group with parameters during the initial configure script process.
32 
33 The configuration and management systems treat the "default" and
34 "SSTCore" groups with special handling and no guarantee is provided
35 that these settings can be modified, removed or added to (since they
36 may be held in configuration files that are not accessible to the
37 user).
38 
39 Groups also allow printing (to standard output) or files directly
40 of all members.
41 
42 Although a logical interface may be the utilization of a map, groups
43 do not expose this currently to allow for modification in the
44 implementation in the future when more complex schemes are expected
45 to be used. Users of the group class should use the public accessor
46 methods provided to ensure forwards compatibility with future
47 SST releases.
48 
49 */
50 
52 
53 public:
54  EnvironmentConfigGroup(std::string name) : groupName(name) {}
55  std::string getName() const;
56  std::set<std::string> getKeys() const;
57  std::string getValue(std::string key);
58  void setValue(std::string key, std::string value);
59  void print();
60  void writeTo(FILE* outFile);
61 
62 protected:
63  std::string groupName;
64  std::map<std::string, std::string> params;
65 
66 };
67 
68 
69 /***
70 \class EnvironmentConfiguration envconfig.h "sst/core/env/envconfig.h"
71 
72 The EnvironmentConfiguration class provides an entire configuration
73 set for SST, which will include zero or more EnvironmentConfigGroup
74 instances (essentially zero or more groups). In the usual course of
75 operations the environment will contains two "special" groups called
76 "default" (unpopulated but is provided for any ungrouped parameter
77 values) and "SSTCore" which houses parameters encoded during the
78 core's configuration process.
79 
80 EnvironmentConfiguration instances can be loaded from a single file
81 or via the standard precedence ordered SST loading mechanisms. In the
82 case of loading from a specific file, the core makes no guarantees
83 about the number of groups provided (zero or more). The user should
84 make no assumptions in this case.
85 
86 If the EnvironmentConfiguration is loaded via the SST precedence
87 ordered mechnaisms, then the "default" and "SSTCore" groups will be
88 provided.
89 
90 Although it may seem logical to provide a map structure of group
91 names to group instances, the design is not implemented this way
92 to permit future modification in the underlying structures. Users
93 should use the public methods provided to ensure future compatibility
94 with SST releases.
95 
96 */
98 
99 public:
102 
103  EnvironmentConfigGroup* createGroup(std::string groupName);
104  void removeGroup(std::string groupName);
105  std::set<std::string> getGroupNames();
106  EnvironmentConfigGroup* getGroupByName(std::string groupName);
107  void print();
108  void writeTo(std::string filePath);
109  void writeTo(FILE* outFile);
110 
111 private:
112  std::map<std::string, EnvironmentConfigGroup*> groups;
113 
114 };
115 
116 }
117 }
118 }
119 
120 #endif
Definition: action.cc:17