Request.h

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

Generated on Thu Nov 9 13:04:21 2006 for TAO_DynamicInterface by doxygen 1.3.6