Flows_T.cpp

Go to the documentation of this file.
00001 //$Id: Flows_T.cpp 81499 2008-04-28 17:58:17Z johnnyw $
00002 
00003 #ifndef TAO_AV_FLOWS_T_CPP
00004 #define TAO_AV_FLOWS_T_CPP
00005 
00006 #include "orbsvcs/AV/Flows_T.h"
00007 #include "tao/debug.h"
00008 
00009 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00010 
00011 // ------------------------------------------------------------
00012 // TAO_FDev
00013 // ------------------------------------------------------------
00014 
00015 // default constructor
00016 template <class T_Producer, class T_Consumer>
00017 TAO_FDev<T_Producer, T_Consumer>::TAO_FDev (void)
00018 {
00019 }
00020 
00021 template <class T_Producer, class T_Consumer>
00022 TAO_FDev<T_Producer, T_Consumer>::TAO_FDev (const char *flowname)
00023   :flowname_ (flowname)
00024 {
00025   try
00026     {
00027       CORBA::Any flowname_any;
00028       flowname_any <<= flowname;
00029       this->define_property ("Flow",
00030                              flowname_any);
00031     }
00032   catch (const CORBA::Exception& ex)
00033     {
00034       ex._tao_print_exception ("TAO_FDev::TAO_FDev");
00035     }
00036 }
00037 
00038 template <class T_Producer, class T_Consumer>
00039 TAO_FDev<T_Producer, T_Consumer>::~TAO_FDev (void)
00040 {
00041   //no-op
00042 }
00043 
00044 template <class T_Producer, class T_Consumer>
00045 const char *
00046 TAO_FDev<T_Producer, T_Consumer>::flowname (void)
00047 {
00048   return this->flowname_.in ();
00049 }
00050 
00051 template <class T_Producer, class T_Consumer>
00052 void
00053 TAO_FDev<T_Producer, T_Consumer>::flowname (const char *flow_name)
00054 {
00055   try
00056     {
00057       CORBA::Any flowname_any;
00058       flowname_any <<= flow_name;
00059       this->define_property ("Flow",
00060                              flowname_any);
00061     }
00062   catch (const CORBA::Exception& ex)
00063     {
00064       ex._tao_print_exception ("TAO_FDev::flowname");
00065     }
00066   this->flowname_ = flow_name;
00067 }
00068 
00069 template <class T_Producer, class T_Consumer>
00070 AVStreams::FlowProducer_ptr
00071 TAO_FDev<T_Producer, T_Consumer>::create_producer (AVStreams::FlowConnection_ptr the_requester,
00072                                                    AVStreams::QoS & the_qos,
00073                                                    CORBA::Boolean_out met_qos,
00074                                                    char *& named_fdev)
00075 {
00076   // call the bridge method.
00077   return this->make_producer (the_requester,
00078                               the_qos,
00079                               met_qos,
00080                               named_fdev);
00081 }
00082 
00083 template <class T_Producer, class T_Consumer>
00084 // hook for the applications to override the creation process.
00085 AVStreams::FlowProducer_ptr
00086 TAO_FDev<T_Producer, T_Consumer>::make_producer (AVStreams::FlowConnection_ptr /* the_requester */,
00087                                                  AVStreams::QoS & /* the_qos */,
00088                                                  CORBA::Boolean_out /* met_qos */,
00089                                                  char *& /* named_fdev */)
00090 {
00091   AVStreams::FlowProducer_ptr producer = AVStreams::FlowProducer::_nil ();
00092   try
00093     {
00094       // Activate the producer implementation under the Root POA.
00095       T_Producer *producer_i = 0;
00096       ACE_NEW_RETURN (producer_i, T_Producer, 0);
00097       this->producer_list_.insert_tail (producer_i);
00098       producer = producer_i->_this ();
00099     }
00100   catch (const CORBA::Exception& ex)
00101     {
00102       ex._tao_print_exception ("TAO_FDev::make_producer");
00103       return producer;
00104     }
00105   return producer;
00106 }
00107 
00108 template <class T_Producer, class T_Consumer>
00109 // hook for the applications to override the consumer creation.
00110 AVStreams::FlowConsumer_ptr
00111 TAO_FDev<T_Producer, T_Consumer>::make_consumer (AVStreams::FlowConnection_ptr /* the_requester */,
00112                                                  AVStreams::QoS & /* the_qos */,
00113                                                  CORBA::Boolean_out /* met_qos */,
00114                                                  char *& /* named_fdev */)
00115 {
00116   AVStreams::FlowConsumer_ptr consumer = AVStreams::FlowConsumer::_nil ();
00117   try
00118     {
00119       // Activate the consumer implementation under the Root POA.
00120       T_Consumer *consumer_i;
00121       ACE_NEW_RETURN (consumer_i, T_Consumer, 0 );
00122 
00123       this->consumer_list_.insert_tail (consumer_i);
00124       consumer = consumer_i->_this ();
00125     }
00126   catch (const CORBA::Exception& ex)
00127     {
00128       ex._tao_print_exception ("TAO_FDev::make_consumer");
00129       return consumer;
00130     }
00131   return consumer;
00132 }
00133 
00134 template <class T_Producer, class T_Consumer>
00135 AVStreams::FlowConsumer_ptr
00136 TAO_FDev<T_Producer, T_Consumer>::create_consumer (AVStreams::FlowConnection_ptr the_requester,
00137                                                    AVStreams::QoS & the_qos,
00138                                                    CORBA::Boolean_out met_qos,
00139                                                    char *& named_fdev)
00140 {
00141   return this->make_consumer (the_requester,
00142                               the_qos,
00143                               met_qos,
00144                               named_fdev);
00145 }
00146 
00147 template <class T_Producer, class T_Consumer>
00148 // not implemented yet.
00149 AVStreams::FlowConnection_ptr
00150 TAO_FDev<T_Producer, T_Consumer>::bind (AVStreams::FDev_ptr peer_device,
00151                                         AVStreams::QoS & the_qos,
00152                                         CORBA::Boolean_out is_met)
00153 {
00154   ACE_UNUSED_ARG (peer_device);
00155   ACE_UNUSED_ARG (the_qos);
00156   ACE_UNUSED_ARG (is_met);
00157   return 0;
00158 }
00159 
00160 template <class T_Producer, class T_Consumer>
00161 // multicast is not supported yet.
00162 AVStreams::FlowConnection_ptr
00163 TAO_FDev<T_Producer, T_Consumer>::bind_mcast (AVStreams::FDev_ptr first_peer,
00164                                               AVStreams::QoS & the_qos,
00165                                               CORBA::Boolean_out is_met)
00166 {
00167   ACE_UNUSED_ARG (first_peer);
00168   ACE_UNUSED_ARG (the_qos);
00169   ACE_UNUSED_ARG (is_met);
00170   return 0;
00171 }
00172 
00173 template <class T_Producer, class T_Consumer>
00174 void
00175 TAO_FDev<T_Producer, T_Consumer>::destroy (AVStreams::FlowEndPoint_ptr /* the_ep */,
00176                                            const char * /* fdev_name */)
00177 {
00178   // @@ Shouldn't the parameters be made use of!
00179   // Destroy/delete all the producers and consumers.
00180 
00181   TAO_FlowProducer *producer_i;
00182 
00183   for (PRODUCER_LIST_ITERATOR producer_list_iterator (this->producer_list_);
00184        (producer_i = producer_list_iterator.next ()) != 0;
00185        producer_list_iterator.advance ())
00186     {
00187       TAO_AV_Core::deactivate_servant (producer_i);
00188       delete producer_i;
00189     }
00190 
00191   TAO_FlowConsumer *consumer_i;
00192 
00193   for (CONSUMER_LIST_ITERATOR consumer_list_iterator (this->consumer_list_);
00194        (consumer_i = consumer_list_iterator.next ()) != 0;
00195        consumer_list_iterator.advance ())
00196     {
00197       TAO_AV_Core::deactivate_servant (consumer_i);
00198       delete consumer_i;
00199     }
00200   int result = TAO_AV_Core::deactivate_servant (this);
00201   if (result < 0)
00202     if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_StreamEndPoint::destroy failed\n"));
00203 }
00204 
00205 TAO_END_VERSIONED_NAMESPACE_DECL
00206 
00207 #endif /* TAO_AV_FLOWS_T_CPP */

Generated on Tue Feb 2 17:47:49 2010 for TAO_AV by  doxygen 1.4.7