summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Event_Map_Observer_T.cpp
blob: 255cd09c057722db706c5e35443eac6b9a6e9ffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// $Id$

#include "Event_Map_Observer_T.h"

#if ! defined (__ACE_INLINE__)
#include "Event_Map_Observer_T.inl"
#endif /* __ACE_INLINE__ */

ACE_RCSID(Notify, TAO_Event_Map_Observer_T, "$id$")

#include "Proxy.h"
#include "Peer.h"
#include "Dispatch_Observer_T.h"
#include "orbsvcs/ESF/ESF_Proxy_Collection.h"
#include "Event_Map_T.h"

/******************************************************************************************/

template <class PROXY>
TAO_NS_Update_Added_Worker<PROXY>::TAO_NS_Update_Added_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer)
  :event_type_ (event_type), dispatch_observer_ (dispatch_observer)
{
}

template <class PROXY> void
TAO_NS_Update_Added_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL)
{
  proxy->peer()->type_added (this->event_type_);
  this->dispatch_observer_->enqueue (proxy->peer()); // Tell the observer that this peer has a update pending.
}

/******************************************************************************************/

template <class PROXY>
TAO_NS_Update_Removed_Worker<PROXY>::TAO_NS_Update_Removed_Worker (const TAO_NS_EventType& event_type, TAO_NS_Updates_Dispatch_Observer* dispatch_observer)
  :event_type_ (event_type), dispatch_observer_ (dispatch_observer)
{
}

template <class PROXY> void
TAO_NS_Update_Removed_Worker<PROXY>::work (PROXY* proxy ACE_ENV_ARG_DECL)
{
  proxy->peer()->type_removed (this->event_type_);
  this->dispatch_observer_->enqueue (proxy->peer()); // Tell the observer that this peer has a update pending.
}

/******************************************************************************************/

template <class PROXY>
TAO_NS_Event_Map_Observer_T<PROXY>::TAO_NS_Event_Map_Observer_T (void)
  :event_map_ (0), dispatch_observer_ (0)
{
}

template <class PROXY>
TAO_NS_Event_Map_Observer_T<PROXY>::~TAO_NS_Event_Map_Observer_T ()
{
}

template <class PROXY> void
TAO_NS_Event_Map_Observer_T<PROXY>::init (EVENT_MAP* event_map, TAO_NS_Updates_Dispatch_Observer* dispatch_observer)
{
  this->event_map_ = event_map;
  this->dispatch_observer_ = dispatch_observer;
}

template <class PROXY> void
TAO_NS_Event_Map_Observer_T<PROXY>::type_added (const TAO_NS_EventType& event_type)
{
  UPDATE_ADDED_WORKER worker (event_type, this->dispatch_observer_);

  PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER);

  if (proxys != 0)
    proxys->for_each (&worker ACE_ENV_ARG_PARAMETER);

  // Get the default broadcast collection.
  proxys = this->event_map_->broadcast_collection ();

  if (proxys != 0)
    proxys->for_each (&worker ACE_ENV_ARG_PARAMETER);
}

template <class PROXY> void
TAO_NS_Event_Map_Observer_T<PROXY>::type_removed (const TAO_NS_EventType& event_type)
{
  UPDATE_REMOVED_WORKER worker (event_type, this->dispatch_observer_);

  PROXY_COLLECTION* proxys = this->event_map_->find (event_type ACE_ENV_ARG_PARAMETER);

  if (proxys != 0)
    proxys->for_each (&worker ACE_ENV_ARG_PARAMETER);

  // Get the default broadcast collection.
  proxys = this->event_map_->broadcast_collection ();

  if (proxys != 0)
    proxys->for_each (&worker ACE_ENV_ARG_PARAMETER);
}