Flows_T.cpp

Go to the documentation of this file.
00001 //Flows_T.cpp,v 5.12 2006/03/14 06:14:24 jtc Exp
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   ACE_DECLARE_NEW_CORBA_ENV;
00026   ACE_TRY
00027     {
00028       CORBA::Any flowname_any;
00029       flowname_any <<= flowname;
00030       this->define_property ("Flow",
00031                              flowname_any
00032                              ACE_ENV_ARG_PARAMETER);
00033       ACE_TRY_CHECK;
00034     }
00035   ACE_CATCHANY
00036     {
00037       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::TAO_FDev");
00038     }
00039   ACE_ENDTRY;
00040   ACE_CHECK;
00041 }
00042 
00043 template <class T_Producer, class T_Consumer>
00044 TAO_FDev<T_Producer, T_Consumer>::~TAO_FDev (void)
00045 {
00046   //no-op
00047 }
00048 
00049 template <class T_Producer, class T_Consumer>
00050 const char *
00051 TAO_FDev<T_Producer, T_Consumer>::flowname (void)
00052 {
00053   return this->flowname_.in ();
00054 }
00055 
00056 template <class T_Producer, class T_Consumer>
00057 void
00058 TAO_FDev<T_Producer, T_Consumer>::flowname (const char *flow_name)
00059 {
00060   ACE_DECLARE_NEW_CORBA_ENV;
00061   ACE_TRY
00062     {
00063       CORBA::Any flowname_any;
00064       flowname_any <<= flow_name;
00065       this->define_property ("Flow",
00066                              flowname_any
00067                              ACE_ENV_ARG_PARAMETER);
00068       ACE_TRY_CHECK;
00069     }
00070   ACE_CATCHANY
00071     {
00072       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::flowname");
00073     }
00074   ACE_ENDTRY;
00075   ACE_CHECK;
00076   this->flowname_ = flow_name;
00077 }
00078 
00079 template <class T_Producer, class T_Consumer>
00080 AVStreams::FlowProducer_ptr
00081 TAO_FDev<T_Producer, T_Consumer>::create_producer (AVStreams::FlowConnection_ptr the_requester,
00082                                                    AVStreams::QoS & the_qos,
00083                                                    CORBA::Boolean_out met_qos,
00084                                                    char *& named_fdev
00085                                                    ACE_ENV_ARG_DECL)
00086   ACE_THROW_SPEC ((CORBA::SystemException,
00087                    AVStreams::streamOpFailed,
00088                    AVStreams::streamOpDenied,
00089                    AVStreams::notSupported,
00090                    AVStreams::QoSRequestFailed))
00091 {
00092   // call the bridge method.
00093   return this->make_producer (the_requester,
00094                               the_qos,
00095                               met_qos,
00096                               named_fdev
00097                               ACE_ENV_ARG_PARAMETER);
00098 }
00099 
00100 template <class T_Producer, class T_Consumer>
00101 // hook for the applications to override the creation process.
00102 AVStreams::FlowProducer_ptr
00103 TAO_FDev<T_Producer, T_Consumer>::make_producer (AVStreams::FlowConnection_ptr /* the_requester */,
00104                                                  AVStreams::QoS & /* the_qos */,
00105                                                  CORBA::Boolean_out /* met_qos */,
00106                                                  char *& /* named_fdev */
00107                                                  ACE_ENV_ARG_DECL)
00108 {
00109   AVStreams::FlowProducer_ptr producer = AVStreams::FlowProducer::_nil ();
00110   ACE_TRY
00111     {
00112       // Activate the producer implementation under the Root POA.
00113       T_Producer *producer_i;
00114       ACE_NEW_RETURN (producer_i, T_Producer, 0);
00115       this->producer_list_.insert_tail (producer_i);
00116       producer = producer_i->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00117       ACE_TRY_CHECK;
00118     }
00119   ACE_CATCHANY
00120     {
00121       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::make_producer");
00122       return producer;
00123     }
00124   ACE_ENDTRY;
00125   ACE_CHECK_RETURN (producer);
00126   return producer;
00127 }
00128 
00129 template <class T_Producer, class T_Consumer>
00130 // hook for the applications to override the consumer creation.
00131 AVStreams::FlowConsumer_ptr
00132 TAO_FDev<T_Producer, T_Consumer>::make_consumer (AVStreams::FlowConnection_ptr /* the_requester */,
00133                                                  AVStreams::QoS & /* the_qos */,
00134                                                  CORBA::Boolean_out /* met_qos */,
00135                                                  char *& /* named_fdev */
00136                                                  ACE_ENV_ARG_DECL)
00137 {
00138   AVStreams::FlowConsumer_ptr consumer = AVStreams::FlowConsumer::_nil ();
00139   ACE_TRY
00140     {
00141       // Activate the consumer implementation under the Root POA.
00142       T_Consumer *consumer_i;
00143       ACE_NEW_RETURN (consumer_i, T_Consumer, 0 );
00144 
00145       this->consumer_list_.insert_tail (consumer_i);
00146       consumer = consumer_i->_this (ACE_ENV_SINGLE_ARG_PARAMETER);
00147       ACE_TRY_CHECK;
00148     }
00149   ACE_CATCHANY
00150     {
00151       ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"TAO_FDev::make_consumer");
00152       return consumer;
00153     }
00154   ACE_ENDTRY;
00155   ACE_CHECK_RETURN (consumer);
00156   return consumer;
00157 }
00158 
00159 template <class T_Producer, class T_Consumer>
00160 AVStreams::FlowConsumer_ptr
00161 TAO_FDev<T_Producer, T_Consumer>::create_consumer (AVStreams::FlowConnection_ptr the_requester,
00162                                                    AVStreams::QoS & the_qos,
00163                                                    CORBA::Boolean_out met_qos,
00164                                                    char *& named_fdev
00165                                                    ACE_ENV_ARG_DECL)
00166   ACE_THROW_SPEC ((CORBA::SystemException,
00167                    AVStreams::streamOpFailed,
00168                    AVStreams::streamOpDenied,
00169                    AVStreams::notSupported,
00170                    AVStreams::QoSRequestFailed))
00171 {
00172   return this->make_consumer (the_requester,
00173                               the_qos,
00174                               met_qos,
00175                               named_fdev
00176                               ACE_ENV_ARG_PARAMETER);
00177 }
00178 
00179 template <class T_Producer, class T_Consumer>
00180 // not implemented yet.
00181 AVStreams::FlowConnection_ptr
00182 TAO_FDev<T_Producer, T_Consumer>::bind (AVStreams::FDev_ptr peer_device,
00183                                         AVStreams::QoS & the_qos,
00184                                         CORBA::Boolean_out is_met
00185                                         ACE_ENV_ARG_DECL)
00186   ACE_THROW_SPEC ((CORBA::SystemException,
00187                    AVStreams::streamOpFailed,
00188                    AVStreams::QoSRequestFailed))
00189 {
00190   ACE_UNUSED_ARG (peer_device);
00191   ACE_UNUSED_ARG (the_qos);
00192   ACE_UNUSED_ARG (is_met);
00193   ACE_CHECK_RETURN (0);
00194   return 0;
00195 }
00196 
00197 template <class T_Producer, class T_Consumer>
00198 // multicast is not supported yet.
00199 AVStreams::FlowConnection_ptr
00200 TAO_FDev<T_Producer, T_Consumer>::bind_mcast (AVStreams::FDev_ptr first_peer,
00201                                               AVStreams::QoS & the_qos,
00202                                               CORBA::Boolean_out is_met
00203                                               ACE_ENV_ARG_DECL)
00204   ACE_THROW_SPEC ((CORBA::SystemException,
00205                    AVStreams::streamOpFailed,
00206                    AVStreams::QoSRequestFailed))
00207 {
00208   ACE_UNUSED_ARG (first_peer);
00209   ACE_UNUSED_ARG (the_qos);
00210   ACE_UNUSED_ARG (is_met);
00211   ACE_CHECK_RETURN (0);
00212   return 0;
00213 }
00214 
00215 template <class T_Producer, class T_Consumer>
00216 void
00217 TAO_FDev<T_Producer, T_Consumer>::destroy (AVStreams::FlowEndPoint_ptr /* the_ep */,
00218                                            const char * /* fdev_name */
00219                                            ACE_ENV_ARG_DECL_NOT_USED)
00220   ACE_THROW_SPEC ((CORBA::SystemException,
00221                    AVStreams::notSupported))
00222 {
00223   // @@ Shouldn't the parameters be made use of!
00224   // Destroy/delete all the producers and consumers.
00225 
00226   TAO_FlowProducer *producer_i;
00227 
00228   for (PRODUCER_LIST_ITERATOR producer_list_iterator (this->producer_list_);
00229        (producer_i = producer_list_iterator.next ()) != 0;
00230        producer_list_iterator.advance ())
00231     {
00232       TAO_AV_Core::deactivate_servant (producer_i);
00233       delete producer_i;
00234     }
00235 
00236   TAO_FlowConsumer *consumer_i;
00237 
00238   for (CONSUMER_LIST_ITERATOR consumer_list_iterator (this->consumer_list_);
00239        (consumer_i = consumer_list_iterator.next ()) != 0;
00240        consumer_list_iterator.advance ())
00241     {
00242       TAO_AV_Core::deactivate_servant (consumer_i);
00243       delete consumer_i;
00244     }
00245   int result = TAO_AV_Core::deactivate_servant (this);
00246   if (result < 0)
00247     if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"TAO_StreamEndPoint::destroy failed\n"));
00248 }
00249 
00250 TAO_END_VERSIONED_NAMESPACE_DECL
00251 
00252 #endif /* TAO_AV_FLOWS_T_CPP */

Generated on Thu Nov 9 13:44:41 2006 for TAO_AV by doxygen 1.3.6