Transport_Connector.h

Go to the documentation of this file.
00001 // This may look like C, but it's really -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file Transport_Connector.h
00006  *
00007  *  Transport_Connector.h,v 1.23 2006/04/26 17:12:48 mesnier_p Exp
00008  *
00009  *  Define the interface for the Connector component in TAO's
00010  *  pluggable protocol framework.
00011  *
00012  *  @author  Fred Kuhns <fredk@cs.wustl.edu>
00013  */
00014 //=============================================================================
00015 
00016 #ifndef TAO_CONNECTOR_H
00017 #define TAO_CONNECTOR_H
00018 
00019 #include /**/ "ace/pre.h"
00020 #include "ace/CORBA_macros.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #include "tao/TAO_Export.h"
00027 #include "tao/Basic_Types.h"
00028 
00029 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00030 class ACE_Time_Value;
00031 ACE_END_VERSIONED_NAMESPACE_DECL
00032 
00033 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00034 
00035 class TAO_Transport_Descriptor_Interface;
00036 class TAO_InputCDR;
00037 class TAO_Endpoint;
00038 class TAO_Profile;
00039 class TAO_MProfile;
00040 class TAO_ORB_Core;
00041 class TAO_Connect_Strategy;
00042 class TAO_Transport;
00043 class TAO_Connection_Handler;
00044 class TAO_LF_Multi_Event;
00045 
00046 namespace TAO
00047 {
00048   class Profile_Transport_Resolver;
00049 }
00050 
00051 namespace CORBA
00052 {
00053   class Environment;
00054 }
00055 
00056 /*
00057  * Hook to add includes and forward declaration
00058  * to the Connector class.
00059  */
00060 //@@ TAO_CONNECTOR_SPL_INCLUDE_FORWARD_DECL_ADD_HOOK
00061 
00062 /**
00063  * @class TAO_Connector
00064  *
00065  * @brief Generic Connector interface definitions.
00066  *
00067  * Base class for connector bridge object.
00068  *
00069  * @todo Need to rename the class as TAO_Transport_Connector.
00070  */
00071 class TAO_Export TAO_Connector
00072 {
00073 public:
00074 
00075   /// Default constructor.
00076   TAO_Connector (CORBA::ULong tag);
00077 
00078   /// The destructor.
00079   virtual ~TAO_Connector (void);
00080 
00081   /**
00082    * The tag identifying the specific ORB transport layer protocol.
00083    * For example IOP::TAG_INTERNET_IOP == 0.  The tag is used in the
00084    * IOR to identify the type of profile included. IOR -> {{tag0,
00085    * profile0} {tag1, profile1} ...}.  The IOP module defines the
00086    * ProfileId typedef to be a CORBA::ULong.
00087    */
00088   CORBA::ULong tag (void) const;
00089 
00090   /// Parse a string containing a URL style IOR and return an
00091   /// MProfile.  Verify that ior is in the correct format.
00092   int make_mprofile (
00093       const char *ior,
00094       TAO_MProfile &mprofile
00095       ACE_ENV_ARG_DECL);
00096 
00097   /// Helper function to assist corbaloc parsing. The default simply validates
00098   /// the protocol identifyier and scans up to the next comma or slash.
00099   /// Any protocol that has a specific need, such as uiop, can override this
00100   /// method to  provide a custom scanner.
00101   /// The profile returned is either null if this the ior does not match or an
00102   /// empty profile of the correct type, obtained from make_profile().
00103   virtual TAO_Profile * corbaloc_scan (const char *ior,
00104                                        size_t &len
00105                                        ACE_ENV_ARG_DECL);
00106 
00107   ///  Initialize object and register with reactor.
00108   virtual int open (
00109       TAO_ORB_Core *orb_core) = 0;
00110 
00111   /// Shutdown Connector bridge and concrete Connector.
00112   virtual int close (void) = 0;
00113 
00114   /**
00115    * To support pluggable we need to abstract away the details of the
00116    * connect ()  method so it can be called from the invocation code
00117    * independent of the actual transport protocol in use.
00118    */
00119   virtual TAO_Transport* connect (
00120       TAO::Profile_Transport_Resolver *r,
00121       TAO_Transport_Descriptor_Interface *desc,
00122       ACE_Time_Value *timeout
00123       ACE_ENV_ARG_DECL);
00124 
00125   /// A variation on connect that will try simultanious connections
00126   /// on all endpoints listed in the desc.
00127   virtual TAO_Transport* parallel_connect (
00128       TAO::Profile_Transport_Resolver *r,
00129       TAO_Transport_Descriptor_Interface *desc,
00130       ACE_Time_Value *timeout
00131       ACE_ENV_ARG_DECL);
00132 
00133   /// Create a profile for this protocol and initialize it based on the
00134   /// encapsulation in @a cdr
00135   virtual TAO_Profile *create_profile (
00136       TAO_InputCDR& cdr) = 0;
00137 
00138   /// Check that the prefix of the provided endpoint is valid for use
00139   /// with a given pluggable protocol.
00140   virtual int check_prefix (
00141       const char *endpoint) = 0;
00142 
00143   /// Return the object key delimiter to use or expect.
00144   virtual char object_key_delimiter (void) const = 0;
00145 
00146   //@@ TAO_CONNECTOR_SPL_PUBLIC_METHODS_ADD_HOOK
00147 
00148 protected:
00149   /// A flag indicating the actual connector supports parallel connection
00150   /// attempts. The base implementation alwayse returns 0. Override to return
00151   /// non-zero if parallel connection attempts may be tried.
00152   virtual int supports_parallel_connects (void) const;
00153 
00154   /// Create a profile with a given endpoint.
00155   virtual TAO_Profile *make_profile (ACE_ENV_SINGLE_ARG_DECL) = 0;
00156 
00157   /// Set and validate endpoint. We need to do this to initialize our
00158   /// remote *_Addr's which have not been done during IOR decode.
00159   virtual int set_validate_endpoint (TAO_Endpoint *endpoint) = 0;
00160 
00161   /// Make a connection
00162   virtual TAO_Transport* make_connection (
00163       TAO::Profile_Transport_Resolver *r,
00164       TAO_Transport_Descriptor_Interface &desc,
00165       ACE_Time_Value *timeout) = 0;
00166 
00167   /// Make a connection using - not a pure virtual since not all
00168   /// protocols support this.
00169   virtual TAO_Transport* make_parallel_connection (
00170       TAO::Profile_Transport_Resolver *r,
00171       TAO_Transport_Descriptor_Interface &desc,
00172       ACE_Time_Value *timeout);
00173 
00174   /// Cancel the passed cvs handler from the connector
00175   virtual int cancel_svc_handler (
00176       TAO_Connection_Handler *svc_handler) = 0;
00177 
00178   /// Check whether the connection is not closed
00179   /**
00180    * @retval 0 The connection happens to be not closed, but is now open
00181    * because an other thread managed to open the handler
00182    * @retval -1 The connection is closed
00183    */
00184   virtual int check_connection_closure (
00185       TAO_Connection_Handler *connection_handler);
00186 
00187   /**
00188    * Wait for connection completion. We have a transport that is not
00189    * connected yet, wait until it is connected.
00190    * @retval true When we could use @a transport
00191    * @return false When we can't use the @a transport
00192    */
00193   virtual bool wait_for_connection_completion(
00194       TAO::Profile_Transport_Resolver *r,
00195       TAO_Transport *&transport,
00196       ACE_Time_Value *timeout);
00197 
00198   /// In the case of a parallel connection attempt, we take an array of
00199   /// transports, and wait on any of them. When the first one completes,
00200   /// the rest are closed.
00201   virtual bool wait_for_connection_completion(
00202       TAO::Profile_Transport_Resolver *r,
00203       TAO_Transport *&the_winner,
00204       TAO_Transport **transport,
00205       unsigned int count,
00206       TAO_LF_Multi_Event *mev,
00207       ACE_Time_Value *timeout);
00208 
00209   /// Set the ORB Core pointer
00210   void orb_core (TAO_ORB_Core *orb_core);
00211 
00212   /// Create a connect strategy
00213   int create_connect_strategy (void);
00214 
00215   /// Return the TAO_ORB_Core pointer
00216   TAO_ORB_Core *orb_core (void);
00217 
00218 protected:
00219 
00220   /// The (a)synch connect strategy
00221   TAO_Connect_Strategy *active_connect_strategy_;
00222 
00223 private:
00224 
00225   /// IOP protocol tag.
00226   CORBA::ULong const tag_;
00227 
00228   /// Pointer to our ORB core
00229   TAO_ORB_Core *orb_core_;
00230 
00231   //@@ TAO_CONNECTOR_SPL_PRIVATE_DATA_ADD_HOOK
00232 };
00233 
00234 //@@ TAO_CONNECTOR_SPL_EXTERN_ADD_HOOK
00235 
00236 TAO_END_VERSIONED_NAMESPACE_DECL
00237 
00238 #if defined (__ACE_INLINE__)
00239 # include "tao/Transport_Connector.inl"
00240 #endif /* __ACE_INLINE__ */
00241 
00242 #include /**/ "ace/post.h"
00243 #endif /*TAO_CONNECTOR_H*/

Generated on Thu Nov 9 11:54:27 2006 for TAO by doxygen 1.3.6