Cache_Entries.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Cache_Entries.h
00006  *
00007  *  Cache_Entries.h,v 1.26 2005/11/02 07:13:02 ossama Exp
00008  *
00009  *
00010  *  @author Bala Natarajan  <bala@cs.wustl.edu>
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef TAO_CACHE_ENTRIES_H
00016 #define TAO_CACHE_ENTRIES_H
00017 
00018 #include /**/ "ace/pre.h"
00019 
00020 #include "tao/Transport_Descriptor_Interface.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 # pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 class TAO_Transport;
00029 
00030 #ifdef index
00031 # undef index
00032 #endif  /* index */
00033 
00034 namespace TAO
00035 {
00036   /// States of a recyclable object.
00037   /// @@todo: A lifecycle needs to be designed. It can wait for
00038   /// sometime.
00039   enum Cache_Entries_State
00040     {
00041       /// Idle and can be purged.
00042       ENTRY_IDLE_AND_PURGABLE,
00043 
00044       /// Idle but cannot be purged.
00045       ENTRY_IDLE_BUT_NOT_PURGABLE,
00046 
00047       /// Can be purged, but is not idle (mostly for debugging).
00048       ENTRY_PURGABLE_BUT_NOT_IDLE,
00049 
00050       /// Busy (i.e., cannot be recycled or purged).
00051       ENTRY_BUSY,
00052 
00053       /// Closed.
00054       ENTRY_CLOSED,
00055 
00056       /// Unknown state.
00057       ENTRY_UNKNOWN
00058     };
00059 
00060   /**
00061    * @class Cache_IntId
00062    *
00063    * @brief Helper class for TAO_Transport_Cache_Manager
00064    *
00065    * Helper class that wraps the <value> part of the Map or
00066    * table holding the Transport state.: unifies data items, so
00067    * they can be stored together as a <value> for a <key> in a
00068    * table holding the state of the Transport Cache.
00069    */
00070   class TAO_Export Cache_IntId
00071   {
00072   public:
00073 
00074     /// Constructor.
00075     Cache_IntId (void);
00076 
00077     /// Constructor.
00078     Cache_IntId (TAO_Transport *transport);
00079 
00080     /// Copy constructor.
00081     Cache_IntId (const Cache_IntId & rhs);
00082 
00083     /// Destructor.
00084     ~Cache_IntId (void);
00085 
00086     /// Assignment operator (does copy memory).
00087     Cache_IntId& operator= (const Cache_IntId &rhs);
00088 
00089     /// Equality comparison operator (must match both id_ and kind_).
00090     bool operator== (const Cache_IntId &rhs) const;
00091 
00092     /// Inequality comparison operator.
00093     bool operator!= (const Cache_IntId &rhs) const;
00094 
00095     /// Return the underlying transport
00096     TAO_Transport *transport (void);
00097 
00098     /// Return the underlying transport
00099     const TAO_Transport *transport (void) const;
00100 
00101     /// Set <recycle_state>.
00102     void recycle_state (Cache_Entries_State new_state);
00103 
00104     /// Get <recycle_state>.
00105     Cache_Entries_State recycle_state (void);
00106 
00107     /// Relinquish ownership of the TAO_Transport object associated with
00108     /// this Cache_IntId.
00109     /**
00110      * @note This method should go away once the
00111      *       Transport_Cache_Map_Manager is improved so that it returns
00112      *       TAO_Transport objects when performing a find() operation.
00113      *       This method really only exists to get around inadequacies
00114      *       in the Transport_Cache_Map_Manager interface.
00115      */
00116     TAO_Transport *relinquish_transport (void);
00117 
00118   private:
00119     /// The transport that needs to be cached.
00120     TAO_Transport *transport_;
00121 
00122     /// The state of the handle
00123     Cache_Entries_State recycle_state_;
00124   };
00125 
00126 
00127   /**
00128    * @class Cache_ExtId
00129    *
00130    * @brief Helper class for TAO_Transport_Cache_Manager: unifies
00131    * several  data items, so they can be stored together as a
00132    * <value> for a <key> in a hash table holding the state of the
00133    * Transport Cache.
00134    */
00135   class TAO_Export Cache_ExtId
00136   {
00137   public:
00138 
00139     /// Constructor.
00140     Cache_ExtId (void);
00141 
00142     /// Constructor.
00143     Cache_ExtId (TAO_Transport_Descriptor_Interface *prop);
00144 
00145     /// Copy constructor.
00146     Cache_ExtId (const Cache_ExtId & rhs);
00147 
00148     /// Destructor.
00149     ~Cache_ExtId (void);
00150 
00151     // = Assignment and comparison operators.
00152     /// Assignment operator (does copy memory).
00153     Cache_ExtId& operator= (const Cache_ExtId &rhs);
00154 
00155     /// Equality comparison operator (must match both id_ and kind_).
00156     bool operator== (const Cache_ExtId &rhs) const;
00157 
00158     /// Inequality comparison operator.
00159     bool operator!= (const Cache_ExtId &rhs) const;
00160 
00161     /// <hash> function is required in order for this class to be usable by
00162     /// ACE_Hash_Map_Manager_Ex.
00163     u_long hash (void) const;
00164 
00165     /// Make a deep copy of the underlying pointer
00166     void duplicate (void);
00167 
00168     /// Return the index value
00169     CORBA::ULong index (void) const;
00170 
00171     /// Set the index value. This calls should not be used by any users
00172     /// but for the TAO_Transport_Cache_Manager class.
00173     void index (CORBA::ULong index);
00174 
00175     /// Increment the index value
00176     void incr_index (void);
00177 
00178     // = Accessors
00179     /// Get the underlying the property pointer
00180     TAO_Transport_Descriptor_Interface *property (void) const;
00181 
00182   private:
00183 
00184     /// A property object that we represent.
00185     TAO_Transport_Descriptor_Interface *transport_property_;
00186 
00187     /// Do we need to delete transport_property?
00188     CORBA::Boolean is_delete_;
00189 
00190     /**
00191      * This is a supplementary index. Would be set to zero by
00192      * default. Would be altered by the Transport_Cache of TAO. Please
00193      * see the documentation of TAO_Transport_Cache_Manager for
00194      * details.
00195      */
00196     CORBA::ULong index_;
00197   };
00198 }
00199 
00200 TAO_END_VERSIONED_NAMESPACE_DECL
00201 
00202 #if defined (__ACE_INLINE__)
00203 # include "tao/Cache_Entries.inl"
00204 #endif /* __ACE_INLINE__ */
00205 
00206 #include /**/ "ace/post.h"
00207 
00208 #endif /* TAO_CACHE_ENTRIES_H */

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