Transport_Acceptor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file Transport_Acceptor.h
00006  *
00007  *  $Id: Transport_Acceptor.h 81472 2008-04-28 12:46:33Z elliott_c $
00008  *
00009  *  Interface for the Acceptor component of the TAO pluggable protocol
00010  *  framework.
00011  *
00012  *  @author  Fred Kuhns <fredk@cs.wustl.edu>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef TAO_ACCEPTOR_H
00017 #define TAO_ACCEPTOR_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include /**/ "tao/TAO_Export.h"
00022 
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 # pragma once
00025 #endif /* ACE_LACKS_PRAGMA_ONCE */
00026 
00027 #include "ace/Acceptor.h"
00028 #include "tao/Basic_Types.h"
00029 
00030 // Forward declarations.
00031 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00032 class ACE_Addr;
00033 class ACE_Reactor;
00034 ACE_END_VERSIONED_NAMESPACE_DECL
00035 
00036 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00037 
00038 class TAO_ORB_Core;
00039 class TAO_MProfile;
00040 class TAO_Endpoint;
00041 class TAO_Transport;
00042 
00043 namespace IOP
00044 {
00045   struct TaggedProfile;
00046 }
00047 
00048 namespace TAO
00049 {
00050   class ObjectKey;
00051 }
00052 
00053 //@@ TAO_ACCEPTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
00054 
00055 // ****************************************************************
00056 
00057 /// The TAO-specific OMG assigned value for the TAG_ORB_TYPE tagged
00058 /// component.
00059 /**
00060  * This number was assigned by the OMG.  Do *NOT* change.  The ASCII
00061  * representation is "TA\x00".  If necessary, we can request more ORB
00062  * types later.
00063  */
00064 const CORBA::ULong TAO_ORB_TYPE = 0x54414f00U;
00065 
00066 // ****************************************************************
00067 
00068 /**
00069  * @class TAO_Acceptor
00070  *
00071  * @brief Abstract Acceptor class used for pluggable transports.
00072  *
00073  * Base class for the Acceptor bridge class.
00074  *
00075  * @todo Need to rename the class as TAO_Transport_Acceptor.
00076  */
00077 class TAO_Export TAO_Acceptor
00078 {
00079 public:
00080   TAO_Acceptor (CORBA::ULong tag);
00081 
00082   /// Destructor
00083   virtual ~TAO_Acceptor (void);
00084 
00085   /// The tag, each concrete class will have a specific tag value.
00086   CORBA::ULong tag (void) const;
00087 
00088   /// Set the amount of time to delay accepting new connections in the
00089   /// event that we encounter an error that may be transient.
00090   void set_error_retry_delay (time_t delay);
00091 
00092   /// Method to initialize acceptor for address.
00093   virtual int open (TAO_ORB_Core *orb_core,
00094                     ACE_Reactor *reactor,
00095                     int version_major,
00096                     int version_minor,
00097                     const char *address,
00098                     const char *options = 0) = 0;
00099 
00100   /**
00101    * Open an acceptor with the given protocol version on a default
00102    * endpoint
00103    */
00104   virtual int open_default (TAO_ORB_Core *,
00105                             ACE_Reactor *reactor,
00106                             int version_major,
00107                             int version_minor,
00108                             const char *options = 0) = 0;
00109 
00110   /// Closes the acceptor
00111   virtual int close (void) = 0;
00112 
00113   /**
00114    * Create the corresponding profile for this endpoint.
00115    * If share_profile is set to true, the pluggable protocol
00116    * implementation should try to add the endpoint to a profile
00117    * in the mprofile that is of the same type.  Currently, this
00118    * is used when RT CORBA is enabled.
00119    */
00120   virtual int create_profile (const TAO::ObjectKey &object_key,
00121                               TAO_MProfile &mprofile,
00122                               CORBA::Short priority) = 0;
00123 
00124   /// Return 1 if the @a endpoint has the same address as the acceptor.
00125   virtual int is_collocated (const TAO_Endpoint *endpoint) = 0;
00126 
00127   /**
00128    * Returns the number of endpoints this acceptor is listening on.  This
00129    * is used for determining how many profiles will be generated
00130    * for this acceptor.
00131    */
00132   virtual CORBA::ULong endpoint_count (void) = 0;
00133 
00134   /**
00135    * This method fetches the @a key from the @a profile. Protocols that
00136    * are pluggable can send data that are specific in the
00137    * @c profile_data field encapsulated as a octet stream. This method
00138    * allows those  protocols to get the object key from the
00139    * encapsulation.
00140    */
00141   virtual int object_key (IOP::TaggedProfile &profile,
00142                           TAO::ObjectKey &key) = 0;
00143 
00144   /// This method is not directly associated with the method of the same
00145   /// name on the ACE_Acceptor template class.  However, it is called by
00146   /// the TAO_Strategy_Acceptor method of the same name.
00147   int handle_accept_error (ACE_Event_Handler* base_acceptor);
00148 
00149   /// Perform the handle_timeout functionality to put this acceptor back
00150   /// into the reactor to try accepting again.
00151   int handle_expiration (ACE_Event_Handler* base_acceptor);
00152 
00153   /*
00154    * Hook to add public methods from derived acceptor classes onto
00155    * this class.
00156    */
00157   //@@ TAO_ACCEPTOR_SPL_PUBLIC_METHODS_ADD_HOOK
00158 
00159 private:
00160   /// IOP protocol tag.
00161   CORBA::ULong const tag_;
00162 
00163   time_t error_retry_delay_;
00164 
00165   /*
00166    * Hook to add data members from concrete acceptor implementations onto
00167    * the base class.
00168    */
00169   //@@ TAO_ACCEPTOR_SPL_DATA_MEMBERS_ADD_HOOK
00170 };
00171 
00172 /// This is a drop-in replacement class for the ACE_Strategy_Acceptor. 
00173 /// It provides all of the same functionality and the additional
00174 /// functionality of handling accept() errors with some sort of
00175 /// configured action.  All of the actual code is in the TAO_Acceptor
00176 /// to avoid multiply-instantiated code that would be, in effect,
00177 /// identical.
00178 ///
00179 /// It is not declared nested within TAO_Acceptor as I originally wanted
00180 /// because it caused an internal compiler error for the Tornado 2.2.1
00181 /// compiler.
00182 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
00183 class TAO_Strategy_Acceptor:
00184   public ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>
00185 {
00186 public:
00187   TAO_Strategy_Acceptor (TAO_Acceptor* acceptor)
00188    : acceptor_ (acceptor) {
00189   }
00190 
00191   virtual int handle_accept_error (void) {
00192     return this->acceptor_->handle_accept_error (this);
00193   }
00194 
00195   virtual int handle_timeout (const ACE_Time_Value&,
00196                               const void*) {
00197     return this->acceptor_->handle_expiration (this);
00198   }
00199 
00200 private:
00201   TAO_Acceptor* acceptor_;
00202 };
00203 
00204 //@@ TAO_ACCEPTOR_SPL_EXTERN_ADD_HOOK
00205 
00206 TAO_END_VERSIONED_NAMESPACE_DECL
00207 
00208 #if defined (__ACE_INLINE__)
00209 # include "tao/Transport_Acceptor.inl"
00210 #endif /* __ACE_INLINE__ */
00211 
00212 #include /**/ "ace/post.h"
00213 
00214 #endif  /* TAO_ACCEPTOR_H */

Generated on Tue Feb 2 17:37:53 2010 for TAO by  doxygen 1.4.7