summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/Structured/StructuredEvent.cpp
blob: 21d273c3fe76da8fc947fc4ec02df65059a8f755 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// $Id$

#include "StructuredEvent.h"

ACE_RCSID(RT_Notify, TAO_Notify_StructuredEvent, "$Id$")

#include "../PropertySeq.h"
#include "../Consumer.h"
#include "tao/debug.h"
#include "tao/corba.h"

TAO_Notify_StructuredEvent_No_Copy::TAO_Notify_StructuredEvent_No_Copy (const CosNotification::StructuredEvent &notification)
  : notification_ (&notification), type_ (notification.header.fixed_header.event_type)
{
  const CosNotification::PropertySeq& prop_seq = notification.header.variable_header;

  for (CORBA::ULong i = 0; i < prop_seq.length (); ++i)
    {
      if (ACE_OS::strcmp (prop_seq[i].name.in (), CosNotification::Priority) == 0)
        this->priority_.set (prop_seq[i].value);
      else if (ACE_OS::strcmp (prop_seq[i].name.in (), CosNotification::Timeout) == 0)
        this->timeout_.set (prop_seq[i].value);
    }
}

const TAO_Notify_EventType&
TAO_Notify_StructuredEvent_No_Copy::type (void) const
{
  return this->type_;
}

TAO_Notify_StructuredEvent_No_Copy::~TAO_Notify_StructuredEvent_No_Copy ()
{
}

void
TAO_Notify_StructuredEvent_No_Copy::marshal (TAO_OutputCDR & cdr) const
{
  static const ACE_CDR::Octet STRUCTURED_CODE = MARSHAL_STRUCTURED;
  cdr.write_octet (STRUCTURED_CODE);
  cdr << (*this->notification_);
}

//static
TAO_Notify_StructuredEvent *
TAO_Notify_StructuredEvent_No_Copy::unmarshal (TAO_InputCDR & cdr)
{
  TAO_Notify_StructuredEvent * event = 0;
  CosNotification::StructuredEvent body;
  if (cdr >> body)
  {
    event = new TAO_Notify_StructuredEvent (body);
  }
  return event;
}

TAO_Notify_Event *
TAO_Notify_StructuredEvent_No_Copy::copy (ACE_ENV_SINGLE_ARG_DECL) const
{
  TAO_Notify_Event * new_event;
  ACE_NEW_THROW_EX (new_event,
                    TAO_Notify_StructuredEvent (*this->notification_),
                    CORBA::NO_MEMORY ());
  ACE_CHECK_RETURN (0);
  return new_event;
}

CORBA::Boolean
TAO_Notify_StructuredEvent_No_Copy::do_match (CosNotifyFilter::Filter_ptr filter ACE_ENV_ARG_DECL) const
{
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - "
                "TAO_Notify_StructuredEvent::do_match ()\n"));

  return filter->match_structured (*this->notification_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_Notify_StructuredEvent_No_Copy::convert (CosNotification::StructuredEvent& notification) const
{
  notification = *this->notification_;
}

void
TAO_Notify_StructuredEvent_No_Copy::push (TAO_Notify_Consumer* consumer ACE_ENV_ARG_DECL) const
{
  if (TAO_debug_level > 0)
    ACE_DEBUG ((LM_DEBUG, "Notify (%P|%t) - "
                          "TAO_Notify_StructuredEvent::do_push ("
                          "CosNotifyComm::StructuredPushConsumer_ptr)\n"));

  consumer->push (*this->notification_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_Notify_StructuredEvent_No_Copy::push (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) const
{
  forwarder->forward_structured (*this->notification_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_Notify_StructuredEvent_No_Copy::push_no_filtering (Event_Forwarder::StructuredProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) const
{
  forwarder->forward_structured_no_filtering (*this->notification_ ACE_ENV_ARG_PARAMETER);
}

void
TAO_Notify_StructuredEvent_No_Copy::push (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) const
{
  CORBA::Any any;

  TAO_Notify_Event::translate (*this->notification_, any);

  forwarder->forward_any (any ACE_ENV_ARG_PARAMETER);
}

void
TAO_Notify_StructuredEvent_No_Copy::push_no_filtering (Event_Forwarder::ProxyPushSupplier_ptr forwarder ACE_ENV_ARG_DECL) const
{
  CORBA::Any any;

  TAO_Notify_Event::translate (*this->notification_, any);

  forwarder->forward_any_no_filtering (any ACE_ENV_ARG_PARAMETER);
}

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

TAO_Notify_StructuredEvent::TAO_Notify_StructuredEvent (const CosNotification::StructuredEvent& notification)
  : TAO_Notify_StructuredEvent_No_Copy (notification)
    , notification_copy (notification)
{
  this->notification_ = &notification_copy;
}

TAO_Notify_StructuredEvent::~TAO_Notify_StructuredEvent ()
{
}