| Polaris: ProtoWrapper.h Source File | ||
|
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members
ProtoWrapper.hGo to the documentation of this file.00001 /// 00002 /// 00003 #ifndef _PROTO_WRAPPER_H 00004 #define _PROTO_WRAPPER_H 00005 /// 00006 /// \class ProtoWrapper 00007 /// \brief The base Wrapper class 00008 /// \defgroup Polaris 00009 /// \ingroup Polaris 00010 /// C++ VDL 00011 /// \see ProtoWrapper.h 00012 /// \see ProtoWrapper.cc 00013 /// 00014 /// \endcode 00015 /// \section Overview Overview 00016 /// This is the base of the Wrapper classes and also functions as 00017 /// the stripped down version of a Wrapper containing 00018 /// only a pointer to the object. It is for use only by the 00019 /// Element class and should not be visible to any other 00020 /// classes. 00021 /// 00022 /// \endcode 00023 /// \section Description Description 00024 /// The Wrapper class is responsible for maintaining objects while 00025 /// in any Collection class. Wrappers perform all operations required 00026 /// for ownership indication, reference counting and for representing 00027 /// deleted objects in the form of Zombies. 00028 /// 00029 /// The underlying formula for the Collection hierarchy is that 00030 /// Collections hold wrappers rather than the objects 00031 /// themselves. When an object is placed in a Collection, a new 00032 /// wrapper is created and the object is manipulated through the 00033 /// wrapper. The Listable class contributes a standardized 00034 /// interface to the Wrapper classes and the Collection 00035 /// hierarchy, and, thus, for an object to be contained by a 00036 /// wrapper, it must derive from Listable. 00037 /// 00038 /// \endcode 00039 /// \section See See Also 00040 /// Wrapper, Listable 00041 /// 00042 #ifdef POLARIS_GNU_PRAGMAS 00043 #pragma interface 00044 #endif 00045 /// 00046 #include "../Listable.h" 00047 /// 00048 typedef void (*modify_proc) (Listable * &call_on, void *extra_data); 00049 /// 00050 class ProtoWrapper { 00051 protected: 00052 Listable *_ptr; ///< Pointer to object 00053 00054 void _object_errors() const; 00055 ///< performs p_asserts for object() 00056 00057 virtual int _is_proto_wrapper() const; 00058 ///< Is this wrapper a ProtoWrapper? 00059 00060 public: 00061 inline ProtoWrapper(); 00062 00063 virtual ~ProtoWrapper(); 00064 00065 inline void set(Listable *); 00066 ///< Set the Listable object contained by the Wrapper. 00067 00068 inline Listable *get() const; 00069 ///< Return the contained Listable object. 00070 00071 inline Listable *object() const; 00072 ///< Return the ProtoWrapper's object or report an error if invalid 00073 00074 inline Listable *object_address() const; 00075 ///< Return the contained Listable object. 00076 00077 inline int valid() const; 00078 ///< Does this point to a valid object (not a Zombie)? 00079 00080 virtual int structures_OK(); 00081 }; 00082 00083 00084 inline 00085 ProtoWrapper::ProtoWrapper() 00086 { 00087 _ptr = 0; 00088 } 00089 00090 inline Listable * 00091 ProtoWrapper::object() const 00092 { 00093 if ((!_ptr) || (!_ptr->valid())) _object_errors(); 00094 00095 return _ptr; 00096 } 00097 00098 inline void 00099 ProtoWrapper::set(Listable *l) 00100 { 00101 _ptr = l; 00102 } 00103 00104 inline Listable * 00105 ProtoWrapper::get() const 00106 { 00107 return _ptr; 00108 } 00109 00110 inline Listable * 00111 ProtoWrapper::object_address() const 00112 { 00113 return _ptr; 00114 } 00115 00116 inline int 00117 ProtoWrapper::valid() const 00118 { 00119 return (_ptr && (int) _ptr->valid()); 00120 } 00121 00122 #endif 00123 |
||
|