39 #ifndef __GyotoSmartPointer_H_ 40 #define __GyotoSmartPointer_H_ 49 class FactoryMessenger;
50 template <
class T>
class SmartPointer;
147 if (obj && obj->decRefCount() == 0) {
148 # if GYOTO_DEBUG_ENABLED 213 obj =
dynamic_cast<T*
>(
const_cast<U*
>(orig()));
235 const T& operator* ()
const 259 T* operator-> ()
const 286 right.
obj->incRefCount ();
308 if (obj) obj->incRefCount();
317 operator T*()
const {
return obj; }
320 operator const T*() {
return obj; }
326 operator bool ()
const {
return obj != NULL; }
332 bool operator! ()
const {
return obj == NULL; }
int getRefCount()
Get the current number of references.
SmartPointer(const SmartPointer< U > &orig)
Copy constructor from compatible type (used for casting)
Definition: GyotoSmartPointer.h:211
int decRefCount()
Decrement the reference counter and return current value. Warning: Don't mess with the counter...
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
Gyoto::SmartPointer< Gyoto::SmartPointee > Subcontractor_t(Gyoto::FactoryMessenger *)
A subcontractor builds an object upon order from the Factory.
Definition: GyotoSmartPointer.h:112
#define GYOTO_DEBUG_EXPR(a)
Output expression value in debug mode.
Definition: GyotoDefs.h:265
pthread_mutex_t mutex_
A mutex.
Definition: GyotoSmartPointer.h:87
T * obj
Real pointer, don't mess with it.
Definition: GyotoSmartPointer.h:139
const T * operator()() const
Get standard, non-smart pointer to object. Use with care.
Definition: GyotoSmartPointer.h:349
SmartPointer(T *orig=NULL)
Constructor from a standard pointer-to-class.
Definition: GyotoSmartPointer.h:167
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
void throwError(std::string)
Throw a Gyoto::Error.
int refCount
Reference counter.
Definition: GyotoSmartPointer.h:81
SmartPointer(const SmartPointer< T > &orig)
Copy constructor from same type.
Definition: GyotoSmartPointer.h:187
Pointers performing reference counting.
Definition: GyotoProperty.h:41
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:78
void incRefCount()
Increment the reference counter. Warning: Don't mess with the counter.
void decRef()
Decrement the reference counter. Warning: don't mess with it.
Definition: GyotoSmartPointer.h:145