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

Adapter.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Adapter.h
00006  *
00007  *  $Id: Adapter.h,v 1.1.1.2 2003/02/21 18:36:44 chad Exp $
00008  *
00009  *  @author Carlos O'Ryan (coryan@uci.edu)
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_ADAPTER_H
00015 #define TAO_ADAPTER_H
00016 #include "ace/pre.h"
00017 
00018 #include "tao/corbafwd.h"
00019 #include "tao/Exception.h"
00020 #include "ace/Service_Object.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #if defined(_MSC_VER)
00027 #if (_MSC_VER >= 1200)
00028 #pragma warning(push)
00029 #endif /* _MSC_VER >= 1200 */
00030 #pragma warning(disable:4250)
00031 #endif /* _MSC_VER */
00032 
00033 class TAO_ORB_Core;
00034 class TAO_Stub;
00035 class TAO_MProfile;
00036 class TAO_ServerRequest;
00037 
00038 class TAO_Export TAO_Adapter
00039 {
00040 public:
00041   virtual ~TAO_Adapter (void);
00042 
00043   /// Initialize the Adapter
00044   virtual void open (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) = 0;
00045 
00046   /// The ORB is shutting down, destroy any resources attached to this
00047   /// adapter.
00048   virtual void close (int wait_for_completion
00049                       ACE_ENV_ARG_DECL_NOT_USED) = 0;
00050 
00051   /// Check if the adapter can be closed in the current context, raise
00052   /// an exception if not.
00053   virtual void check_close (int wait_for_completion
00054                             ACE_ENV_ARG_DECL_NOT_USED) = 0;
00055 
00056   /**
00057    * Return the priority assigned to this adapter.
00058    * Adapters at higher priority are used first, the first adapter
00059    * that matches a key is used to dispatch a request.
00060    */
00061   virtual int priority (void) const = 0;
00062 
00063   /// Return the status....
00064   virtual int dispatch (TAO_ObjectKey &key,
00065                         TAO_ServerRequest &request,
00066                         CORBA::Object_out forward_to
00067                         ACE_ENV_ARG_DECL)
00068     ACE_THROW_SPEC ((CORBA::SystemException)) = 0;
00069 
00070   enum {
00071     DS_OK,
00072     // The operation was successfully dispatched, an exception may
00073     // have been raised, but that is a correct execution too.
00074 
00075     DS_FAILED,
00076     // There was a problem in dispatching the operation.
00077 
00078     DS_MISMATCHED_KEY,
00079     // The key is not in the right format for this Adapter, try the
00080     // next one.
00081 
00082     DS_FORWARD
00083     // Forward the request to another object reference, this decouples
00084     // the ORB from the PortableServer::ForwardRequest exception
00085   };
00086 
00087   /// Return the name, i.e. the object id used to resolve it in the
00088   /// ORB.
00089   virtual const char *name (void) const = 0;
00090 
00091   /**
00092    * Return the root of the Object Adapter.
00093    * Each adapter defines its own IDL interface accessed through the
00094    * method above.
00095    */
00096   virtual CORBA::Object_ptr root (void) = 0;
00097 
00098   /// Create a collocated object using the given profile and stub.
00099   virtual CORBA::Object_ptr create_collocated_object (TAO_Stub *,
00100                                                       const TAO_MProfile &) = 0;
00101 };
00102 
00103 // ****************************************************************
00104 
00105 // @@ Move to its own file
00106 
00107 class TAO_Export TAO_Adapter_Registry
00108 {
00109 public:
00110   TAO_Adapter_Registry (TAO_ORB_Core *orb_core);
00111 
00112   /// Close the
00113   ~TAO_Adapter_Registry (void);
00114 
00115   /**
00116    * Close each of of the Adapters and then cleanup the Registry.
00117    * It is possible that an Adapter will reject a close() call if it
00118    * is invoked in an innapropriate context (think shutting down the
00119    * POA while performing an upcall).
00120    */
00121   void close (int wait_for_completion
00122               ACE_ENV_ARG_DECL)
00123     ACE_THROW_SPEC (());
00124 
00125   /**
00126    * Verify if the close() call can be invoked in the current
00127    * context for *all* adapters.
00128    * Raise the right exception if not.
00129    */
00130   void check_close (int wait_for_completion
00131                     ACE_ENV_ARG_DECL)
00132     ACE_THROW_SPEC (());
00133 
00134   /// Insert a new adapter into the registry.
00135   void insert (TAO_Adapter *adapter
00136                ACE_ENV_ARG_DECL);
00137 
00138   /**
00139    * Dispatch the request to all the adapters.
00140    * It tries the adapters ordered by priority, stopping when the
00141    * adapter returns a status different from DS_MISMATCHED_KEY
00142    */
00143   void dispatch (TAO_ObjectKey &key,
00144                  TAO_ServerRequest &request,
00145                  CORBA::Object_out forward_to
00146                  ACE_ENV_ARG_DECL)
00147     ACE_THROW_SPEC ((CORBA::SystemException));
00148 
00149   /// Create a collocated object using the given profile and stub.
00150   CORBA::Object_ptr create_collocated_object (TAO_Stub *,
00151                                               const TAO_MProfile &);
00152 
00153   /// Fetch the adapter named <name>
00154   TAO_Adapter *find_adapter (const char *name) const;
00155 
00156 private:
00157   /// The ORB Core
00158   TAO_ORB_Core *orb_core_;
00159 
00160   /// A simple array of adapters.
00161   size_t adapters_capacity_;
00162   size_t adapters_count_;
00163   TAO_Adapter **adapters_;
00164 };
00165 
00166 // ****************************************************************
00167 
00168 class TAO_Export TAO_Adapter_Factory : public ACE_Service_Object
00169 {
00170 public:
00171   /// Destructor
00172   virtual ~TAO_Adapter_Factory (void);
00173 
00174   /// Create a new adapter
00175   virtual TAO_Adapter *create (TAO_ORB_Core *orb_core) = 0;
00176 };
00177 
00178 #if defined (__ACE_INLINE__)
00179 # include "Adapter.i"
00180 #endif /* __ACE_INLINE__ */
00181 
00182 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
00183 #pragma warning(pop)
00184 #endif /* _MSC_VER */
00185 
00186 #include "ace/post.h"
00187 #endif /* TAO_OBJECT_ADAPTER_H */

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