Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Connection_Handler.h

Go to the documentation of this file.
00001 
00002 // -*- C++ -*-
00003 
00004 //=============================================================================
00005 /**
00006  *  @file   Connection_Handler.h
00007  *
00008  *  $Id: Connection_Handler.h,v 1.1.1.2 2003/02/21 18:36:44 chad Exp $
00009  *
00010  *  @author Balachandran Natarajan  <bala@cs.wustl.edu>
00011  */
00012 //=============================================================================
00013 
00014 #ifndef TAO_CONNECTION_HANDLER_H
00015 #define TAO_CONNECTION_HANDLER_H
00016 
00017 #include "ace/pre.h"
00018 
00019 #include "LF_CH_Event.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 
00026 class TAO_ORB_Core;
00027 class TAO_ORB_Core_TSS_Resources;
00028 class TAO_Transport;
00029 class ACE_SOCK;
00030 class ACE_Lock;
00031 class ACE_Event_Handler;
00032 
00033 /**
00034  * @class TAO_Connection_Handler
00035  *
00036  * @brief TAO_Connection_Handler
00037  *
00038  * This class is an abstraction for the connection handlers. The
00039  * connections handler in every protocol can derive from this
00040  * class as well as the ACE_Svc_Handler specialised for the
00041  * right protocol. This way, most of the common code for the
00042  * different protocols would be in this implementation.
00043  */
00044 class TAO_Export TAO_Connection_Handler : public TAO_LF_CH_Event
00045 {
00046 public:
00047 
00048   /// Constructor
00049   TAO_Connection_Handler (void);
00050 
00051   /// Constructor
00052   TAO_Connection_Handler (TAO_ORB_Core *orb_core);
00053 
00054   /// Destructor
00055   virtual ~TAO_Connection_Handler (void);
00056 
00057   /// Return the underlying transport object
00058   TAO_Transport *transport (void);
00059 
00060   /// Set the underlying transport object
00061   void transport (TAO_Transport* transport);
00062 
00063 # if 0
00064   /// NOTE: NO longer used
00065   /// Did the process of non-blocking connection initialization
00066   /// complete?
00067   int is_connect_complete (void) const;
00068 
00069   /// Was the non-blocking connection initialization successful?
00070   int is_connect_successful (void) const;
00071 #endif /*if 0*/
00072   /// Is the state final?
00073   int is_finalized (void);
00074 
00075   /// Increment and decrement the refcount. The object is deleted when
00076   /// the refcount reaches zero.
00077   long incr_refcount (void);
00078   long decr_refcount (void);
00079 
00080   /// Set the handler in <CODE>LF_EVENT_CONNECTION_CLOSE_WAIT </CODE>
00081   /// state
00082   void connection_close_wait (void);
00083 
00084   /// Close the underlying connection.
00085   /**
00086    * Used by the ORB to actively close connections that are idle,
00087    * stale or somehow are determined to be broken before the Reactor
00088    * does.
00089    *
00090    * @return Return 0 if the connection was already closed, non-zero
00091    * otherwise.
00092    */
00093   virtual int close_connection (void) = 0;
00094 
00095   /// The event handler calls, here so that other objects who hold a
00096   /// reference to this object can call the event handler methods.
00097   virtual int handle_input (ACE_HANDLE fd) = 0;
00098 
00099 protected:
00100 
00101   /// Return our TAO_ORB_Core pointer
00102   TAO_ORB_Core *orb_core (void);
00103 
00104   /// Return our TSS Resources pointer
00105   TAO_ORB_Core_TSS_Resources* tss_resources (void);
00106 
00107   /// Set options on the socket
00108   int set_socket_option (ACE_SOCK &sock,
00109                          int snd_size,
00110                          int rcv_size);
00111 
00112   /// This method is invoked from the svc () method of the Svc_Handler
00113   /// Object.
00114   int svc_i (void);
00115 
00116   /****
00117    * Not sure where they are defined and used.. Looks legacy.
00118    *
00119    * Increment and decrement the number of upcalls that have gone
00120    * this handler. Returns the upcall count. The calls are
00121    * safe..
00122    * int incr_pending_upcalls (void);
00123    * int decr_pending_upcalls (void);
00124    * int pending_upcalls (void) const;
00125    */
00126 
00127   //@{
00128   /**
00129    * @name Helper methods for Event_Handler-based derived classes.
00130    *
00131    * Many (actually all so far) implementations of
00132    * TAO_Connection_Handler are a mixin of TAO_Connection_Handler and
00133    * some form of ACE_Event_Handler.  The following methods simplify
00134    * such implementations by capturing the common code in a single
00135    * place.
00136    */
00137 
00138   /// Implement the handle_close() callback
00139   virtual int handle_close_eh (ACE_HANDLE h,
00140                                unsigned long reactor_mask,
00141                                ACE_Event_Handler * eh);
00142 
00143   /// Implement the handle_output() callback
00144   int handle_output_eh (ACE_HANDLE h, ACE_Event_Handler * eh);
00145 
00146   /// Implement the handle_input() callback
00147   int handle_input_eh (ACE_HANDLE h, ACE_Event_Handler * eh);
00148 
00149   /// Implement close_connection() for Connection_Handlers that are
00150   /// also Event_Handlers.
00151   int close_connection_eh (ACE_Event_Handler * eh);
00152 
00153   /// Release the OS resources related to this handler, used in
00154   /// handle_close_eh()
00155   virtual int release_os_resources (void);
00156 
00157   /// Pre-invocation hook for I/O operations (handle_input() &
00158   /// handle_output())
00159   /**
00160    * See the SSLIOP protocol for an interesting use-case
00161    */
00162   virtual void pre_io_hook (int & return_value);
00163 
00164   /// Post-invocation hook for I/O operations (handle_input() &
00165   /// handle_output())
00166   /**
00167    * See the SSLIOP protocol for an interesting use-case
00168    */
00169   virtual void pos_io_hook (int & return_value);
00170   //@}
00171 
00172 private:
00173   /// Pointer to the TAO_ORB_Core
00174   TAO_ORB_Core *orb_core_;
00175 
00176   /// Transport object reference
00177   TAO_Transport* transport_;
00178 
00179   /// Cached tss resources of the ORB that activated this object.
00180   TAO_ORB_Core_TSS_Resources *tss_resources_;
00181 
00182   /// Pretty obvious
00183   long reference_count_;
00184 
00185   /// Lock for the reference count
00186   ACE_Lock *refcount_lock_;
00187 
00188   /// Internal state lock, needs to be separate from the reference
00189   /// count / pending upcalls lock because they interleave.
00190   ACE_Lock * lock_;
00191 };
00192 
00193 #if defined (__ACE_INLINE__)
00194 #include "tao/Connection_Handler.inl"
00195 #endif /* __ACE_INLINE__ */
00196 
00197 #include "ace/post.h"
00198 
00199 #endif /*TAO_CONNECTION_HANDLER_H*/

Generated on Mon Jun 16 13:48:05 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002