Servant_Base.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Servant_Base.h
00006  *
00007  *  Servant_Base.h,v 1.35 2006/03/10 07:19:16 jtc Exp
00008  *
00009  *  @author  Irfan Pyarali <irfan@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_SERVANT_BASE_H
00014 #define TAO_SERVANT_BASE_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "tao/PortableServer/portableserver_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/PortableServer/PS_ForwardC.h"
00025 #include "tao/Abstract_Servant_Base.h"
00026 #include "ace/Atomic_Op.h"
00027 
00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 class TAO_Operation_Table;
00031 
00032 /**
00033  * @class TAO_ServantBase
00034  *
00035  * @brief Base class for skeletons and servants.
00036  *
00037  * The POA spec requires that all servants inherit from this class'
00038  * base class.
00039  *
00040  * An instance of a servant class derived from
00041  * ServantBase initially has a reference count of
00042  * one. Invoking _add_ref on the servant instance increases its
00043  * reference count by one. Invoking _remove_ref on the servant
00044  * instance decreases its reference count by one; if the
00045  * resulting reference count equals zero, _remove_ref invokes
00046  * delete on its this pointer in order to destroy the
00047  * servant. For ORBs that operate in multi-threaded
00048  * environments, the implementations of _add_ref and _remove_ref
00049  * that the ServantBase class provides shall be
00050  * thread-safe.
00051  *
00052  * Like ServantBase supports copy
00053  * construction and the default assignment operation. Copy
00054  * construction always sets the reference count of the new
00055  * servant instance to one. The default assignment
00056  * implementation merely returns *this and does not affect the
00057  * reference count.
00058  *
00059  */
00060 class TAO_PortableServer_Export TAO_ServantBase
00061   : public virtual TAO_Abstract_ServantBase
00062 {
00063 public:
00064 
00065   /// Destructor.
00066   virtual ~TAO_ServantBase (void);
00067 
00068   /// Returns the default POA for this servant.
00069   virtual PortableServer::POA_ptr _default_POA (
00070       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00071     );
00072 
00073   /// Local implementation of the CORBA::Object::_is_a method.
00074   virtual CORBA::Boolean _is_a (const char *logical_type_id
00075                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00076 
00077   /// Default _non_existent: always returns false.
00078   virtual CORBA::Boolean _non_existent (
00079       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00080     );
00081 
00082   /// Query the Interface Repository for the interface definition.
00083   virtual CORBA::InterfaceDef_ptr _get_interface (
00084       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00085     );
00086 
00087   /// Default _get_component: always returns CORBA::Object::_nil().
00088   virtual CORBA::Object_ptr _get_component (
00089       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00090     );
00091 
00092   /// Get the repository id.
00093   virtual char * _repository_id (
00094       ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00095     );
00096 
00097   /// This is an auxiliary method for _this() and _narrow().
00098   virtual TAO_Stub *_create_stub (ACE_ENV_SINGLE_ARG_DECL);
00099 
00100   /**
00101    * Dispatches a request to the object: find the operation, cast the
00102    * type to the most derived type, demarshall all the parameters from
00103    * the request and finally invokes the operation, storing the
00104    * results and out parameters (if any) or the exceptions thrown into
00105    * @a request.
00106    */
00107   virtual void _dispatch (TAO_ServerRequest &request,
00108                           void *servant_upcall
00109                           ACE_ENV_ARG_DECL) = 0;
00110 
00111   /// Please see documentation in tao/Abstract_Servant_Base.h for
00112   /// details.
00113   virtual int _find (const char *opname,
00114                      TAO_Skeleton &skelfunc,
00115                      const size_t length = 0);
00116 
00117   virtual int _find (const char *opname,
00118                      TAO_Collocated_Skeleton &skelfunc,
00119                      TAO::Collocation_Strategy st,
00120                      const size_t length = 0);
00121 
00122   /// Get this interface's repository id (TAO specific).
00123   virtual const char *_interface_repository_id (void) const = 0;
00124 
00125   //@{
00126   /**
00127    * @name Reference Counting Operations
00128    */
00129   /// Increase reference count by one.
00130   virtual void _add_ref (ACE_ENV_SINGLE_ARG_DECL);
00131 
00132   /**
00133    * Decreases reference count by one; if the resulting reference
00134    * count equals zero, _remove_ref invokes delete on its this pointer
00135    * in order to destroy the servant.
00136    */
00137   virtual void _remove_ref (ACE_ENV_SINGLE_ARG_DECL);
00138 
00139   /**
00140    * Returns the current reference count value.
00141    */
00142   virtual CORBA::ULong _refcount_value (ACE_ENV_SINGLE_ARG_DECL) const;
00143   //@}
00144 
00145 protected:
00146 
00147   /// Default constructor, only derived classes can be created.
00148   TAO_ServantBase (void);
00149 
00150   /// Copy constructor, protected so no instances can be created.
00151   TAO_ServantBase (const TAO_ServantBase &);
00152 
00153   /// Assignment operator.
00154   TAO_ServantBase &operator= (const TAO_ServantBase &);
00155 
00156   virtual void synchronous_upcall_dispatch (TAO_ServerRequest & req,
00157                                             void * servant_upcall,
00158                                             void * derived_this
00159                                             ACE_ENV_ARG_DECL);
00160 
00161   virtual void asynchronous_upcall_dispatch (TAO_ServerRequest & req,
00162                                              void * servant_upcall,
00163                                              void * derived_this
00164                                              ACE_ENV_ARG_DECL);
00165 
00166 protected:
00167   /// Reference counter.
00168   ACE_Atomic_Op<TAO_SYNCH_MUTEX, long> ref_count_;
00169 
00170   /// The operation table for this servant.  It is initialized by the
00171   /// most derived class.
00172   TAO_Operation_Table * optable_;
00173 };
00174 
00175 class TAO_PortableServer_Export TAO_Servant_Hash
00176 {
00177 public:
00178   /// Returns hash value.
00179   u_long operator () (PortableServer::Servant servant) const;
00180 };
00181 
00182 /**
00183  * @class TAO_ServantBase_var
00184  *
00185  * @brief Auto pointer for reference counting servants.
00186  *
00187  * For the convenience of automatically managing servant
00188  * reference counts, the PortableServer namespace also provides
00189  * the ServantBase_var class. This class behaves similarly to
00190  * _var classes for object references (see Section 20.3.1).
00191  */
00192 class TAO_PortableServer_Export TAO_ServantBase_var
00193 {
00194 public:
00195   TAO_ServantBase_var (void);
00196 
00197   TAO_ServantBase_var (TAO_ServantBase *p);
00198 
00199   TAO_ServantBase_var (const TAO_ServantBase_var &b);
00200 
00201   ~TAO_ServantBase_var (void);
00202 
00203   TAO_ServantBase_var &operator= (TAO_ServantBase *p);
00204 
00205   TAO_ServantBase_var &operator= (const TAO_ServantBase_var &b);
00206 
00207   TAO_ServantBase *operator-> () const;
00208 
00209   TAO_ServantBase *in (void) const;
00210 
00211   TAO_ServantBase *&inout (void);
00212 
00213   TAO_ServantBase *&out (void);
00214 
00215   TAO_ServantBase *_retn (void);
00216 
00217 private:
00218 
00219   TAO_ServantBase *ptr_;
00220 };
00221 
00222 TAO_END_VERSIONED_NAMESPACE_DECL
00223 
00224 #if defined (__ACE_INLINE__)
00225 # include "tao/PortableServer/Servant_Base.i"
00226 #endif /* __ACE_INLINE__ */
00227 
00228 #include /**/ "ace/post.h"
00229 
00230 #endif /* TAO_SERVANT_BASE_H */

Generated on Thu Nov 9 12:40:44 2006 for TAO_PortableServer by doxygen 1.3.6