Referenced.h
Go to the documentation of this file.
1 
5 #ifndef OPENHRP_UTIL_REFERENCED_H_INCLUDED
6 #define OPENHRP_UTIL_REFERENCED_H_INCLUDED
7 
8 #include <boost/intrusive_ptr.hpp>
9 
10 namespace hrp {
11  class Referenced;
12  void intrusive_ptr_add_ref(Referenced* obj);
13  void intrusive_ptr_release(Referenced* obj);
14 
15  class Referenced
16  {
17  public:
19  virtual ~Referenced() { }
20 
21  protected:
22  int refCounter() { return refCounter_; }
23 
24  private:
25  friend void intrusive_ptr_add_ref(Referenced* obj);
26  friend void intrusive_ptr_release(Referenced* obj);
27 
29  };
30 
32  obj->refCounter_++;
33  }
34 
36  obj->refCounter_--;
37  if(obj->refCounter_ == 0){
38  delete obj;
39  }
40  }
41 };
42 
43 #endif
void intrusive_ptr_add_ref(Referenced *obj)
Definition: Referenced.h:31
void intrusive_ptr_release(Referenced *obj)
Definition: Referenced.h:35
int refCounter()
Definition: Referenced.h:22
friend void intrusive_ptr_release(Referenced *obj)
Definition: Referenced.h:35
friend void intrusive_ptr_add_ref(Referenced *obj)
Definition: Referenced.h:31
virtual ~Referenced()
Definition: Referenced.h:19


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Thu Sep 8 2022 02:24:05