Salome HOME
Correction of icon
[modules/shaper.git] / src / Config / Config_FeatureReader.h
index 7b5322bba036468272244794f370455f610c1fdb..75eb376e5cdd88ba8a6249a863e522e7ec1c3163 100644 (file)
@@ -1,3 +1,5 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
 /*
  * Config_FeatureReader.h
  *
 #ifndef CONFIG_FEATUREREADER_H_
 #define CONFIG_FEATUREREADER_H_
 
-#include <Config.h>
+#include <Config_def.h>
 #include <Config_XMLReader.h>
+#include <memory>
 
 #include <string>
-
+#include <list>
+#include <map>
 
 class Config_FeatureMessage;
 
-class Config_FeatureReader: public Config_XMLReader
+/*!
+ * \class Config_FeatureReader
+ * \ingroup Config
+ * \brief Class to process feature's xml definition.
+ */
+class Config_FeatureReader : public Config_XMLReader
 {
-public:
+ public:
+  /// Constructor
   Config_FeatureReader(const std::string& theXmlFile,
-                       const std::string& theLibraryName = "",
+                       const std::string& theLibraryName,
                        const char* theEventGenerated = 0);
   virtual ~Config_FeatureReader();
+  /// Returns list of all features defined in reader's file
+  std::list<std::string> features() const;
+
+ protected:
+  /// Overloaded method. Defines how to process each node
+  virtual void processNode(xmlNodePtr aNode);
 
-protected:
-  void processNode(xmlNodePtr aNode);
-  bool processChildren(xmlNodePtr aNode);
+  /// Overloaded method. Clears attribute cache on extit from attribute's node
+  virtual void cleanup(xmlNodePtr aNode);
 
-  void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
+  /// Overloaded method. Defines if the given node should be parsed recursively
+  virtual bool processChildren(xmlNodePtr aNode);
 
-private:
-  std::string myLastWorkbench;
-  std::string myLastGroup;
+  /// Fills feature message
+  void fillFeature(xmlNodePtr theRoot, 
+                   const std::shared_ptr<Config_FeatureMessage>& outFeatureMessage);
+
+  /// Stores an attribute in internal map for later use.
+  /// Key is "Node_Name:Node_Attribute" and value is getProperty(theNodeAttribute)
+  void storeAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
+  std::string restoreAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  /// Restores an attribute from internal map.
+  std::string restoreAttribute(const char* theNodeName, const char* theNodeAttribute);
+
+  bool cleanupAttribute(xmlNodePtr theNode, const char* theNodeAttribute);
+  bool cleanupAttribute(const char* theNodeName, const char* theNodeAttribute);
+
+ private:
+  /// A map to store all parent's attributes.
+  /// The key has from "Node_Name:Node_Attribute"
+  std::map<std::string, std::string> myParentAttributes;
   std::string myLibraryName;
-  /// event generated on feature data sending, by default it is "FeatureEvent"
+
+  std::list<std::string> myFeatures;
+  /// event generated on feature data sending, by default it is Config_FeatureMessage::GUI_EVENT()
   const char* myEventGenerated;
+  bool myIsProcessWidgets;
 };
 
 #endif /* CONFIG_FEATUREREADER_H_ */