From: mpv Date: Thu, 22 May 2014 13:00:38 +0000 (+0400) Subject: Debug of flush operation X-Git-Tag: V_0.2~26^2~1^2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=10afa56c18322075c75ff2616ac23853bd0c87ca;p=modules%2Fshaper.git Debug of flush operation --- diff --git a/src/Events/Events_Loop.cpp b/src/Events/Events_Loop.cpp index e8d6a716a..5a5a94426 100644 --- a/src/Events/Events_Loop.cpp +++ b/src/Events/Events_Loop.cpp @@ -33,19 +33,21 @@ Events_ID Events_Loop::eventByName(const char* theName) return Events_ID(aResult); } -void Events_Loop::send(Events_Message& theMessage) +void Events_Loop::send(Events_Message& theMessage, bool isGroup) { // if it is grouped message, just accumulate it - Events_MessageGroup* aGroup = dynamic_cast(&theMessage); - if (aGroup) { - std::map::iterator aMyGroup = - myGroups.find(aGroup->eventID().eventText()); - if (aMyGroup == myGroups.end()) { // create a new group of messages for accumulation - myGroups[aGroup->eventID().eventText()] = aGroup->newEmpty(); - aMyGroup = myGroups.find(aGroup->eventID().eventText()); + if (isGroup) { + Events_MessageGroup* aGroup = dynamic_cast(&theMessage); + if (aGroup) { + std::map::iterator aMyGroup = + myGroups.find(aGroup->eventID().eventText()); + if (aMyGroup == myGroups.end()) { // create a new group of messages for accumulation + myGroups[aGroup->eventID().eventText()] = aGroup->newEmpty(); + aMyGroup = myGroups.find(aGroup->eventID().eventText()); + } + aMyGroup->second->Join(*aGroup); + return; } - aMyGroup->second->Join(*aGroup); - return; } // TO DO: make it in thread and with usage of semaphores @@ -101,7 +103,7 @@ void Events_Loop::flush(const Events_ID& theID) myGroups.find(theID.eventText()); if (aMyGroup != myGroups.end()) { // really sends Events_MessageGroup* aGroup = aMyGroup->second; - send(*aGroup); + send(*aGroup, false); myGroups.erase(aMyGroup); delete aGroup; } diff --git a/src/Events/Events_Loop.h b/src/Events/Events_Loop.h index f5721c8b4..d19dd4d4a 100644 --- a/src/Events/Events_Loop.h +++ b/src/Events/Events_Loop.h @@ -41,7 +41,8 @@ public: EVENTS_EXPORT static Events_ID eventByName(const char* theName); //! Allows to send an event - EVENTS_EXPORT void send(Events_Message& theMessage); + //! \param isGroup is true for grouping messages if possible + EVENTS_EXPORT void send(Events_Message& theMessage, bool isGroup = true); //! Registers (or adds if such listener is already registered) a listener //! that will be called on the event and from the defined sender diff --git a/src/Model/Model_PluginManager.cpp b/src/Model/Model_PluginManager.cpp index 7a0a20d0a..05f1586e6 100644 --- a/src/Model/Model_PluginManager.cpp +++ b/src/Model/Model_PluginManager.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -97,27 +98,34 @@ boost::shared_ptr Model_PluginManager::copy( Model_PluginManager::Model_PluginManager() { myPluginsInfoLoaded = false; - //TODO(sbh): Implement static method to extract event id [SEID] - static Events_ID aFeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); - ModelAPI_PluginManager::SetPluginManager(boost::shared_ptr(this)); // register the configuration reading listener Events_Loop* aLoop = Events_Loop::loop(); - aLoop->registerListener(this, aFeatureEvent); + static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); + aLoop->registerListener(this, FeatureEvent); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_CREATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); + aLoop->registerListener(this, Events_Loop::eventByName(EVENT_FEATURE_DELETED)); } void Model_PluginManager::processEvent(const Events_Message* theMessage) { - const Config_FeatureMessage* aMsg = - dynamic_cast(theMessage); - if (aMsg) { - // proccess the plugin info, load plugin - if (myPlugins.find(aMsg->id()) == myPlugins.end()) { - myPlugins[aMsg->id()] = aMsg->pluginLibrary(); + static Events_ID FeatureEvent = Events_Loop::eventByName("FeatureRegisterEvent"); + if (theMessage->eventID() == FeatureEvent) { + const Config_FeatureMessage* aMsg = + dynamic_cast(theMessage); + if (aMsg) { + // proccess the plugin info, load plugin + if (myPlugins.find(aMsg->id()) == myPlugins.end()) { + myPlugins[aMsg->id()] = aMsg->pluginLibrary(); + } } + // plugins information was started to load, so, it will be loaded + myPluginsInfoLoaded = true; + } else { // create/update/delete + if (!rootDocument()->isOperation()) + Events_Error::send("Modification of data structure outside of the transaction"); } - // plugins information was started to load, so, it will be loaded - myPluginsInfoLoaded = true; } void Model_PluginManager::LoadPluginsInfo()