MADARA  3.2.3
ScopedArray.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 #ifndef _MADARA_UTILITY_SCOPED_ARRAY_H_
3 #define _MADARA_UTILITY_SCOPED_ARRAY_H_
4 
5 namespace madara
6 {
7  namespace utility
8  {
21  template <typename T>
23  {
24  public:
26  ScopedArray (void);
27 
29  ScopedArray (T * ptr, bool increase_count = false);
30 
32  ScopedArray (const ScopedArray & rhs);
33 
35  virtual ~ScopedArray (void);
36 
39  void operator= (T * ptr);
40 
42  void operator= (const ScopedArray & rhs);
43 
45  T * get_ptr (void);
46 
48  const T * get_ptr (void) const;
49 
51  T * get (void);
52 
54  const T * get (void) const;
55 
56  private:
58  inline void increment (void);
59 
61  inline void decrement (void);
62 
65  struct Shim
66  {
68  Shim (T * t);
69 
71  ~Shim (void);
72 
74  T * t_;
75 
77  int refcount_;
78  };
79 
82  };
83  }
84 }
86 
87 #endif /* _MADARA_UTILITY_SCOPED_ARRAY_H_ */
virtual ~ScopedArray(void)
Dtor will delete pointer if refcount becomes 0.
Definition: ScopedArray.inl:33
T * t_
Pointer to the object that&#39;s being reference counted.
Definition: ScopedArray.h:74
Shim * ptr_
Pointer to the Shim.
Definition: ScopedArray.h:81
void increment(void)
implementation of the increment operation
ScopedArray(void)
default Ctor
Definition: ScopedArray.inl:9
void decrement(void)
implementation of the decrement operation
int refcount_
Current value of the reference count.
Definition: ScopedArray.h:77
T * get_ptr(void)
get the underlying pointer
Definition: ScopedArray.inl:68
void operator=(T *ptr)
assignment operator for times when you don&#39;t want the reference increased for incoming ptr ...
Definition: ScopedArray.inl:42
Provides utility functions and classes for common tasks and needs.
Definition: IteratorImpl.h:14
A shim class that keeps track of the reference count and a pointer to the type T that&#39;s reference cou...
Definition: ScopedArray.h:65
Copyright (c) 2015 Carnegie Mellon University.
This template class provides transparent reference counting of its template parameter T...
Definition: ScopedArray.h:22