SST  10.0.0
StructuralSimulationToolkit
sstinfo.h
1 // Copyright 2009-2020 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-2020, 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 
13 #ifndef SST_INFO_H
14 #define SST_INFO_H
15 
16 #include <map>
17 #include <vector>
18 #include <set>
19 
20 #include "sst/core/eli/elementinfo.h"
21 #include "sst/core/tinyxml/tinyxml.h"
22 
23 class TiXmlNode;
24 
25 namespace SST {
26 
27 // CONFIGURATION BITS
28 #define CFG_OUTPUTHUMAN 0x00000001
29 #define CFG_OUTPUTXML 0x00000002
30 #define CFG_VERBOSE 0x00000004
31 
32 /**
33  * The SSTInfo Configuration class.
34  *
35  * This class will parse the command line, and setup internal
36  * lists of elements and components to be processed.
37  */
39 public:
40  typedef std::multimap<std::string, std::string> FilterMap_t;
41  /** Create a new SSTInfo configuration and parse the Command Line. */
42  SSTInfoConfig();
43  ~SSTInfoConfig();
44 
45  /** Parse the Command Line.
46  * @param argc The number of arguments passed to the application
47  * @param argv The array of arguments
48  */
49  int parseCmdLine(int argc, char* argv[]);
50 
51  /** Return the list of elements to be processed. */
52  std::set<std::string> getElementsToProcessArray()
53  {
54  std::set<std::string> res;
55  for ( auto &i : m_filters )
56  res.insert(i.first);
57  return res;
58  }
59 
60  /** Return the filter map */
61  FilterMap_t& getFilterMap() { return m_filters; }
62 
63  /** Return the bit field of various command line options enabled. */
64  unsigned int getOptionBits() {return m_optionBits;}
65 
66  /** Return the user defined path the XML File. */
67  std::string& getXMLFilePath() {return m_XMLFilePath;}
68 
69  /** Is debugging output enabled? */
70  bool debugEnabled() const { return m_debugEnabled; }
71  bool processAllElements() const { return m_filters.empty(); }
72  bool doVerbose() const { return m_optionBits & CFG_VERBOSE; }
73 
74 private:
75  void outputUsage();
76  void outputVersion();
77  void addFilter(const std::string& name);
78 
79 private:
80  char* m_AppName;
81  std::vector<std::string> m_elementsToProcess;
82  unsigned int m_optionBits;
83  std::string m_XMLFilePath;
84  bool m_debugEnabled;
85  FilterMap_t m_filters;
86 };
87 
88 /**
89  * The SSTInfo representation of ElementLibraryInfo object.
90  *
91  * This class is used internally by SSTInfo to load and process
92  * ElementLibraryInfo objects.
93  */
95 
96 public:
97  /** Create a new SSTInfoElement_LibraryInfo object.
98  * @param eli Pointer to an ElementLibraryInfo object.
99  */
100  SSTLibraryInfo(const std::string& name) :
101  m_name(name)
102  {
103  }
104 
105  /** Return the Name of the Library. */
106  // std::string getLibraryName() {if (m_eli && m_eli->name) return m_eli->name; else return ""; }
107  std::string getLibraryName() {return m_name; }
108 
109  /** Output the Library Information.
110  * @param LibIndex The Index of the Library.
111  */
112  void outputHumanReadable(std::ostream& os, int LibIndex);
113 
114  /** Create the formatted XML data of the Library.
115  * @param LibIndex The Index of the Library.
116  * @param XMLParentElement The parent element to receive the XML data.
117  */
118  void outputXML(int Index, TiXmlNode* XMLParentElement);
119 
120  template <class BaseType> void outputHumanReadable(std::ostream& os, bool printAll);
121  template <class BaseType> void outputXML(TiXmlElement* node);
122 
123  std::string getLibraryDescription() {
124  return "";
125  }
126 
127  private:
128  std::string m_name;
129 
130 };
131 
132 
133 } // namespace SST
134 
135 #endif // SST_INFO_H
void outputXML(int Index, TiXmlNode *XMLParentElement)
Create the formatted XML data of the Library.
Definition: sstinfo.cc:481
The SSTInfo Configuration class.
Definition: sstinfo.h:38
bool debugEnabled() const
Is debugging output enabled?
Definition: sstinfo.h:70
std::string & getXMLFilePath()
Return the user defined path the XML File.
Definition: sstinfo.h:67
SSTLibraryInfo(const std::string &name)
Create a new SSTInfoElement_LibraryInfo object.
Definition: sstinfo.h:100
SSTInfoConfig()
Create a new SSTInfo configuration and parse the Command Line.
Definition: sstinfo.cc:284
int parseCmdLine(int argc, char *argv[])
Parse the Command Line.
Definition: sstinfo.cc:314
unsigned int getOptionBits()
Return the bit field of various command line options enabled.
Definition: sstinfo.h:64
std::set< std::string > getElementsToProcessArray()
Return the list of elements to be processed.
Definition: sstinfo.h:52
std::string getLibraryName()
Return the Name of the Library.
Definition: sstinfo.h:107
The SSTInfo representation of ElementLibraryInfo object.
Definition: sstinfo.h:94
void outputHumanReadable(std::ostream &os, int LibIndex)
Output the Library Information.
Definition: sstinfo.cc:445
FilterMap_t & getFilterMap()
Return the filter map.
Definition: sstinfo.h:61