LocalObject.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  * @file LocalObject.h
00006  *
00007  * LocalObject.h,v 1.34 2006/06/19 14:51:11 parsons Exp
00008  *
00009  * Header file for CORBA's base "LocalObject" type.
00010  *
00011  * A "LocalObject" is an entity that can be the target of a local
00012  * invocation.  See the CORBA Component Model specification for
00013  * details.
00014  *
00015  * @author Nanbor Wang <nanbor@cs.wustl.edu>
00016  */
00017 //=============================================================================
00018 
00019 
00020 #ifndef TAO_CORBA_LOCALOBJECT_H
00021 #define TAO_CORBA_LOCALOBJECT_H
00022 
00023 #include /**/ "ace/pre.h"
00024 
00025 #include "ace/Thread_Mutex.h"
00026 #include "ace/Atomic_Op.h"
00027 
00028 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00029 # pragma once
00030 #endif /* ACE_LACKS_PRAGMA_ONCE */
00031 
00032 #include "tao/Object.h"
00033 
00034 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00035 
00036 namespace CORBA
00037 {
00038   class LocalObject;
00039   typedef LocalObject *LocalObject_ptr;
00040   typedef TAO_Pseudo_Var_T<LocalObject> LocalObject_var;
00041   typedef TAO_Pseudo_Out_T<LocalObject> LocalObject_out;
00042 
00043   /**
00044    * @class LocalObject
00045    */
00046   class TAO_Export LocalObject : public virtual CORBA::Object
00047   {
00048   public:
00049 
00050     /// Destructor
00051     virtual ~LocalObject (void);
00052 
00053     /// Increment the ref count
00054     static LocalObject_ptr _duplicate (LocalObject_ptr obj);
00055 
00056     /// Return a NIL object
00057     static LocalObject_ptr _nil (void);
00058 
00059     /**
00060      * @todo Narrowing a LocalObject to a CORBA::Object is broken
00061      * right now.  The solution seems to be making CORBA::Object an
00062      * abstract base class and create a CORBA::RemoteObject for
00063      * regular object.  Or, even easier, add a @c is_local member into
00064      * CORBA::Object.  I'll take the easier route for now.
00065      */
00066     static LocalObject_ptr _narrow (CORBA::Object_ptr obj
00067                                     ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00068 
00069 #if (TAO_HAS_MINIMUM_CORBA == 0)
00070 
00071     /// Always returns false.
00072     virtual CORBA::Boolean _non_existent (
00073         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00074       );
00075 
00076     /// Throws CORBA::NO_IMPLEMENT.
00077     virtual CORBA::ImplementationDef_ptr _get_implementation (
00078         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00079       );
00080 
00081     /// Gets info about object from the Interface Repository.
00082     virtual CORBA::InterfaceDef_ptr _get_interface (
00083         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00084       );
00085 
00086     /// Throws NO_IMPLEMENT.
00087     virtual CORBA::Object_ptr _get_component (
00088         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00089       );
00090 
00091     /// Get the repository id.
00092     virtual char * _repository_id (
00093         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00094     );
00095 
00096     virtual void _create_request (CORBA::Context_ptr ctx,
00097                                   const char * operation,
00098                                   CORBA::NVList_ptr arg_list,
00099                                   CORBA::NamedValue_ptr result,
00100                                   CORBA::Request_ptr & request,
00101                                   CORBA::Flags req_flags
00102                                   ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00103 
00104     virtual void _create_request (CORBA::Context_ptr ctx,
00105                                   const char * operation,
00106                                   CORBA::NVList_ptr arg_list,
00107                                   CORBA::NamedValue_ptr result,
00108                                   CORBA::ExceptionList_ptr exclist,
00109                                   CORBA::ContextList_ptr ctxtlist,
00110                                   CORBA::Request_ptr & request,
00111                                   CORBA::Flags req_flags
00112                                   ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00113 
00114     /// Throws NO_IMPLEMENT.
00115     virtual CORBA::Request_ptr _request (const char * operation
00116                                          ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00117 
00118 #endif /* TAO_HAS_MINIMUM_CORBA */
00119 
00120 #if (TAO_HAS_CORBA_MESSAGING == 1)
00121 
00122     /// Throws CORBA::NO_IMPLEMENT.
00123     CORBA::Policy_ptr _get_policy (CORBA::PolicyType type
00124                                    ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00125 
00126     /// Throws CORBA::NO_IMPLEMENT.
00127     CORBA::Policy_ptr _get_cached_policy (TAO_Cached_Policy_Type type
00128                                           ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00129 
00130     /// Throws CORBA::NO_IMPLEMENT.
00131     CORBA::Object_ptr _set_policy_overrides (
00132         const CORBA::PolicyList & policies,
00133         CORBA::SetOverrideType set_add
00134         ACE_ENV_ARG_DECL_WITH_DEFAULTS
00135       );
00136 
00137     /// Throws CORBA::NO_IMPLEMENT.
00138     CORBA::PolicyList * _get_policy_overrides (
00139         const CORBA::PolicyTypeSeq & types
00140         ACE_ENV_ARG_DECL_WITH_DEFAULTS
00141       );
00142 
00143     /// Throws CORBA::NO_IMPLEMENT.
00144     CORBA::Boolean _validate_connection (
00145         CORBA::PolicyList_out inconsistent_policies
00146         ACE_ENV_ARG_DECL_WITH_DEFAULTS
00147       );
00148 
00149 #endif /* TAO_HAS_CORBA_MESSAGING == 1 */
00150 
00151     /**
00152      * Return a hash value for this object.  The hash is based on the
00153      * address of the object.  On non-32 bit platforms, the hash may
00154      * be non-unique.
00155      */
00156     virtual CORBA::ULong _hash (CORBA::ULong maximum
00157                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00158 
00159     /**
00160      * Try to determine if this object is the same as @c other_obj.
00161      * This method relies on the representation of the object
00162      * reference's private state.  Since that changes easily (when
00163      * different ORB protocols are in use) there is no default
00164      * implementation.
00165      */
00166     virtual CORBA::Boolean _is_equivalent (CORBA::Object_ptr other_obj
00167                                            ACE_ENV_ARG_DECL_WITH_DEFAULTS)
00168       ACE_THROW_SPEC (());
00169 
00170     // = Reference count managment.
00171     /// Increment the reference count.
00172     virtual void _add_ref (void);
00173 
00174     /// Decrement the reference count.
00175     virtual void _remove_ref (void);
00176 
00177     virtual CORBA::ORB_ptr _get_orb (
00178         ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS
00179       );
00180 
00181     // = TAO extensions
00182 
00183     /// Throws CORBA::NO_IMPLEMENT.
00184     virtual TAO::ObjectKey * _key (ACE_ENV_SINGLE_ARG_DECL);
00185 
00186     /// Useful for template programming.
00187     typedef LocalObject_ptr _ptr_type;
00188     typedef LocalObject_var _var_type;
00189     typedef LocalObject_out _out_type;
00190 
00191   protected:
00192 
00193     /// Default constructor.
00194     /**
00195      * Make it protected to prevent instantiation of this class.
00196      */
00197     LocalObject (void);
00198 
00199   private:
00200 
00201     /**
00202      * @name Unimplemented methods
00203      */
00204     //@{
00205     LocalObject (const LocalObject &);
00206     LocalObject & operator = (const LocalObject &);
00207     //@}
00208 
00209   };
00210 }   // End CORBA namespace
00211 
00212 /**
00213  * @class TAO_Local_RefCounted_Object
00214  *
00215  * @brief This class adds default reference counting to local
00216  *        objects.
00217  *
00218  * This is proprietary convenience class that implements reference
00219  * counting in locality constrained objects.
00220  */
00221 class TAO_Export TAO_Local_RefCounted_Object
00222   : public virtual CORBA::LocalObject
00223 {
00224 public:
00225 
00226   /// Destructor.
00227   virtual ~TAO_Local_RefCounted_Object (void);
00228 
00229   /// Increment reference count.
00230   virtual void _add_ref (void);
00231 
00232   /// Decrement reference count.
00233   virtual void _remove_ref (void);
00234 
00235 protected:
00236 
00237   // Default constructor.
00238   /**
00239    * Make it protected to prevent instantiation of this class.
00240    */
00241   TAO_Local_RefCounted_Object (void);
00242 
00243 private:
00244 
00245   /**
00246    * @name Unimplemented methods
00247    */
00248   //@{
00249   TAO_Local_RefCounted_Object (const TAO_Local_RefCounted_Object &);
00250   TAO_Local_RefCounted_Object & operator = (
00251       const TAO_Local_RefCounted_Object &
00252     );
00253   //@}
00254 
00255 protected:
00256   /// Reference counter.
00257   ACE_Atomic_Op<TAO_SYNCH_MUTEX, CORBA::ULong> refcount_;
00258 };
00259 
00260 TAO_END_VERSIONED_NAMESPACE_DECL
00261 
00262 #if defined (__ACE_INLINE__)
00263 # include "tao/LocalObject.i"
00264 #endif /* __ACE_INLINE__ */
00265 
00266 #include /**/ "ace/post.h"
00267 
00268 #endif /* TAO_CORBA_LOCALOBJECT_H */

Generated on Thu Nov 9 11:54:15 2006 for TAO by doxygen 1.3.6