SST  13.0.0
StructuralSimulationToolkit
sstinfo.h
1 // Copyright 2009-2023 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-2023, 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_SST_INFO_H
13 #define SST_CORE_SST_INFO_H
14 
15 #include "sst/core/configShared.h"
16 #include "sst/core/eli/elementinfo.h"
17 
18 #include <map>
19 #include <set>
20 #include <vector>
21 
22 #include "tinyxml/tinyxml.h"
23 
24 class TiXmlNode;
25 
26 namespace SST {
27 
28 // CONFIGURATION BITS
29 #define CFG_OUTPUTHUMAN 0x00000001
30 #define CFG_OUTPUTXML 0x00000002
31 #define CFG_VERBOSE 0x00000004
32 
33 /**
34  * The SSTInfo Configuration class.
35  *
36  * This class will parse the command line, and setup internal
37  * lists of elements and components to be processed.
38  */
40 {
41 public:
42  typedef std::multimap<std::string, std::string> FilterMap_t;
43  /** Create a new SSTInfo configuration and parse the Command Line. */
44  SSTInfoConfig(bool suppress_print);
45  ~SSTInfoConfig();
46 
47  /** Return the list of elements to be processed. */
48  std::set<std::string> getElementsToProcessArray()
49  {
50  std::set<std::string> res;
51  for ( auto& i : m_filters )
52  res.insert(i.first);
53  return res;
54  }
55 
56  /** Return the filter map */
57  FilterMap_t& getFilterMap() { return m_filters; }
58 
59  /** Return the bit field of various command line options enabled. */
60  unsigned int getOptionBits() { return m_optionBits; }
61 
62  /** Return the user defined path the XML File. */
63  std::string& getXMLFilePath() { return m_XMLFilePath; }
64 
65  /** Is debugging output enabled? */
66  bool debugEnabled() const { return m_debugEnabled; }
67  bool processAllElements() const { return m_filters.empty(); }
68  bool doVerbose() const { return m_optionBits & CFG_VERBOSE; }
69 
70 protected:
71  std::string getUsagePrelude() override;
72 
73 private:
74  void outputUsage();
75  void addFilter(const std::string& name);
76 
77  int setPositionalArg(int UNUSED(num), const std::string& arg)
78  {
79  addFilter(arg);
80  return 0;
81  }
82 
83  // Functions to set options
84  int printHelp(const std::string& UNUSED(arg))
85  {
86  printUsage();
87  return 1;
88  }
89 
90  int outputVersion(const std::string& UNUSED(arg))
91  {
92  fprintf(stderr, "SST Release Version %s\n", PACKAGE_VERSION);
93  return 1;
94  }
95 
96  int setEnableDebug(const std::string& UNUSED(arg))
97  {
98  m_debugEnabled = true;
99  return 0;
100  }
101 
102  int setNoDisplay(const std::string& UNUSED(arg))
103  {
104  m_optionBits &= ~CFG_OUTPUTHUMAN;
105  return 0;
106  }
107 
108  int setXML(const std::string& UNUSED(arg))
109  {
110  m_optionBits |= CFG_OUTPUTXML;
111  return 0;
112  }
113 
114  int setXMLOutput(const std::string& UNUSED(arg))
115  {
116  m_XMLFilePath = arg;
117  return 0;
118  }
119 
120  int setLibs(const std::string& UNUSED(arg))
121  {
122  addFilter(arg);
123  return 0;
124  }
125 
126  int setQuiet(const std::string& UNUSED(arg))
127  {
128  m_optionBits &= ~CFG_VERBOSE;
129  return 0;
130  }
131 
132 private:
133  char* m_AppName;
134  std::vector<std::string> m_elementsToProcess;
135  unsigned int m_optionBits;
136  std::string m_XMLFilePath;
137  bool m_debugEnabled;
138  FilterMap_t m_filters;
139 };
140 
141 /**
142  * The SSTInfo representation of ElementLibraryInfo object.
143  *
144  * This class is used internally by SSTInfo to load and process
145  * ElementLibraryInfo objects.
146  */
148 {
149 
150 public:
151  /** Create a new SSTInfoElement_LibraryInfo object.
152  * @param eli Pointer to an ElementLibraryInfo object.
153  */
154  SSTLibraryInfo(const std::string& name) : m_name(name) {}
155 
156  /** Return the Name of the Library. */
157  // std::string getLibraryName() {if (m_eli && m_eli->name) return m_eli->name; else return ""; }
158  std::string getLibraryName() { return m_name; }
159 
160  /** Output the Library Information.
161  * @param LibIndex The Index of the Library.
162  */
163  void outputHumanReadable(std::ostream& os, int LibIndex);
164 
165  /** Create the formatted XML data of the Library.
166  * @param LibIndex The Index of the Library.
167  * @param XMLParentElement The parent element to receive the XML data.
168  */
169  void outputXML(int Index, TiXmlNode* XMLParentElement);
170 
171  template <class BaseType>
172  void outputHumanReadable(std::ostream& os, bool printAll);
173  template <class BaseType>
174  void outputXML(TiXmlElement* node);
175 
176  std::string getLibraryDescription() { return ""; }
177 
178 private:
179  std::string m_name;
180 };
181 
182 } // namespace SST
183 
184 #endif // SST_CORE_SST_INFO_H
void outputXML(int Index, TiXmlNode *XMLParentElement)
Create the formatted XML data of the Library.
Definition: sstinfo.cc:489
SSTInfoConfig(bool suppress_print)
Create a new SSTInfo configuration and parse the Command Line.
Definition: sstinfo.cc:249
Class to contain SST Simulation Configuration variables.
Definition: configShared.h:33
Definition: action.cc:18
bool debugEnabled() const
Is debugging output enabled?
Definition: sstinfo.h:66
The SSTInfo Configuration class.
Definition: sstinfo.h:39
int printUsage()
Called to print the help/usage message.
Definition: configBase.cc:125
std::string & getXMLFilePath()
Return the user defined path the XML File.
Definition: sstinfo.h:63
SSTLibraryInfo(const std::string &name)
Create a new SSTInfoElement_LibraryInfo object.
Definition: sstinfo.h:154
unsigned int getOptionBits()
Return the bit field of various command line options enabled.
Definition: sstinfo.h:60
std::set< std::string > getElementsToProcessArray()
Return the list of elements to be processed.
Definition: sstinfo.h:48
std::string getLibraryName()
Return the Name of the Library.
Definition: sstinfo.h:158
std::string getUsagePrelude() override
Called to get the prelude for the help/usage message.
Definition: sstinfo.cc:291
The SSTInfo representation of ElementLibraryInfo object.
Definition: sstinfo.h:147
void outputHumanReadable(std::ostream &os, int LibIndex)
Output the Library Information.
Definition: sstinfo.cc:451
FilterMap_t & getFilterMap()
Return the filter map.
Definition: sstinfo.h:57