summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Notify_Lookup_Command.cpp
blob: 275be23fff7d9c9340eba04ceeaf37d15e19b600 (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
// $Id$

#include "orbsvcs/ESF/ESF_Proxy_Collection.h"
#include "Notify_Lookup_Command.h"
#include "Notify_Event_Manager.h"
#include "Notify_Listener_Filter_Eval_Command.h"
#include "Notify_Event.h"
#include "Notify_Event_Map.h"
#include "Notify_Event_Processor.h"

ACE_RCSID(Notify, Notify_Lookup_Command, "$Id$")

TAO_Notify_Lookup_Command::TAO_Notify_Lookup_Command (TAO_Notify_Event_Processor* event_processor, TAO_Notify_Event* event, TAO_Notify_Event_Map* event_map)
  :TAO_Notify_Command (event_processor, event),
   event_map_ (event_map)
{
  this->event_->_incr_refcnt ();
}

TAO_Notify_Lookup_Command::~TAO_Notify_Lookup_Command ()
{
  this->event_->_decr_refcnt ();
}

int
TAO_Notify_Lookup_Command::execute (CORBA::Environment& ACE_TRY_ENV)
{
  // If the event is *not* the special event
  // send it to the list that matches it.
  // In any case send it to the default list.
#if 0
  ACE_DEBUG ((LM_DEBUG, "finding a match for event: %s, %s\n",
              event->event_type ().event_type_.domain_name.in (),
              event->event_type ().event_type_.type_name.in ()));
#endif

  if (!this->event_->is_special_event_type ())
    {
      TAO_Notify_EventListener_List* listener_list;
      // find the subscription list for <event_type>

      if (event_map_->find (this->event_->event_type (),
                           listener_list) == 0)
        {
          listener_list->for_each (this, ACE_TRY_ENV);
          ACE_CHECK_RETURN (-1);
        }
    }
  // Those subscribed for the default events get everything.
  // if (this->default_subscription_list_->is_empty () == 0)
  // @@ can't do this test - is_empty is not impl.
  {
    event_map_->default_subscription_list ()->for_each (this, ACE_TRY_ENV);
    ACE_CHECK_RETURN (-1);
  }

  return 0;
}

void
TAO_Notify_Lookup_Command::work (TAO_Notify_EventListener* event_listener,
                                  CORBA::Environment &ACE_TRY_ENV)
{
  this->event_processor_->evaluate_listener_filter (this->event_, event_listener, 1, ACE_TRY_ENV);
  // Note the last parameter, we want the parent filter to be evaluated.
}