summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Notify/ProxySupplier_T.cpp
blob: af9dfa473e1a56b0c4781f0eba60229a62cccc29 (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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
// $Id$

#ifndef TAO_Notify_PROXYSUPPLIER_T_CPP
#define TAO_Notify_PROXYSUPPLIER_T_CPP

#include "orbsvcs/Notify/ProxySupplier_T.h"

#include "orbsvcs/Notify/Consumer.h"
#include "orbsvcs/Notify/Structured/StructuredEvent.h"
#include "orbsvcs/Notify/Any/AnyEvent.h"

#include "orbsvcs/Notify/Method_Request_Dispatch.h"
#include "orbsvcs/Notify/Worker_Task.h"
#include "orbsvcs/Notify/Event_Manager.h"
#include "orbsvcs/Notify/ConsumerAdmin.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

template <class SERVANT_TYPE>
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::TAO_Notify_ProxySupplier_T (void)
  : is_suspended_ (0)
{
}

template <class SERVANT_TYPE>
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::~TAO_Notify_ProxySupplier_T ()
{
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::admin_types_changed (const CosNotification::EventTypeSeq & added,
                                                           const CosNotification::EventTypeSeq & removed)
{
  this->subscription_change (added, removed);
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_structured (const CosNotification::StructuredEvent& notification)
{
  TAO_Notify_StructuredEvent_No_Copy event (notification);

  TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 1);

  this->execute_task (request);
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_structured_no_filtering (const CosNotification::StructuredEvent& notification)
{
  TAO_Notify_StructuredEvent_No_Copy event(notification);

  TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 0);

  this->execute_task (request);
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_any (const CORBA::Any & any)
{
  TAO_Notify_AnyEvent_No_Copy event (any);

  TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 1);

  this->execute_task (request);
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::forward_any_no_filtering (const CORBA::Any& any)
{
  TAO_Notify_AnyEvent_No_Copy event(any);

  TAO_Notify_Method_Request_Dispatch_No_Copy request (&event, this, 0);

  this->execute_task (request);
}

template <class SERVANT_TYPE> CosNotification::EventTypeSeq*
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::obtain_offered_types (CosNotifyChannelAdmin::ObtainInfoMode mode)
{
  return this->obtain_types (mode, this->event_manager().offered_types ());
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::subscription_change (const CosNotification::EventTypeSeq & added,
                                                           const CosNotification::EventTypeSeq & removed)
{
  TAO_Notify_EventTypeSeq seq_added (added);
  TAO_Notify_EventTypeSeq seq_removed (removed);

  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_,
                        CORBA::INTERNAL ());

    this->subscribed_types_.add_and_remove (seq_added, seq_removed);
  }

  this->event_manager().subscription_change (this, seq_added, seq_removed);
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::suspend_connection (void)
{
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ());

    if (this->is_connected () == 0)
      throw CosNotifyChannelAdmin::NotConnected ();

    if (this->consumer()->is_suspended () == 1)
      throw CosNotifyChannelAdmin::ConnectionAlreadyInactive ();
  }

  this->consumer()->suspend ();
  this->self_change ();
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::resume_connection (void)
{
  {
    ACE_GUARD_THROW_EX (TAO_SYNCH_MUTEX, ace_mon, this->lock_, CORBA::INTERNAL ());

    if (this->is_connected () == 0)
      throw CosNotifyChannelAdmin::NotConnected ();

    if (this->consumer()->is_suspended () == 0)
      throw CosNotifyChannelAdmin::ConnectionAlreadyActive ();
  }

  this->consumer()->resume ();
}

template <class SERVANT_TYPE> CosNotifyChannelAdmin::ConsumerAdmin_ptr
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::MyAdmin (void)
{
  CosNotifyChannelAdmin::ConsumerAdmin_var ret;

  CORBA::Object_var object = this->consumer_admin().ref ();

  ret = CosNotifyChannelAdmin::ConsumerAdmin::_narrow (object.in ());

  return ret._retn ();
}

/***************************** UNIMPLEMENTED METHODS***************************************/

template <class SERVANT_TYPE> CosNotifyFilter::MappingFilter_ptr
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::priority_filter (void)
{
  throw CORBA::NO_IMPLEMENT ();
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::priority_filter (CosNotifyFilter::MappingFilter_ptr /*priority_filter*/)
{
  throw CORBA::NO_IMPLEMENT ();
}

template <class SERVANT_TYPE> CosNotifyFilter::MappingFilter_ptr
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::lifetime_filter (void)
{
  throw CORBA::NO_IMPLEMENT ();
}

template <class SERVANT_TYPE> void
TAO_Notify_ProxySupplier_T<SERVANT_TYPE>::lifetime_filter (CosNotifyFilter::MappingFilter_ptr /*lifetime_filter*/)
{
  throw CORBA::NO_IMPLEMENT ();
}

TAO_END_VERSIONED_NAMESPACE_DECL

#endif /* #define TAO_Notify_PROXYSUPPLIER_T_CPP */