Salome HOME
Issue #353 constraint on 2 segments from not acive sketches
[modules/shaper.git] / src / Config / Config_FeatureReader.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 /*
4  * Config_FeatureReader.h
5  *
6  *  Created on: Mar 20, 2014
7  *      Author: sbh
8  */
9
10 #ifndef CONFIG_FEATUREREADER_H_
11 #define CONFIG_FEATUREREADER_H_
12
13 #include <Config_def.h>
14 #include <Config_XMLReader.h>
15 #include <memory>
16
17 #include <string>
18 #include <list>
19 #include <map>
20
21 class Config_FeatureMessage;
22
23 /*!
24  * \class Config_FeatureReader
25  * \ingroup Config
26  * \brief Class to process feature's xml definition.
27  */
28 class Config_FeatureReader : public Config_XMLReader
29 {
30  public:
31   /// Constructor
32   Config_FeatureReader(const std::string& theXmlFile,
33                        const std::string& theLibraryName,
34                        const char* theEventGenerated = 0);
35   virtual ~Config_FeatureReader();
36   /// Returns list of all features defined in reader's file
37   std::list<std::string> features() const;
38
39  protected:
40   /// Overloaded method. Defines how to process each node
41   virtual void processNode(xmlNodePtr aNode);
42   /// Overloaded method. Defines if the given node should be parsed recursively
43   virtual bool processChildren(xmlNodePtr aNode);
44
45   /// Fills feature message
46   void fillFeature(xmlNodePtr theRoot, 
47                    const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
48
49   /// Stores an attribute in internal map for later use.
50   /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
51   void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
52   /// Restores an attribute from internal map.
53   std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
54   /// Restores an attribute from internal map.
55   std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
56
57  private:
58   /// A map to store all parent's attributes.
59   /// The key has from "Node_Name:Node_Attribute"
60   std::map<std::string, std::string> myParentAttributes;
61   std::string myLibraryName;
62
63   std::list<std::string> myFeatures;
64   /// event generated on feature data sending, by default it is Config_FeatureMessage::GUI_EVENT()
65   const char* myEventGenerated;
66   bool myIsProcessWidgets;
67 };
68
69 #endif /* CONFIG_FEATUREREADER_H_ */