39 #ifndef __GyotoSmartPointer_H_
40 #define __GyotoSmartPointer_H_
50 class FactoryMessenger;
147 if (
obj &&
obj->decRefCount() == 0) {
148 # if GYOTO_DEBUG_ENABLED
213 obj =
dynamic_cast<T*
>(
const_cast<U*
>(orig()));
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; }
335 ~SmartPointer< T > () {
decRef(); }
int getRefCount()
Get the current number of references.
const T * operator()() const
Get standard, non-smart pointer to object. Use with care.
Definition: GyotoSmartPointer.h:349
SmartPointer(const SmartPointer< U > &orig)
Copy constructor from compatible type (used for casting)
Definition: GyotoSmartPointer.h:211
T & operator*()
Dereference operator "*".
Definition: GyotoSmartPointer.h:223
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:91
bool operator!=(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:274
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:262
pthread_mutex_t mutex_
A mutex.
Definition: GyotoSmartPointer.h:88
bool operator==(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:269
T * obj
Real pointer, don't mess with it.
Definition: GyotoSmartPointer.h:139
SmartPointer(T *orig=NULL)
Constructor from a standard pointer-to-class.
Definition: GyotoSmartPointer.h:167
void throwError(std::string)
Throw a Gyoto::Error.
int refCount
Reference counter.
Definition: GyotoSmartPointer.h:82
SmartPointer(const SmartPointer< T > &orig)
Copy constructor from same type.
Definition: GyotoSmartPointer.h:187
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:51
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:79
T * operator->()
Dereference operator "->".
Definition: GyotoSmartPointer.h:247
void incRefCount()
Increment the reference counter. Warning: Don't mess with the counter.
SmartPointer< T > & operator=(SmartPointer< T > &right)
Copy a SmartPointer to another (already defined) SmartPointer of same kind.
Definition: GyotoSmartPointer.h:280
void decRef()
Decrement the reference counter. Warning: don't mess with it.
Definition: GyotoSmartPointer.h:145