Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / Model / Model_Session.cpp
index b1804462323c96cf46ac69abeba145f3fb1cf654..567dba4d4afcb617c8ae88f13f6dbbe2a600bf0a 100644 (file)
@@ -31,8 +31,6 @@
 
 using namespace std;
 
-#include <iostream>
-
 static Model_Session* myImpl = new Model_Session();
 
 // t oredirect all calls to the root document
@@ -177,10 +175,12 @@ FeaturePtr Model_Session::createFeature(string theFeatureID, Model_Document* the
       }
       return aCreated;
     } else {
-      Events_InfoMessage("Model_Session","Can not load plugin '%1'").arg(myCurrentPluginName).send();
+      Events_InfoMessage("Model_Session",
+        "Can not load plugin '%1'").arg(myCurrentPluginName).send();
     }
   } else {
-    Events_InfoMessage("Model_Session","Feature '%1' not found in any plugin").arg(theFeatureID).send();
+    Events_InfoMessage("Model_Session",
+      "Feature '%1' not found in any plugin").arg(theFeatureID).send();
   }
 
   return FeaturePtr();  // return nothing
@@ -191,7 +191,8 @@ std::shared_ptr<ModelAPI_Document> Model_Session::moduleDocument()
   Handle(Model_Application) anApp = Model_Application::getApplication();
   bool aFirstCall = !anApp->hasRoot();
   if (aFirstCall) {
-    // to be sure that plugins are loaded, even before the first "createFeature" call (in unit tests)
+    // to be sure that plugins are loaded, 
+    // even before the first "createFeature" call (in unit tests)
     LoadPluginsInfo();
     // creation of the root document is always outside of the transaction, so, avoid checking it
     setCheckTransactions(false);
@@ -361,8 +362,6 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
       std::dynamic_pointer_cast<Config_FeatureMessage>(theMessage);
     if (aMsg) {
 
-//      std::cout << "Feature: " << aMsg->id() << std::endl;
-
       // process the plugin info, load plugin
       if (myPlugins.find(aMsg->id()) == myPlugins.end()) {
         myPlugins[aMsg->id()] = std::pair<std::string, std::string>(
@@ -373,68 +372,35 @@ void Model_Session::processEvent(const std::shared_ptr<Events_Message>& theMessa
         std::dynamic_pointer_cast<Config_AttributeMessage>(theMessage);
       if (aMsgAttr) {
 
-//        std::cout << "Feature: " << aMsgAttr->featureId()
-//            << ", Attribute: " << aMsgAttr->attributeId() << std::endl;
-
         if (!aMsgAttr->isObligatory()) {
           validators()->registerNotObligatory(aMsgAttr->featureId(), aMsgAttr->attributeId());
-        } else {
-          std::cout << "F: " << aMsgAttr->featureId()
-              << ", V: Model_FeatureValidator"
-              << ", A: " << aMsgAttr->attributeId()
-              << std::endl;
         }
         if(aMsgAttr->isConcealment()) {
           validators()->registerConcealment(aMsgAttr->featureId(), aMsgAttr->attributeId());
         }
-        if (!aMsgAttr->caseId().empty()) {
-          validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(),
-            aMsgAttr->switchId(), aMsgAttr->caseId());
+        const std::list<std::pair<std::string, std::string> >& aCases = aMsgAttr->getCases();
+        if (!aCases.empty()) {
+          validators()->registerCase(aMsgAttr->featureId(), aMsgAttr->attributeId(), aCases);
         }
       }
     }
     // plugins information was started to load, so, it will be loaded
     myPluginsInfoLoaded = true;
   } else if (theMessage->eventID() == kValidatorEvent) {
-
-    static bool done = false;
-    if (!done) {
-      std::set<std::string> aPlugins;
-      for (auto it = myPlugins.begin(); it != myPlugins.end(); ++it) {
-        std::string aPluginName = it->second.first;
-        aPlugins.insert(aPluginName);
-      }
-
-      for (auto it = aPlugins.begin(); it != aPlugins.end(); ++it) {
-        myCurrentPluginName = *it;
-        Config_ModuleReader::loadPlugin(*it);
-      }
-
-      done = true;
-    }
-
     std::shared_ptr<Config_ValidatorMessage> aMsg = 
       std::dynamic_pointer_cast<Config_ValidatorMessage>(theMessage);
     if (aMsg) {
       if (aMsg->attributeId().empty()) {  // feature validator
-
-        std::cout << "F: " << aMsg->featureId()
-          << ", V: " << aMsg->validatorId() << std::endl;
-
         validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->parameters());
       } else {  // attribute validator
-
-        std::cout << "F: " << aMsg->featureId()
-          << ", A: " << aMsg->attributeId()
-          << ", V: " << aMsg->validatorId() << std::endl;
-
         validators()->assignValidator(aMsg->validatorId(), aMsg->featureId(), aMsg->attributeId(),
                                       aMsg->parameters());
       }
     }
   } else {  // create/update/delete
     if (myCheckTransactions && !isOperation())
-      Events_InfoMessage("Model_Session", "Modification of data structure outside of the transaction").send();
+      Events_InfoMessage("Model_Session",
+        "Modification of data structure outside of the transaction").send();
     // if part is deleted, make the root as the current document (on undo of Parts creations)
     static const Events_ID kDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
     if (theMessage->eventID() == kDeletedEvent) {