Salome HOME
Loading of SketchSolver plugin example.
[modules/shaper.git] / src / Config / Config_FeatureReader.cpp
index 1cb2ef83da1768002d6d7df81ad528b8c6e61bea..78e485e912d1b5e294d160c57b380e57273aff39 100644 (file)
@@ -6,14 +6,15 @@
  */
 
 #include <Config_Keywords.h>
+#include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_FeatureReader.h>
-#include <Event_Message.h>
-#include <Event_Loop.h>
+#include <Events_Message.h>
+#include <Events_Loop.h>
 
-#include <libxml\parser.h>
-#include <libxml\tree.h>
-#include <libxml\xmlstring.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlstring.h>
 
 #include <string>
 
 
 
 Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile,
-                                           const std::string& theLibraryName)
+                                           const std::string& theLibraryName,
+                                           const char* theEventGenerated)
     : Config_XMLReader(theXmlFile),
-      myLibraryName(theLibraryName)
+      myLibraryName(theLibraryName),
+      myEventGenerated(theEventGenerated ? theEventGenerated : EVENT_FEATURE_LOADED)
 {
 }
 
@@ -33,13 +36,21 @@ Config_FeatureReader::~Config_FeatureReader()
 {
 }
 
+std::list<std::string> Config_FeatureReader::features() const
+{
+  return myFeatures;
+}
+
 void Config_FeatureReader::processNode(xmlNodePtr theNode)
 {
-  static Event_ID aMenuItemEvent = Event_Loop::eventByName("FeatureEvent");
+  Events_ID aMenuItemEvent = Events_Loop::eventByName(myEventGenerated);
   if (isNode(theNode, NODE_FEATURE, NULL)) {
-    Event_Loop* aEvLoop = Event_Loop::loop();
+    Events_Loop* aEvLoop = Events_Loop::loop();
     Config_FeatureMessage aMessage(aMenuItemEvent, this);
     fillFeature(theNode, aMessage);
+    myFeatures.push_back(getProperty(theNode, _ID));
+    //If a feature has xml definition for it's widget:
+    aMessage.setUseInput(hasChild(theNode));
     aEvLoop->send(aMessage);
   }
   //The m_last* variables always defined before fillFeature() call. XML is a tree.
@@ -49,6 +60,8 @@ void Config_FeatureReader::processNode(xmlNodePtr theNode)
   if (isNode(theNode, NODE_WORKBENCH, NULL)) {
     myLastWorkbench = getProperty(theNode, _ID);
   }
+  //Process SOURCE nodes.
+  Config_XMLReader::processNode(theNode);
 }
 
 bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
@@ -66,4 +79,5 @@ void Config_FeatureReader::fillFeature(xmlNodePtr theRoot, Config_FeatureMessage
   outFtMessage.setGroupId(myLastGroup);
   outFtMessage.setWorkbenchId(myLastWorkbench);
   outFtMessage.setPluginLibrary(myLibraryName);
+  outFtMessage.setNestedFeatures(getProperty(theRoot, FEATURE_NESTED));
 }