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