Request.h

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

Generated on Tue Feb 2 17:43:23 2010 for TAO_DynamicInterface by  doxygen 1.4.7