Request.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Request.h
00006  *
00007  *  $Id: Request.h 78631 2007-06-28 13:49:10Z johnnyw $
00008  *
00009  *  Header file for CORBA's Dynamic Invocation Interface "Request"
00010  *  type.
00011  *
00012  *  @author Copyright 1994-1995 by Sun Microsystems, Inc.
00013  *  @author Additions and RequestSeq by Jeff Parsons <parsons@cs.wustl.edu>
00014  */
00015 //=============================================================================
00016 
00017 #ifndef TAO_REQUEST_H
00018 #define TAO_REQUEST_H
00019 
00020 #include /**/ "ace/pre.h"
00021 
00022 #include "tao/orbconf.h"
00023 
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 // To force execution of the static constructor
00029 // that registers the dynamic service object.
00030 #include "tao/DynamicInterface/Dynamic_Adapter_Impl.h"
00031 
00032 #include "tao/DynamicInterface/ExceptionList.h"
00033 
00034 #include "tao/ORB.h"
00035 #include "tao/Environment.h"
00036 #include "tao/CDR.h"
00037 #include "tao/AnyTypeCode/NVList.h"
00038 
00039 #if defined (TAO_HAS_AMI)
00040 #include "tao/Messaging/Messaging.h"
00041 #endif /* TAO_HAS_AMI */
00042 
00043 #include "ace/SString.h"
00044 #include "ace/Atomic_Op.h"
00045 
00046 #if defined (TAO_EXPORT_MACRO)
00047 #undef TAO_EXPORT_MACRO
00048 #endif
00049 #define TAO_EXPORT_MACRO TAO_DynamicInterface_Export
00050 
00051 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00052 
00053 namespace CORBA
00054 {
00055   class NVList;
00056   typedef NVList *NVList_ptr;
00057 
00058   class Context;
00059   typedef Context *Context_ptr;
00060 
00061   class ContextList;
00062   typedef ContextList *ContextList_ptr;
00063 
00064   /**
00065    * @class Request
00066    *
00067    * @brief CORBA::Request
00068    *
00069    * Provides a way to create requests and populate it with parameters
00070    * for use in the Dynamic Invocation Interface.
00071    */
00072   class TAO_DynamicInterface_Export Request
00073   {
00074   public:
00075 
00076     /// Return the target of this request.
00077     CORBA::Object_ptr target (void) const;
00078 
00079     /// Return the operation name for the request.
00080     const CORBA::Char *operation (void) const;
00081 
00082     /// Return the arguments for the request.
00083     CORBA::NVList_ptr arguments (void);
00084 
00085     /// Return the result for the request.
00086     CORBA::NamedValue_ptr result (void);
00087 
00088     /// Return the exceptions resulting from this request.
00089     CORBA::ExceptionList_ptr exceptions (void);
00090 
00091     /// Accessor for the Context member.
00092     CORBA::Context_ptr ctx (void) const;
00093 
00094     /// Mutator for the Context member.
00095     void ctx (CORBA::Context_ptr);
00096 
00097     /// Return a list of the request's result's contexts.  Since TAO
00098     /// does not implement Contexts, this will always be 0.
00099     CORBA::ContextList_ptr contexts (void);
00100 
00101     /**
00102      * @name Argument manipulation helper functions.
00103      *
00104      * Arg adders, one for each type of parameter, with and without
00105      * optional name. Returns reference to Any for insertion using
00106      * <<=.
00107      */
00108     //@{
00109     CORBA::Any &add_in_arg (void);
00110     CORBA::Any &add_in_arg (const char* name);
00111     CORBA::Any &add_inout_arg (void);
00112     CORBA::Any &add_inout_arg (const char* name);
00113     CORBA::Any &add_out_arg (void);
00114     CORBA::Any &add_out_arg (const char* name);
00115     //@}
00116 
00117     /// Initialize the return type.
00118     void set_return_type (CORBA::TypeCode_ptr tc);
00119 
00120     /// Returns reference to Any for extraction using >>=.
00121     CORBA::Any &return_value (void);
00122 
00123     /// Perform method resolution and invoke an appropriate method.
00124     /**
00125      * If the method returns successfully, its result is placed in
00126      * the result argument specified on @c create_request. The behavior
00127      * is undefined if this @c Request has already been used with a
00128      * previous call to @c invoke>, @c send>, or
00129      * @send_multiple_requests.
00130      *
00131      * @note A default argument is set, but please note that this not
00132      *       recommended as the user may not be able to propagate the
00133      *       exceptions.
00134      */
00135     void invoke (void);
00136 
00137     /// Send a oneway request.
00138     /**
00139      * @note A default argument is set, but please note that this not
00140      *       recommended as the user may not be able to propagate the
00141      *       exceptions.
00142      */
00143     void send_oneway (void);
00144 
00145     /**
00146      * @name The 'deferred synchronous' methods.
00147      *
00148      * The 'deferred synchronous' methods.
00149      */
00150     //@{
00151     void send_deferred (void);
00152     void get_response (void);
00153     CORBA::Boolean poll_response (void);
00154     //@}
00155 
00156     /// Callback method for deferred synchronous requests.
00157     void handle_response (TAO_InputCDR &incoming, CORBA::ULong reply_status);
00158 
00159 #if defined (TAO_HAS_AMI)
00160     /// The 'asychronous' send method. The object is a DSI based callback
00161     /// handler. This handler must implement Messaging::ReplyHandler
00162     void sendc (CORBA::Object_ptr handler);
00163 
00164     static void _tao_reply_stub (
00165                     TAO_InputCDR &_tao_reply_cdr,
00166                     Messaging::ReplyHandler_ptr _tao_reply_handler,
00167                     CORBA::ULong reply_status);
00168 #endif /* TAO_HAS_AMI */
00169 
00170     /// Pseudo object methods.
00171     static CORBA::Request* _duplicate (CORBA::Request*);
00172     static CORBA::Request* _nil (void);
00173 
00174     // = Reference counting.
00175     CORBA::ULong _incr_refcnt (void);
00176     CORBA::ULong _decr_refcnt (void);
00177 
00178     /// Set the lazy evaluation flag.
00179     void _tao_lazy_evaluation (bool lazy_evaluation);
00180 
00181     /// Get the byte order member.
00182     int _tao_byte_order (void) const;
00183 
00184     /// Set the byte order member.
00185     void _tao_byte_order (int byte_order);
00186 
00187     // Hold on to a user exception in case we are part of a TAO
00188     // gateway.
00189     void raw_user_exception (TAO_InputCDR &cdr);
00190 
00191     /// Accessor for the input stream containing the exception.
00192     ACE_CString &raw_user_exception (void);
00193 
00194     /// Proprietary method to check whether a response has been
00195     /// received.
00196     CORBA::Boolean response_received (void);
00197 
00198     // Useful for template programming.
00199     typedef CORBA::Request_ptr _ptr_type;
00200     typedef CORBA::Request_var _var_type;
00201     typedef CORBA::Request_out _out_type;
00202 
00203   private:
00204     friend class ::TAO_Dynamic_Adapter_Impl;
00205 
00206     // The following are not allowed except when called from the
00207     // friend class.
00208 
00209     Request (CORBA::Object_ptr obj,
00210              CORBA::ORB_ptr orb,
00211              const CORBA::Char *op,
00212              CORBA::NVList_ptr args,
00213              CORBA::NamedValue_ptr result,
00214              CORBA::Flags flags,
00215              CORBA::ExceptionList_ptr exceptions);
00216 
00217     Request (CORBA::Object_ptr obj,
00218              CORBA::ORB_ptr orb,
00219              const CORBA::Char *op);
00220 
00221     ~Request (void);
00222 
00223   private:
00224 
00225     /// Target object.
00226     CORBA::Object_ptr target_;
00227 
00228     /// Pointer to our ORB.
00229     CORBA::ORB_var orb_;
00230 
00231     /// Operation name.
00232     const char * opname_;
00233 
00234     /// Parameter list.
00235     CORBA::NVList_ptr args_;
00236 
00237     /// Result of the operation.
00238     CORBA::NamedValue_ptr result_;
00239 
00240     /// Invocation flags.
00241     CORBA::Flags flags_;
00242 
00243     /// @deprecated  Holds exceptions.
00244     // CORBA::Environment env_;
00245 
00246     /// List of exceptions raised by the operation.
00247     CORBA::ExceptionList_var exceptions_;
00248 
00249     /// List of the request's result's contexts.
00250     CORBA::ContextList_ptr contexts_;
00251 
00252     /// Context associated with this request.
00253     CORBA::Context_ptr ctx_;
00254 
00255     /// Reference counting.
00256     ACE_Atomic_Op<TAO_SYNCH_MUTEX, unsigned long> refcount_;
00257 
00258     /// Protect the response_received_.
00259     TAO_SYNCH_MUTEX lock_;
00260 
00261     /// If not zero then the NVList is not evaluated by default.
00262     bool lazy_evaluation_;
00263 
00264     /// Set to true upon completion of invoke() or handle_response().
00265     CORBA::Boolean response_received_;
00266 
00267     /// Can be reset by a gateway when passing along a request.
00268     int byte_order_;
00269 
00270     /// Stores user exception as a CDR stream when this request is
00271     /// used in a TAO gateway.
00272     ACE_CString raw_user_exception_;
00273 
00274   };
00275 } // End CORBA namespace.
00276 
00277 TAO_END_VERSIONED_NAMESPACE_DECL
00278 
00279 #if defined (__ACE_INLINE__)
00280 # include "tao/DynamicInterface/Request.inl"
00281 #endif /* __ACE_INLINE__ */
00282 
00283 #include /**/ "ace/post.h"
00284 
00285 #endif /* TAO_REQUEST_H */

Generated on Sun Jan 27 13:37:31 2008 for TAO_DynamicInterface by doxygen 1.3.6