Util--  1.1
pointer.hh
Go to the documentation of this file.
1 /* -*- C++ -*-
2  * $Id: pointer.hh 1004 2005-10-10 12:55:33Z sjoyeux $
3  */
4 #ifndef UTILMM_SMART_POINTER_HEADER
5 # define UTILMM_SMART_POINTER_HEADER
6 #include "utilmm/config/config.h"
7 
8 # include <stdexcept>
9 
10 #include "utilmm/singleton/use.hh"
11 
12 namespace utilmm {
19  namespace smart {
20 
29  class null_access :public std::runtime_error {
30  public:
35  null_access(std::string const &message)
36  : std::runtime_error(message) {}
37  }; // class utilmm::smart::null_access
38 
51  template<class Manager>
52  class pointer {
53  private:
55 
56  public:
61  typedef typename Manager::base_type base_type;
74 
86  explicit pointer(pointer_type ptr=0);
95  pointer(pointer const &other);
96 
103  ~pointer();
104 
123  void reset(pointer_type ptr=0);
124 
131  void swap(pointer &other);
132 
142  pointer &operator= (pointer const &other);
143 
151  bool null() const;
159  bool operator! () const;
160 
170  bool operator==(pointer const &other) const;
179  bool operator!=(pointer const &other) const;
180 
190  pointer_type operator->() const;
198  reference_type operator* () const;
199 
200  private:
201  typename Manager::mem_cell pointee;
202  }; // class utilmm::smart::pointer<>
203 
204  } // namespace utilmm::smart
205 } // namespace utilmm
206 
207 # define IN_UTILMM_SMART_POINTER_HEADER
208 #include "utilmm/smart/bits/pointer.tcc"
209 # undef IN_UTILMM_SMART_POINTER_HEADER
210 #endif // UTILMM_SMART_POINTER_HEADER
211 
base_type * pointer_type
basic pointer type
Definition: pointer.hh:67
void reset(pointer_type ptr=0)
Checnging pointed value.
pointer(pointer_type ptr=0)
Constructor.
bool operator!=(pointer const &other) const
Difference test.
pointer_type operator->() const
Access operator.
pointer & operator=(pointer const &other)
Assignement operator.
reference_type operator*() const
dereference operator
bool operator!() const
Check if null.
bool operator==(pointer const &other) const
Equality test.
base_type & reference_type
Basic reference type.
Definition: pointer.hh:73
Generic smart pointer.
Definition: pointer.hh:52
bool null() const
Check if null.
void swap(pointer &other)
pointed cell exchange
null_access(std::string const &message)
Constructor.
Definition: pointer.hh:35
Manager::base_type base_type
Pointed type.
Definition: pointer.hh:61
~pointer()
Destructor.
Declararation of utilmm::singleton::use class.
Null pointer access exception.
Definition: pointer.hh:29

Generated on Tue Oct 9 2018 10:12:45 for Util-- by doxygen 1.8.6
SourceForge.net Project Page