X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FEvents%2FEvents_Loop.cpp;h=d2d96de532ceda5a4c43bb051fadad2a3ebb7f21;hb=0272e1496da44aea21d17fccc98d12c58f578b64;hp=b13472aee107dc9ade02cf43d3e3686597af9580;hpb=730e32c2a13c666f4d76808b4904c5727e3d11af;p=modules%2Fshaper.git diff --git a/src/Events/Events_Loop.cpp b/src/Events/Events_Loop.cpp index b13472aee..d2d96de53 100644 --- a/src/Events/Events_Loop.cpp +++ b/src/Events/Events_Loop.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Events_Loop.hxx // Created: Thu Mar 13 2014 // Author: Mikhail PONIKAROV @@ -37,24 +39,24 @@ Events_ID Events_Loop::eventByName(const char* theName) return Events_ID(aResult); } -void Events_Loop::send(const boost::shared_ptr& theMessage, bool isGroup) +void Events_Loop::send(const std::shared_ptr& theMessage, bool isGroup) { if (myImmediateListeners.find(theMessage->eventID().eventText()) != myImmediateListeners.end()) { myImmediateListeners[theMessage->eventID().eventText()]->processEvent(theMessage); } // if it is grouped message, just accumulate it - if (isGroup) { - boost::shared_ptr aGroup = - boost::dynamic_pointer_cast(theMessage); + if (isGroup && myFlushed.find(theMessage->eventID().myID) == myFlushed.end()) { + std::shared_ptr aGroup = + std::dynamic_pointer_cast(theMessage); if (aGroup) { - std::map >::iterator aMyGroup = myGroups.find( + 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()); } - boost::shared_ptr aStored = - boost::dynamic_pointer_cast(aMyGroup->second); + std::shared_ptr aStored = + std::dynamic_pointer_cast(aMyGroup->second); aStored->Join(aGroup); return; } @@ -115,16 +117,68 @@ void Events_Loop::flush(const Events_ID& theID) { if (!myFlushActive) return; - std::map>::iterator aMyGroup = - myGroups.find(theID.eventText()); - if (aMyGroup != myGroups.end()) { // really sends - boost::shared_ptr aGroup = aMyGroup->second; + std::map >::iterator aMyGroup; + for(aMyGroup = myGroups.find(theID.eventText()); + aMyGroup != myGroups.end(); aMyGroup = myGroups.find(theID.eventText())) + { // really sends + bool aWasFlushed = myFlushed.find(theID.myID) != myFlushed.end(); + if (!aWasFlushed) + myFlushed.insert(theID.myID); + std::shared_ptr aGroup = aMyGroup->second; myGroups.erase(aMyGroup); send(aGroup, false); + + if (!aWasFlushed) + // TODO: Stabilization fix. Check later. + if(myFlushed.find(theID.myID) != myFlushed.end()) { + myFlushed.erase(myFlushed.find(theID.myID)); + } + } +} + +void Events_Loop::eraseMessages(const Events_ID& theID) +{ + std::map >::iterator aMyGroup = + myGroups.find(theID.eventText()); + if (aMyGroup != myGroups.end()) { + myGroups.erase(aMyGroup); } } -void Events_Loop::activateFlushes(const bool theActivate) + +bool Events_Loop::activateFlushes(const bool theActivate) { + bool isActive = myFlushActive; myFlushActive = theActivate; + return isActive; +} + +void Events_Loop::clear(const Events_ID& theID) +{ + std::map>::iterator aMyGroup = + myGroups.find(theID.eventText()); + if (aMyGroup != myGroups.end()) { // really sends + myGroups.erase(aMyGroup); + } +} + +void Events_Loop::autoFlush(const Events_ID& theID, const bool theAuto) +{ + if (theAuto) + myFlushed.insert(theID.myID); + else + myFlushed.erase(myFlushed.find(theID.myID)); +} + +bool Events_Loop::isFlushed(const Events_ID& theID) +{ + return myFlushed.find(theID.myID) != myFlushed.end(); +} + +void Events_Loop::setFlushed(const Events_ID& theID, const bool theValue) +{ + if (theValue) + myFlushed.insert(theID.myID); + else + myFlushed.erase(myFlushed.find(theID.myID)); }