}
}
-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();
else
myFlushed.erase(myFlushed.find(theID.myID));
}
+
+bool Events_Loop::hasGrouppedEvent(const Events_ID& theID)
+{
+ return myGroups.find(theID.myID) != myGroups.end();
+}
\ No newline at end of file
//! Clears all collected messages
EVENTS_EXPORT void clear(const Events_ID& theID);
- //! Enables flush without grouping for the given message
- EVENTS_EXPORT void autoFlush(const Events_ID& theID, const bool theAuto = true);
-
//! Returns true if the evement is flushed right now
EVENTS_EXPORT bool isFlushed(const Events_ID& theID);
//! Sets the flag that the event is flished right now
EVENTS_EXPORT void setFlushed(const Events_ID& theID, const bool theValue);
+ //! Returns true if a loop accumulated events to be flashed
+ EVENTS_EXPORT bool hasGrouppedEvent(const Events_ID& theID);
+
private:
//! Calls "processEvent" for the given listeners.
//! If theFlushedNow for grouped listeners is stores message in listeners.
}
myObjs->synchronizeBackRefs();
Events_Loop* aLoop = Events_Loop::loop();
- aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
- aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
- aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
- aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
+ static const Events_ID kCreatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED);
+ static const Events_ID kUpdatedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_UPDATED);
+ static const Events_ID kRedispEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ static const Events_ID kDeletedEvent = Events_Loop::loop()->eventByName(EVENT_OBJECT_DELETED);
+ aLoop->flush(kCreatedEvent);
+ aLoop->flush(kUpdatedEvent);
+ aLoop->flush(kRedispEvent);
+ aLoop->flush(kDeletedEvent);
if (isNestedClosed) {
if (myDoc->CommitCommand())
// to avoid messages about modifications outside of the transaction
// and to rebuild everything after all updates and creates
if (isRoot()) { // once for root document
- Events_Loop::loop()->autoFlush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
static std::shared_ptr<Events_Message> aFinishMsg
(new Events_Message(Events_Loop::eventByName("FinishOperation")));
Events_Loop::loop()->send(aFinishMsg);
}
+
+ while(aLoop->hasGrouppedEvent(kCreatedEvent) || aLoop->hasGrouppedEvent(kUpdatedEvent) ||
+ aLoop->hasGrouppedEvent(kRedispEvent) || aLoop->hasGrouppedEvent(kDeletedEvent)) {
+ aLoop->flush(kCreatedEvent);
+ aLoop->flush(kUpdatedEvent);
+ aLoop->flush(kRedispEvent);
+ aLoop->flush(kDeletedEvent);
+ }
+
// to avoid "updated" message appearance by updater
//aLoop->clear(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
if (subDoc(*aSubIter)->finishOperation())
aResult = true;
- // sub-Part may send updated by flush of deleted (macro circle)
- if (isRoot()) { // once for root document
- Events_Loop::loop()->autoFlush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED), false);
- }
-
// transaction may be empty if this document was created during this transaction (create part)
if (!myTransactions.empty() && myDoc->CommitCommand()) {
// if commit is successfull, just increment counters