63 (*it)->RemoveListener(
this);
93 bool cmd_between = (CmdID >= pEntry->
id && CmdID <= pEntry->
last_id);
95 bool class_safe = (cls == pEntry->
evt_class);
97 if (cmd_between && typeinfo_safe && class_safe) {
137 _TRACE(
"CEventHandler::AddListener(): NULL listener");
148 TListeners::iterator it = std::find(pool.begin(), pool.end(), listener);
149 if(it == pool.end()) {
150 pool.push_back(listener);
160 TListeners::iterator it_lst = std::find(pool.begin(), pool.end(), listener);
161 if(it_lst != pool.end()) {
173 _TRACE(
"CEventHandler::RemoveListener(): NULL listener");
187 if(listener !=
NULL) {
191 TListeners::const_iterator it = std::find(pool.begin(), pool.end(), listener);
192 return (it != pool.end());
235 bool handled =
false;
291 handled |=
Dispatch(evt, disp_how, pool_name);
296 handled =
Dispatch(evt, disp_how, pool_name);
330 return queue->ExecuteFirstRequest();
356 static CMutex s_CreateQueueMutex;
370 sm_PostQueue.Reset();
379 it->first->m_Queue.Reset();
382 m_AliveTargets.clear();
395 THandlerToCount::iterator it = m_AliveTargets.find(target);
396 if (it == m_AliveTargets.end()) {
397 m_AliveTargets[target] = 1;
407 if (
size >= 1000 && (
size % 100) == 0) {
410 "queue is too long, size = " <<
size);
429 auto it = m_AliveTargets.find(target);
430 if (it != m_AliveTargets.end()) {
434 m_AliveTargets.erase(it);
438 toDelete.push_back(*
i);
468 m_AliveTargets.clear();
CPostQueue - singleton queue for asynchronous events all methods are synchronized.
CEvent - generic event implementation TODO TODO - Attachments.
container_type::const_iterator const_iterator
container_type::iterator iterator
const_iterator begin() const
const_iterator end() const
const_iterator find(const key_type &key) const
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
Include a standard set of the NCBI C++ Toolkit most basic headers.
const SEvtMapEntry * FindEventMapEntry(const SEvtMap *pMap, CEvent::EEventClass cls, CEvent::TEventTypeInfo tif, CEvent::TEventID CmdID)
Traverses a list of Command Maps in order to locate a handler corresponding to the given command ID.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
void Error(CExceptionArgs_Base &args)
#define NCBI_CATCH(message)
Catch CExceptions as well This macro is deprecated - use *_X or *_XX variant instead of it.
virtual void RemoveListener(CEventHandler *listener)
Remove a listener.
bool Visit(CEventHandler *handler)
Checks whether this event has been visited by the given handler.
const TEventID GetID(void) const
Inline Implementation.
CEvent::EEventClass evt_class
static void DestroyInstance()
returns Singleton
static bool HandlePostRequest()
CEventHandler()
CEventHandler.
~CPostQueue()
destroys singleton
void Post(SPostRequest *req)
static const SEvtMapEntry sm_EvtMapEntries[]
vector< CEventHandler * > TListeners
virtual const TListeners * GetListeners(int pool_name=ePool_Default) const
returns a set of listeners fro the specified pool
CEvent::TEventID last_id
Event ID (or ID range start)
void DeclareDead(CEventHandler *handler)
FEventHandler handler
Envent ID range end.
const char * TEventTypeInfo
const SEvtMapEntry * entries
pointer to command map of the base class
void x_DeclareDead()
Removes itself unavailable for async event delivery.
bool ExecuteFirstRequest()
extracts a request from the front of the queue and executes it
void Post(CRef< CEvent > evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Handles an event asynchronously (process and/or dispatch).
CEvent::TEventID id
Type Information.
TEventTypeInfo GetTypeInfo(void)
static void ClearPostQueue()
erases all events from the queue
void(CEventHandler::* FEventHandler)(CEvent *)
event handler
CEvent::TEventTypeInfo type_info
message or command or update
static void DestroyPostQueue()
const EEventClass GetEventClass(void) const
virtual bool Dispatch(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Dispatches an event to the listeners (but does not handle it).
std::map< CEventHandler *, int > THandlerToCount
EEventClass
default event classes
EDispatch
enum controlling dispatching strategies
virtual void AddListener(CEventHandler *listener, int pool_name=ePool_Default)
Add a listener.
void x_AddListenerToPool(CEventHandler *listener, int pool_name)
virtual const SEvtMap * GetEventMap() const
virtual void RemoveAllListeners(void)
static CRef< CPostQueue > GetInstance()
virtual bool OnEvent(CEvent *evt)
Processes en event. Returns "true" if event has been processed.
virtual bool HasListener(CEventHandler *listener, int pool_name=ePool_Default) const
returns "true" if the given listener belongs to the specified pool
static const SEvtMap sm_EvtMap
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
CRef< CPostQueue > m_Queue
static CRef< CPostQueue > sm_PostQueue
CPostQueue.
list< AutoPtr< SPostRequest > > TPostRequests
@ eEvent_Message
message from one class to another
@ eDispatch_AllHandlers
handle and do not dispatch to listeners
@ eDispatch_FirstHandler
dispatch to all handlers
@ eDispatch_Default
dispatch until handled at least by one handler
void Reset(void)
Reset reference object.
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
const struct ncbi::grid::netcache::search::fields::SIZE size
int strcmp(const char *str1, const char *str2)