Salome HOME
PR: merge from tag mergeto_trunk_20Jan05
[modules/kernel.git] / src / ResourcesManager / SALOME_ResourcesCatalog_Handler.hxx
1 //  SALOME ResourcesCatalog : implementation of catalog resources parsing (SALOME_ModuleCatalog.idl)
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOME_ResourcesCatalog_Handler.hxx
25 //  Author : Estelle Deville
26 //  Module : SALOME
27 //$Header$
28
29 #ifndef SALOME_RESOURCES_CATALOG_HANDLER
30 #define SALOME_RESOURCES_CATALOG_HANDLER
31
32 #include "SALOME_ResourcesCatalog_Parser.hxx"
33
34 #include <qxml.h>
35 #include <string>
36 #include <vector>
37
38 class QDomElement;
39 class QDomDocument;
40
41 class SALOME_ResourcesCatalog_Handler : public QXmlDefaultHandler
42 {
43 public :
44   //! standard constructor
45   SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& listOfResources);
46
47   const MapOfParserResourcesType& GetResourcesAfterParsing() const;
48
49   //! standard destructor
50   virtual ~SALOME_ResourcesCatalog_Handler();
51
52   //! method to overload handler function startDocument
53   /*! is called before a xml file is parsed
54     \return true if no error was detected
55   */
56   virtual bool startDocument();
57
58   //! method to overload handler function startElement
59   /*!
60     \param QString argument by value
61     \param QString argument by value
62     \param QString qName argument by value
63     \param QXmlAttributes atts argument by value
64     \return true if no error was detected
65   */
66   virtual bool startElement(const QString& , const QString& ,
67                             const QString& name, const QXmlAttributes& attrs);
68
69  //! method to overload handler function endElement
70   /*!
71     \param QString argument by value
72     \param QString argument by value
73     \param QString qName argument by value
74     \return true if no error was detected
75   */
76   virtual bool endElement(const QString&, const QString&,
77                           const QString& qName);
78
79  //! method to overload handler function characters
80   /*!
81     \param QString chars argument by value
82     \return true if no error was detected
83   */
84   virtual bool characters(const QString& chars);
85
86  //! method to overload handler function endDocument
87   /*! is called at the end of the parsing
88     \return true if no error was detected
89   */
90   virtual bool endDocument();
91
92  //! method to overload handler function errorProtocol
93   /*!
94     \return the error message
95   */
96   virtual QString errorProtocol();
97
98 //! method to overload handler function fatalError
99   /*!
100     \param QXmlParseException exception argument by value
101     \return true if no error was detected
102   */
103   virtual bool fatalError(const QXmlParseException& exception);
104
105 //! method to fill the document to be writen in a file
106   void PrepareDocToXmlFile(QDomDocument& doc);
107
108 private :
109   QString errorProt;
110   std::string content;
111   std::string previous_module_name;
112   std::string previous_module_path;
113
114   ParserResourcesType _resource;
115   MapOfParserResourcesType& _resources_list;
116
117   const char *test_machine;
118   const char *test_resources;
119
120   const char *test_hostname;
121   const char *test_alias;
122   const char *test_protocol;
123   const char *test_mode;
124   const char *test_user_name;
125   const char *test_modules;
126   const char *test_module_name;
127   const char *test_module_path;
128   const char *test_pre_req_file_path;
129   const char *test_os;
130   const char *test_mem_in_mb;
131   const char *test_cpu_freq_mhz;
132   const char *test_nb_of_nodes;
133   const char *test_nb_of_proc_per_node;
134
135 };
136
137 #endif // SALOME_RESOURCES_CATALOG_HANDLER