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

#include "Notify_Event_Processor.h"
#include "Notify_Worker_Task.h"
#include "Notify_Source_Filter_Eval_Command.h"
#include "Notify_Listener_Filter_Eval_Command.h"
#include "Notify_Event_Manager_Objects_Factory.h"
#include "Notify_Lookup_Command.h"
#include "Notify_Event_Dispatch_Command.h"
#include "Notify_Factory.h"
#include "Notify_Listeners.h"
#include "Notify_Event_Manager.h"

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

TAO_Notify_Event_Processor::TAO_Notify_Event_Processor (TAO_Notify_Event_Manager* event_manager)
  :event_manager_ (event_manager),
   lookup_task_ (0),
   emo_factory_ (0)
{
  this->emo_factory_ = event_manager_->resource_factory ();
}

TAO_Notify_Event_Processor::~TAO_Notify_Event_Processor ()
{
  delete this->lookup_task_;
}

void
TAO_Notify_Event_Processor::init (TAO_ENV_SINGLE_ARG_DECL)
{
  this->lookup_task_ = this->emo_factory_->create_lookup_task (TAO_ENV_SINGLE_ARG_PARAMETER);
  ACE_CHECK;

  // Get hold of the admin properties.
  TAO_Notify_AdminProperties* const admin_properties =
    this->event_manager_->admin_properties ();

  this->lookup_task_->init_task (admin_properties);
}

void
TAO_Notify_Event_Processor::shutdown (TAO_ENV_SINGLE_ARG_DECL)
{
  this->lookup_task_->shutdown (TAO_ENV_SINGLE_ARG_PARAMETER);
}

void
TAO_Notify_Event_Processor::evaluate_source_filter (TAO_Notify_Event* event,
                                                    TAO_Notify_EventSource* event_source
                                                    TAO_ENV_ARG_DECL)
{
  // TODO: use cache allocator here.
  // @@ Pradeep: you shouldn't be allocating at all!  If this must go
  // into a queue then the processing queue should make the
  // allocation, that way the single threaded case works just fine.
  TAO_Notify_Source_Filter_Eval_Command* mb =
    new TAO_Notify_Source_Filter_Eval_Command (this, event, event_source);

  event_source->filter_eval_task ()->process_event (mb TAO_ENV_ARG_PARAMETER);
}

void
TAO_Notify_Event_Processor::lookup_subscriptions (TAO_Notify_Event* event,
                                                  TAO_Notify_EventSource* /*event_source*/
                                                  TAO_ENV_ARG_DECL)
{
  TAO_Notify_Lookup_Command* lookup =
    new TAO_Notify_Lookup_Command (this, event, this->event_manager_->event_map ());

  this->lookup_task_->process_event (lookup TAO_ENV_ARG_PARAMETER);
}

void
TAO_Notify_Event_Processor::evaluate_listener_filter (TAO_Notify_Event* event, TAO_Notify_EventListener* event_listener, CORBA::Boolean eval_parent TAO_ENV_ARG_DECL)
{
  // @@ Pradeep: you should use ACE_NEW here....
  // @@ Pradeep: do you really need to allocate this guy from the
  // heap? Maybe you can just allocate it from the stack and only if
  // somebody really wants to keep it around you make a copy?  The
  // idea is to save allocations in the good case.

  TAO_Notify_Listener_Filter_Eval_Command* mb =
    new TAO_Notify_Listener_Filter_Eval_Command (this, event, event_listener, eval_parent);

  event_listener->filter_eval_task ()->process_event (mb TAO_ENV_ARG_PARAMETER);
}

void
TAO_Notify_Event_Processor::dispatch_event (TAO_Notify_Event* event, TAO_Notify_EventListener* event_listener TAO_ENV_ARG_DECL)
{
  TAO_Notify_Event_Dispatch_Command* dispatch =
    new TAO_Notify_Event_Dispatch_Command (this, event, event_listener);

  event_listener->event_dispatch_task ()->process_event (dispatch TAO_ENV_ARG_PARAMETER);
}