ORBInitInfo.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // ===================================================================
00004 /**
00005  *  @file   ORBInitInfo.h
00006  *
00007  *  $Id: ORBInitInfo.h 81429 2008-04-24 18:49:54Z johnnyw $
00008  *
00009  *  @author Ossama Othman <ossama@dre.vanderbilt.edu>
00010  */
00011 // ===================================================================
00012 
00013 #ifndef TAO_ORB_INIT_INFO_H
00014 #define TAO_ORB_INIT_INFO_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include "tao/PI/pi_export.h"
00019 
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif /* ACE_LACKS_PRAGMA_ONCE */
00023 
00024 #include "tao/PI/PI_includeC.h"
00025 #include "tao/LocalObject.h"
00026 
00027 // This is to remove "inherits via dominance" warnings from MSVC.
00028 // MSVC is being a little too paranoid.
00029 #if defined(_MSC_VER)
00030 #pragma warning(push)
00031 #pragma warning(disable:4250)
00032 #endif /* _MSC_VER */
00033 
00034 #if defined (__BORLANDC__)
00035 #pragma option push -w-rvl -w-rch -w-ccc -w-inl
00036 #endif /* __BORLANDC__ */
00037 
00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00039 
00040 class TAO_ORB_Core;
00041 class TAO_ORBInitInfo;
00042 typedef TAO_ORBInitInfo *TAO_ORBInitInfo_ptr;
00043 
00044 typedef TAO_Objref_Var_T<TAO_ORBInitInfo>
00045                          TAO_ORBInitInfo_var;
00046 
00047 typedef TAO_Objref_Out_T<TAO_ORBInitInfo>
00048                          TAO_ORBInitInfo_out;
00049 
00050 /**
00051  * @class TAO_ORBInitInfo
00052  *
00053  * @brief An implementation of the PortableInterceptor::ORBInitInfo_3_1
00054  *        interface.
00055  *
00056  * This class encapsulates the data passed to ORBInitializers during
00057  * ORB initialization.
00058  */
00059 class TAO_PI_Export TAO_ORBInitInfo
00060   : public virtual PortableInterceptor::ORBInitInfo_3_1,
00061     public virtual ::CORBA::LocalObject
00062 {
00063 public:
00064 
00065   /// Constructor.
00066   TAO_ORBInitInfo (TAO_ORB_Core *orb_core,
00067                    int argc,
00068                    char *argv[],
00069                    PortableInterceptor::SlotId slotid);
00070 
00071   /**
00072    * @name PortableInterceptor::ORBInitInfo Methods
00073    *
00074    * These methods are exported by the
00075    * PortableInterceptor::ORBInitInfo interface.
00076    */
00077   //@{
00078   /// Return the argument vector for the ORB currently being
00079   /// initialized as a string sequence.
00080   virtual CORBA::StringSeq * arguments (void);
00081 
00082   /// Return the ORBid for the ORB currently being initialized.
00083   virtual char * orb_id (void);
00084 
00085   /// Return the CodecFactory for the ORB currently being
00086   /// initialized.
00087   virtual IOP::CodecFactory_ptr codec_factory (void);
00088 
00089   /// Register a mapping between a string and a corresponding object
00090   /// reference with the ORB being initialized.
00091   /**
00092    * This method is particularly useful for registering references to
00093    * local (locality constrained) objects.  Note that this method
00094    * should be called in ORBInitializer::pre_init() so that the
00095    * registered reference will be available to the
00096    * resolve_initial_references() that may be called in the
00097    * ORBInitializer::post_init() call.
00098    */
00099   virtual void register_initial_reference (const char * id, CORBA::Object_ptr obj);
00100 
00101   /// Obtain a reference to an object that may not yet be available
00102   /// via the usual CORBA::ORB::resolve_initial_references() mechanism
00103   /// since the ORB may not be fully initialized yet.
00104   virtual CORBA::Object_ptr resolve_initial_references (const char * id);
00105 
00106   /// Register a client request interceptor with the ORB currently
00107   /// being initialized.
00108   virtual void add_client_request_interceptor (
00109       PortableInterceptor::ClientRequestInterceptor_ptr interceptor);
00110 
00111   /// Register a server request interceptor with the ORB currently
00112   /// being initialized.
00113   virtual void add_server_request_interceptor (
00114       PortableInterceptor::ServerRequestInterceptor_ptr interceptor);
00115 
00116   /// Register an IOR interceptor with the ORB currently being
00117   /// initialized.
00118   virtual void add_ior_interceptor (
00119       PortableInterceptor::IORInterceptor_ptr interceptor);
00120 
00121   /// Register a client request interceptor with the ORB currently
00122   /// being initialized, along with a list of policies.
00123   virtual void add_client_request_interceptor_with_policy (
00124       PortableInterceptor::ClientRequestInterceptor_ptr interceptor,
00125       const CORBA::PolicyList& policies);
00126 
00127   /// Register a server request interceptor with the ORB currently
00128   /// being initialized, along with a list of policies.
00129   virtual void add_server_request_interceptor_with_policy (
00130       PortableInterceptor::ServerRequestInterceptor_ptr interceptor,
00131       const CORBA::PolicyList& policies);
00132 
00133   /// Register an IOR interceptor with the ORB currently being
00134   /// initialized, along with a list of policies.
00135   virtual void add_ior_interceptor_with_policy (
00136       PortableInterceptor::IORInterceptor_ptr interceptor,
00137       const CORBA::PolicyList& policies);
00138 
00139   /// Reserve a slot in table found within the
00140   /// PortableInterceptor::Current object.
00141   virtual PortableInterceptor::SlotId allocate_slot_id (void);
00142 
00143   /// Register a policy factory of the given policy type with the ORB
00144   /// currently being initialized.
00145   virtual void register_policy_factory (
00146       CORBA::PolicyType type,
00147       PortableInterceptor::PolicyFactory_ptr policy_factory);
00148 
00149   virtual CORBA::ORB_ptr _get_orb (void);
00150   //@}
00151 
00152   /**
00153    * @name TAO Extensions
00154    *
00155    * These methods are not part of the PortableInterceptor
00156    * specification, and are TAO-specific extensions.
00157    */
00158   //@{
00159   /// Allocate a slot in the ORB's TSS resources.
00160   /**
00161    * TAO uses a single TSS key for these resources, so it is useful to
00162    * place TSS objects in TAO's TSS resources on platforms where the
00163    * number of TSS keys is low.  The returned SlotId can be used to
00164    * index into the array stored in ORB's TSS resources structure.
00165    * @par
00166    * An accompanying cleanup function (e.g. a TSS destructor) can also
00167    * be registered.
00168    */
00169   size_t allocate_tss_slot_id (ACE_CLEANUP_FUNC cleanup);
00170 
00171   /// Return a pointer to the ORB Core associated with the ORB being
00172   /// initialized.
00173   /**
00174    * The ORB Core is essentialy fully initialized by the time
00175    * ORBInitializer::post_init() is invoked.  As such, it is generally
00176    * best if this method is used in that method.
00177    *
00178    * @note Only use this method if you know what you are doing.
00179    */
00180   TAO_ORB_Core *orb_core (void) const;
00181 
00182   /// Invalidate this ORBInitInfo instance.
00183   /**
00184    * @note This method is only meant to be called by the
00185    *       CORBA::ORB_init() function.
00186    */
00187   void invalidate (void);
00188 
00189   /// Return the number of allocated slots in for the PICurrent
00190   /// object.
00191   PortableInterceptor::SlotId slot_count (void) const;
00192   //@}
00193 
00194   /**
00195    * @name Reference Related Methods
00196    *
00197    * TAO_ORBInitInfo-specific methods and types.
00198    */
00199   //@{
00200   typedef TAO_ORBInitInfo_ptr _ptr_type;
00201   typedef TAO_ORBInitInfo_var _var_type;
00202 
00203   static TAO_ORBInitInfo_ptr _duplicate (TAO_ORBInitInfo_ptr obj);
00204 
00205   static TAO_ORBInitInfo_ptr _narrow (CORBA::Object_ptr obj);
00206 
00207 
00208   static TAO_ORBInitInfo_ptr _unchecked_narrow (CORBA::Object_ptr obj);
00209 
00210 
00211   static TAO_ORBInitInfo_ptr _nil (void)
00212     {
00213       return (TAO_ORBInitInfo_ptr)0;
00214     }
00215   //@}
00216 
00217   virtual const char* _interface_repository_id (void) const;
00218 
00219 protected:
00220 
00221   /// Destructor is protected to enforce proper memory management
00222   /// through the reference counting mechanism.
00223   ~TAO_ORBInitInfo (void);
00224 
00225   /// Check if this ORBInitInfo instance is valid.  Once post_init()
00226   /// has been called on each of the ORBInitializers, this ORBInitInfo
00227   /// is no longer valid.  Throw an exception in that case.
00228   void check_validity (void);
00229 
00230 private:
00231 
00232   /// Prevent copying through the copy constructor and the assignment
00233   /// operator.
00234   TAO_ORBInitInfo (const TAO_ORBInitInfo &);
00235   void operator= (const TAO_ORBInitInfo &);
00236 
00237 private:
00238 
00239   /// Reference to the ORB Core.
00240   TAO_ORB_Core *orb_core_;
00241 
00242   /// The number of arguments in the argument vector passed to
00243   /// CORBA::ORB_init().
00244   int argc_;
00245 
00246   /// The argument vector passed to CORBA::ORB_init().
00247   char **argv_;
00248 
00249   /// Reference to the CodecFactory returned by
00250   /// ORBInitInfo::codec_factory().
00251   IOP::CodecFactory_var codec_factory_;
00252 
00253   /// The number of allocated slots.
00254   PortableInterceptor::SlotId slot_count_;
00255 
00256 };
00257 
00258 // Traits specializations.
00259 namespace TAO
00260 {
00261   // Hand crafted. Not forward declared, but used by PortableServer.
00262   template<>
00263   struct TAO_PI_Export Objref_Traits<TAO_ORBInitInfo>
00264   {
00265     static TAO_ORBInitInfo_ptr duplicate (TAO_ORBInitInfo_ptr);
00266     static void release (TAO_ORBInitInfo_ptr);
00267     static TAO_ORBInitInfo_ptr nil (void);
00268     static CORBA::Boolean marshal (TAO_ORBInitInfo_ptr p, TAO_OutputCDR & cdr);
00269   };
00270 }
00271 
00272 TAO_END_VERSIONED_NAMESPACE_DECL
00273 
00274 #if defined (__ACE_INLINE__)
00275 #include "tao/PI/ORBInitInfo.inl"
00276 #endif  /* __ACE_INLINE__ */
00277 
00278 #if defined(_MSC_VER)
00279 #pragma warning(pop)
00280 #endif /* _MSC_VER */
00281 
00282 #if defined (__BORLANDC__)
00283 #pragma option pop
00284 #endif /* __BORLANDC__ */
00285 
00286 #include /**/ "ace/post.h"
00287 
00288 #endif /* TAO_ORB_INIT_INFO_H */

Generated on Tue Feb 2 17:42:01 2010 for TAO_PI by  doxygen 1.4.7