39#ifndef __GyotoSmartPointer_H_
40#define __GyotoSmartPointer_H_
49 class FactoryMessenger;
50 template <
class T>
class SmartPointer;
149 if (
obj &&
obj->decRefCount() == 0) {
150# if GYOTO_DEBUG_ENABLED
215 obj =
dynamic_cast<T*
>(
const_cast<U*
>(orig()));
288 right.
obj->incRefCount ();
310 if (
obj)
obj->incRefCount();
319 operator T*()
const {
return obj; }
322 operator const T*() {
return obj; }
328 operator bool ()
const {
return obj != NULL; }
334 bool operator! ()
const {
return obj == NULL; }
337 ~SmartPointer< T > () {
decRef(); }
#define GYOTO_DEBUG_EXPR(a)
Output expression value in debug mode.
Definition: GyotoDefs.h:278
Factory / SmartPointee::Subcontractor_t interface.
Definition: GyotoFactoryMessenger.h:92
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:81
int decRefCount()
Decrement the reference counter and return current value. Warning: Don't mess with the counter.
Gyoto::SmartPointer< Gyoto::SmartPointee > Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &)
A subcontractor builds an object upon order from the Factory.
Definition: GyotoSmartPointer.h:114
int getRefCount()
Get the current number of references.
void incRefCount()
Increment the reference counter. Warning: Don't mess with the counter.
int refCount
Reference counter.
Definition: GyotoSmartPointer.h:83
pthread_mutex_t mutex_
A mutex.
Definition: GyotoSmartPointer.h:89
SmartPointee(const SmartPointee &)
Copy constructor.
Pointers performing reference counting.
Definition: GyotoSmartPointer.h:135
SmartPointer(const SmartPointer< T > &orig)
Copy constructor from same type.
Definition: GyotoSmartPointer.h:189
void decRef()
Decrement the reference counter. Warning: don't mess with it.
Definition: GyotoSmartPointer.h:147
bool operator==(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:271
T & operator*()
Dereference operator "*".
Definition: GyotoSmartPointer.h:225
SmartPointer(T *orig=NULL)
Constructor from a standard pointer-to-class.
Definition: GyotoSmartPointer.h:169
T * operator->()
Dereference operator "->".
Definition: GyotoSmartPointer.h:249
const T * operator()() const
Get standard, non-smart pointer to object. Use with care.
Definition: GyotoSmartPointer.h:351
SmartPointer(const SmartPointer< U > &orig)
Copy constructor from compatible type (used for casting)
Definition: GyotoSmartPointer.h:213
T * obj
Real pointer, don't mess with it.
Definition: GyotoSmartPointer.h:141
SmartPointer< T > & operator=(SmartPointer< T > &right)
Copy a SmartPointer to another (already defined) SmartPointer of same kind.
Definition: GyotoSmartPointer.h:282
bool operator!=(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:276
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
void throwError(std::string)
Throw a Gyoto::Error.