summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/AV/Flows_T.cpp
blob: 86cef7e0568212f0fdcac6ca3de47d29a5dc5daa (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
//$Id$

#ifndef TAO_AV_FLOWS_T_C
#define TAO_AV_FLOWS_T_C

#include "Flows_T.h"
#include "tao/debug.h"


// ------------------------------------------------------------
// TAO_FDev
// ------------------------------------------------------------

// default constructor
template <class T_Producer, class T_Consumer>
TAO_FDev<T_Producer, T_Consumer>::TAO_FDev (void)
{
}

template <class T_Producer, class T_Consumer>
TAO_FDev<T_Producer, T_Consumer>::TAO_FDev (const char *flowname)
  :flowname_ (flowname)
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      CORBA::Any flowname_any;
      flowname_any <<= flowname;
      this->define_property ("Flow",
                             flowname_any
                             ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::TAO_FDev");
    }
  ACE_ENDTRY;
  ACE_CHECK;
}

template <class T_Producer, class T_Consumer>
TAO_FDev<T_Producer, T_Consumer>::~TAO_FDev (void)
{
  //no-op
}

template <class T_Producer, class T_Consumer>
const char *
TAO_FDev<T_Producer, T_Consumer>::flowname (void)
{
  return this->flowname_.in ();
}

template <class T_Producer, class T_Consumer>
void
TAO_FDev<T_Producer, T_Consumer>::flowname (const char *flow_name)
{
  ACE_DECLARE_NEW_CORBA_ENV;
  ACE_TRY
    {
      CORBA::Any flowname_any;
      flowname_any <<= flow_name;
      this->define_property ("Flow",
                             flowname_any
                             ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::flowname");
    }
  ACE_ENDTRY;
  ACE_CHECK;
  this->flowname_ = flow_name;
}

template <class T_Producer, class T_Consumer>
AVStreams::FlowProducer_ptr
TAO_FDev<T_Producer, T_Consumer>::create_producer (AVStreams::FlowConnection_ptr the_requester,
                                                   AVStreams::QoS & the_qos,
                                                   CORBA::Boolean_out met_qos,
                                                   char *& named_fdev
                                                   ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   AVStreams::streamOpFailed,
                   AVStreams::streamOpDenied,
                   AVStreams::notSupported,
                   AVStreams::QoSRequestFailed))
{
  // call the bridge method.
  return this->make_producer (the_requester,
                              the_qos,
                              met_qos,
                              named_fdev
                              ACE_ENV_ARG_PARAMETER);
}

template <class T_Producer, class T_Consumer>
// hook for the applications to override the creation process.
AVStreams::FlowProducer_ptr
TAO_FDev<T_Producer, T_Consumer>::make_producer (AVStreams::FlowConnection_ptr /* the_requester */,
                                                 AVStreams::QoS & /* the_qos */,
                                                 CORBA::Boolean_out /* met_qos */,
                                                 char *& /* named_fdev */
                                                 ACE_ENV_ARG_DECL)
{
  AVStreams::FlowProducer_ptr producer = AVStreams::FlowProducer::_nil ();
  ACE_TRY
    {
      // Activate the producer implementation under the Root POA.
      T_Producer *producer_i;
      ACE_NEW_RETURN (producer_i, T_Producer, 0);
      this->producer_list_.insert_tail (producer_i);
      producer = producer_i->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::make_producer");
      return producer;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (producer);
  return producer;
}

template <class T_Producer, class T_Consumer>
// hook for the applications to override the consumer creation.
AVStreams::FlowConsumer_ptr
TAO_FDev<T_Producer, T_Consumer>::make_consumer (AVStreams::FlowConnection_ptr /* the_requester */,
                                                 AVStreams::QoS & /* the_qos */,
                                                 CORBA::Boolean_out /* met_qos */,
                                                 char *& /* named_fdev */
                                                 ACE_ENV_ARG_DECL)
{
  AVStreams::FlowConsumer_ptr consumer = AVStreams::FlowConsumer::_nil ();
  ACE_TRY
    {
      // Activate the consumer implementation under the Root POA.
      T_Consumer *consumer_i;
      ACE_NEW_RETURN (consumer_i, T_Consumer, 0 );

      this->consumer_list_.insert_tail (consumer_i);
      consumer = consumer_i->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_TRY_CHECK;
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::make_consumer");
      return consumer;
    }
  ACE_ENDTRY;
  ACE_CHECK_RETURN (consumer);
  return consumer;
}

template <class T_Producer, class T_Consumer>
AVStreams::FlowConsumer_ptr
TAO_FDev<T_Producer, T_Consumer>::create_consumer (AVStreams::FlowConnection_ptr the_requester,
                                                   AVStreams::QoS & the_qos,
                                                   CORBA::Boolean_out met_qos,
                                                   char *& named_fdev
                                                   ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   AVStreams::streamOpFailed,
                   AVStreams::streamOpDenied,
                   AVStreams::notSupported,
                   AVStreams::QoSRequestFailed))
{
  return this->make_consumer (the_requester,
                              the_qos,
                              met_qos,
                              named_fdev
                              ACE_ENV_ARG_PARAMETER);
}

template <class T_Producer, class T_Consumer>
// not implemented yet.
AVStreams::FlowConnection_ptr
TAO_FDev<T_Producer, T_Consumer>::bind (AVStreams::FDev_ptr peer_device,
                                        AVStreams::QoS & the_qos,
                                        CORBA::Boolean_out is_met
                                        ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   AVStreams::streamOpFailed,
                   AVStreams::QoSRequestFailed))
{
  ACE_UNUSED_ARG (peer_device);
  ACE_UNUSED_ARG (the_qos);
  ACE_UNUSED_ARG (is_met);
  ACE_CHECK_RETURN (0);
  return 0;
}

template <class T_Producer, class T_Consumer>
// multicast is not supported yet.
AVStreams::FlowConnection_ptr
TAO_FDev<T_Producer, T_Consumer>::bind_mcast (AVStreams::FDev_ptr first_peer,
                                              AVStreams::QoS & the_qos,
                                              CORBA::Boolean_out is_met
                                              ACE_ENV_ARG_DECL)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   AVStreams::streamOpFailed,
                   AVStreams::QoSRequestFailed))
{
  ACE_UNUSED_ARG (first_peer);
  ACE_UNUSED_ARG (the_qos);
  ACE_UNUSED_ARG (is_met);
  ACE_CHECK_RETURN (0);
  return 0;
}

template <class T_Producer, class T_Consumer>
void
TAO_FDev<T_Producer, T_Consumer>::destroy (AVStreams::FlowEndPoint_ptr /* the_ep */,
                                           const char * /* fdev_name */
                                           ACE_ENV_ARG_DECL_NOT_USED)
  ACE_THROW_SPEC ((CORBA::SystemException,
                   AVStreams::notSupported))
{
  // @@ Shouldn't the parameters be made use of!
  // Destroy/delete all the producers and consumers.

  TAO_FlowProducer *producer_i;

  for (PRODUCER_LIST_ITERATOR producer_list_iterator (this->producer_list_);
       (producer_i = producer_list_iterator.next ()) != 0;
       producer_list_iterator.advance ())
    {
      TAO_AV_Core::deactivate_servant (producer_i);
      delete producer_i;
    }

  TAO_FlowConsumer *consumer_i;

  for (CONSUMER_LIST_ITERATOR consumer_list_iterator (this->consumer_list_);
       (consumer_i = consumer_list_iterator.next ()) != 0;
       consumer_list_iterator.advance ())
    {
      TAO_AV_Core::deactivate_servant (consumer_i);
      delete consumer_i;
    }
  int result = TAO_AV_Core::deactivate_servant (this);
  if (result < 0)
    if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_StreamEndPoint::destroy failed\n"));
}

#endif /* TAO_AV_FLOWS_T_C */