Salome HOME
Merge branch 'Dev_0.7.1' of newgeom:newgeom.git into Dev_0.7.1
[modules/shaper.git] / src / Config / Config_XMLReader.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Config_XMLReader.h
5  *
6  *  Created on: Mar 14, 2014
7  *      Author: sbh
8  */
9
10 #ifndef CONFIG_XMLREADER_H_
11 #define CONFIG_XMLREADER_H_
12
13 #include <Config_def.h>
14
15 #include <cstdarg>
16 #include <string>
17
18 //>> Forward declaration of xmlNodePtr.
19 typedef struct _xmlNode xmlNode;
20 typedef xmlNode *xmlNodePtr;
21 struct _xmlNode;
22 //<<
23
24 //>> Forward declaration of xmlDocPtr.
25 typedef struct _xmlDoc xmlDoc;
26 typedef xmlDoc *xmlDocPtr;
27 struct _xmlDoc;
28 //<<
29
30 /*!
31  * \class Config_XMLReader
32  * \ingroup Config
33  * \brief Base class for all libxml readers. Provides high-level API
34  * for all xml operations.
35 */
36 class Config_XMLReader
37 {
38  public:
39   CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
40   CONFIG_EXPORT virtual ~Config_XMLReader();
41   /*!
42    * Read all nodes in associated xml file,
43    * recursively if processChildren(xmlNode) is true for the xmlNode.
44    * For each read node the processNode will be called.
45    */
46   CONFIG_EXPORT void readAll();
47   /*!
48    * Returns xmlNodePtr to the root of reader's document
49    * or NULL if not found
50    */
51   CONFIG_EXPORT xmlNodePtr findRoot();
52
53  protected:
54   /*!
55    * \brief Allows to customize reader's behavior for a node. Virtual.
56    * The default implementation process "source", "validator" and
57    * "selection_filter" nodes.
58    */
59   virtual void processNode(xmlNodePtr aNode);
60   /*!
61    * \brief Defines which nodes should be processed recursively. Virtual.
62    * The default impl is to read all nodes.
63    */
64   virtual bool processChildren(xmlNodePtr aNode);
65   /*!
66    * Calls processNode() for each child (for some - recursively)
67    * of the given node.
68    * \sa ReadAll()
69    */
70   void readRecursively(xmlNodePtr theParent);
71   /*!
72    * \brief void* -> xmlNodePtr
73    */
74   xmlNodePtr node(void* theNode);
75   /// Gets xml node name
76   std::string getNodeName(xmlNodePtr theNode);
77   /*!
78    * \brief Retrieves all the necessary info from the validator node.
79    * Sends ValidatorLoaded event
80    */
81   void processValidator(xmlNodePtr theNode);
82   /*!
83    * \brief Retrieves all the necessary info from the SelectionFilter node.
84    * Sends SelectionFilterLoaded event
85    */
86   void processSelectionFilter(xmlNodePtr theNode);
87
88  protected:
89   std::string myCurrentFeature; ///< Name of currently processed feature
90   std::string myDocumentPath; ///< Path to the xml document
91   xmlDocPtr myXmlDoc; ///< Root of the xml document
92 };
93
94 #endif /* CONFIG_XMLREADER_H_ */