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(); }
int getRefCount()
Get the current number of references.
SmartPointer(const SmartPointer< U > &orig)
Copy constructor from compatible type (used for casting)
Definition: GyotoSmartPointer.h:213
T & operator*()
Dereference operator "*".
Definition: GyotoSmartPointer.h:225
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
bool operator!=(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:276
#define GYOTO_DEBUG_EXPR(a)
Output expression value in debug mode.
Definition: GyotoDefs.h:280
pthread_mutex_t mutex_
A mutex.
Definition: GyotoSmartPointer.h:89
bool operator==(const SmartPointer< T > &right)
Comparison operator between two SmartPointer of same kind.
Definition: GyotoSmartPointer.h:271
T * obj
Real pointer, don't mess with it.
Definition: GyotoSmartPointer.h:141
const T * operator()() const
Get standard, non-smart pointer to object. Use with care.
Definition: GyotoSmartPointer.h:351
SmartPointer(T *orig=NULL)
Constructor from a standard pointer-to-class.
Definition: GyotoSmartPointer.h:169
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
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
void throwError(std::string)
Throw a Gyoto::Error.
int refCount
Reference counter.
Definition: GyotoSmartPointer.h:83
SmartPointer(const SmartPointer< T > &orig)
Copy constructor from same type.
Definition: GyotoSmartPointer.h:189
Pointers performing reference counting.
Definition: GyotoProperty.h:45
Can be pointed to by a SmartPointer.
Definition: GyotoSmartPointer.h:80
T * operator->()
Dereference operator "->".
Definition: GyotoSmartPointer.h:249
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:282
void decRef()
Decrement the reference counter. Warning: don't mess with it.
Definition: GyotoSmartPointer.h:147