CARMA C++
ImrConfigHandlers.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_UTIL_IMRCONFIGHANDLERS_H
11 #define CARMA_UTIL_IMRCONFIGHANDLERS_H
12 
13 #include <xercesc/sax/HandlerBase.hpp>
14 
15 #include <map>
16 #include <vector>
17 #include <string>
18 
19 namespace carma {
20 namespace util {
21 
22 typedef enum {
23  DATA,
24  MONITOR,
25  CONTROL,
26  INTERFEROMETRY,
27  CORRELATOR,
28  OVRO,
29  BIMA,
30  SZA,
31  MISC } SystemType;
32 
33 typedef std::map<SystemType, int> SystemTypeTotalsMap;
34 
38 struct ServerConfig {
39  std::string hostname;
40  std::string name;
41  std::string path;
42  std::string args;
43  std::string optargs;
44  std::string directory;
45  SystemType system;
46  int startup_priority; // Startup/shutdown priority
47  bool critical;
48 };
49 
50 typedef std::vector< ServerConfig > ServerVector;
51 
55 struct OADConfig {
56  std::string hostname;
57  SystemType system;
58  ServerVector servers;
59 };
60 
61 typedef std::vector< OADConfig > OadVector;
62 
66 typedef struct domainStruct {
67  unsigned nServers;
68  unsigned nCriticalServers;
69  OadVector oads;
70  SystemTypeTotalsMap nServersByType;
71 } domainType;
72 
76 domainType parseXmlConfig( const ::std::string & xmlFilename,
77  bool validateOnly,
78  bool verbose );
82 class ImrConfigHandlers : public xercesc::HandlerBase {
83 public:
84 
89 
94 
102 
106  void startDocument( );
107 
111  void startElement( const XMLCh * const name,
112  xercesc::AttributeList & attributes );
113 
117  void endElement( const XMLCh * const name );
118 
122  void endDocument( );
123 
127  void warning( const xercesc::SAXParseException & exception );
128 
132  void error( const xercesc::SAXParseException & exception );
133 
137  void fatalError( const xercesc::SAXParseException & exception );
138 
139 private:
140 
141  bool oadAlreadyExists( const std::string & oad );
142  void appendExistingOad( );
143 
144  ServerConfig currentServer_; // Current server
145  OADConfig currentOad_; // Current oad
146  domainType domain_; // Entire domain
147 
148 }; // End class ImrConfigHandlers
149 }} // End namespace carma::util;
150 #endif
void startDocument()
startDocument DocumentHandler overload
void endDocument()
endDocument DocumentHandler overload
Declares SAX Handlers for parsing XML Configuration files.
void error(const xercesc::SAXParseException &exception)
error SAX ErrorHandler implementation
Structure to hold oad which embeds servers.
domainType parseXmlConfig(const ::std::string &xmlFilename, bool validateOnly, bool verbose)
Parse XML Configuration File and return a structure containing domain.
Structure to hold IMR server definition.
Domain structure - holds it all.
void fatalError(const xercesc::SAXParseException &exception)
fatalError SAX ErrorHandler implementation
domainType getDomain()
Retrieve reference to vector containing servers.
void startElement(const XMLCh *const name, xercesc::AttributeList &attributes)
startElement DocumentHandler overload
void warning(const xercesc::SAXParseException &exception)
warning SAX ErrorHandler implementation
void endElement(const XMLCh *const name)
endElement DocumentHandler overload
struct carma::util::domainStruct domainType
Domain structure - holds it all.