SST 16.0.0
Structural Simulation Toolkit
sstmodel.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_MODEL_SSTMODEL_H
13#define SST_CORE_MODEL_SSTMODEL_H
14
15#include "sst/core/eli/elementinfo.h"
16#include "sst/core/params.h"
17#include "sst/core/warnmacros.h"
18
19#include <string>
20#include <vector>
21
22namespace SST {
23
24class Config;
25class ConfigGraph;
26
27#define STATALLFLAG "--ALLSTATS--"
28
29/** Base class for Model Generation
30 */
31class SSTModelDescription
32{
33
34public:
35 SST_ELI_DECLARE_BASE(SSTModelDescription)
36 // declare extern to limit compile times
37 SST_ELI_DECLARE_CTOR_EXTERN(const std::string&, int, Config*, double)
38 SST_ELI_DECLARE_INFO_EXTERN(
40 ELI::ProvidesSimpleInfo<1,std::vector<std::string>>)
41
42 // Helper functions to pull out ELI data for an element
43 static bool isElementParallelCapable(const std::string& type);
44 static const std::vector<std::string>& getElementSupportedExtensions(const std::string& type);
45
46 explicit SSTModelDescription(Config* cfg);
47 virtual ~SSTModelDescription() {};
48
49 /** Create the ConfigGraph
50 *
51 * This function should be overridden by subclasses.
52 *
53 * This function is responsible for reading any configuration
54 * files and generating a ConfigGraph object.
55 */
57
58
59protected:
60 /** Set a configuration string to update configuration values */
61 bool setOptionFromModel(const std::string& entryName, const std::string& value);
62
63 /**
64 * Sets the model options field of the Config object. This has a
65 * very narrow use case, which is to set the model_options when
66 * the model is just a wrapper to another model type and they need
67 * to pass some extra options.
68 *
69 * @param options String that will be used for model_options. It
70 * will overwrite what is alread there
71 */
72 void setModelOptions(const std::string& options);
73
74 /**
75 * Allows ModelDefinition to set global parameters.
76 *
77 * @param set Name of the global param set to add key/value pair to
78 *
79 * @param key Key of key/value pair to be added
80 *
81 * @param key Value of key/value pair to be added
82 *
83 * @param overwrite Overwrite existing value if set to true (which is default)
84 */
86 const std::string& set, const Params::key_type& key, const Params::key_type& value, bool overwrite = true);
87
88
89private:
90 Config* config;
91};
92
93} // namespace SST
94
95
96// Use this macro to register a model description. Parallel_capable
97// indicates whether this model is able to be use when loading in
98// parallel. The final arguments are optional and are a list of file
99// extensions handled by the model. These are only useful for the
100// built-in models as external models will have to use the command
101// line option to load them and then the extension will be ignored.
102#define SST_ELI_REGISTER_MODEL_DESCRIPTION(cls, lib, name, version, desc, parallel_capable) \
103 SST_ELI_REGISTER_DERIVED(SST::SSTModelDescription, ::cls,lib,name,ELI_FORWARD_AS_ONE(version),desc) \
104 SST_ELI_DOCUMENT_SIMPLE_INFO(bool,0,parallel_capable)
105
106#define SST_ELI_DOCUMENT_MODEL_SUPPORTED_EXTENSIONS(...) \
107 SST_ELI_DOCUMENT_SIMPLE_INFO(std::vector<std::string>,1,__VA_ARGS__)
108
109#endif // SST_CORE_MODEL_SSTMODEL_H
A Configuration Graph A graph representing Components and Links.
Definition configGraph.h:76
Class to contain SST Simulation Configuration variables.
Definition config.h:52
Definition simpleInfo.h:88
std::string key_type
Definition params.h:243
void setModelOptions(const std::string &options)
Sets the model options field of the Config object.
Definition sstmodel.cc:35
virtual ConfigGraph * createConfigGraph()=0
Create the ConfigGraph.
void insertGlobalParameter(const std::string &set, const Params::key_type &key, const Params::key_type &value, bool overwrite=true)
Allows ModelDefinition to set global parameters.
Definition sstmodel.cc:41
bool setOptionFromModel(const std::string &entryName, const std::string &value)
Set a configuration string to update configuration values.
Definition sstmodel.cc:29