ANNA Suite  2020b
Multipurpose development suite for Telco applications
AutoSet.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_dbos_AutoSet_hpp
10 #define anna_dbos_AutoSet_hpp
11 
12 #include <anna/dbos/Set.hpp>
13 
14 namespace anna {
15 
16 namespace dbos {
17 
18 
98 template <typename T> class AutoSet {
99 public:
106  explicit AutoSet(Set <T>* t) : a_t(t) {;}
107 
111  AutoSet() : a_t(NULL) {;}
112 
116  ~AutoSet() { if(a_t != NULL) T::release(a_t); }
117 
123  Set <T>* operator -> () const { return a_t; }
124 
130  {
131  if(a_t == t)
132  return t;
133 
134  if(a_t != NULL)
135  T::release(a_t);
136 
137  return a_t = t;
138  }
139 
144  operator Set <T>*() const { return a_t; }
145 
146 private:
147  Set <T>* a_t;
148 };
149 
150 
151 }
152 }
153 
154 
155 
156 #endif
157 
158 
AutoSet(Set< T > *t)
Definition: AutoSet.hpp:106
~AutoSet()
Definition: AutoSet.hpp:116
Definition: Set.hpp:65
AutoSet()
Definition: AutoSet.hpp:111
Set< T > * operator->() const
Definition: AutoSet.hpp:123
Definition: app.hpp:12
Definition: AutoSet.hpp:98
Set< T > * operator=(Set< T > *t)
Definition: AutoSet.hpp:129