39 #ifndef __GyotoSmartPointer_H_ 40 #define __GyotoSmartPointer_H_ 49 class FactoryMessenger;
50 template <
class T>
class SmartPointer;
150 if (
obj &&
obj->decRefCount() == 0) {
151 # if GYOTO_DEBUG_ENABLED 216 obj =
dynamic_cast<T*
>(
const_cast<U*
>(orig()));
289 right.
obj->incRefCount ();
311 if (
obj)
obj->incRefCount();
320 operator T*()
const {
return obj; }
323 operator const T*() {
return obj; }
329 operator bool ()
const {
return obj != NULL; }
335 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:214
SmartPointee & operator=(const SmartPointee &)
Assignment.
T & operator*()
Dereference operator "*".
Definition: GyotoSmartPointer.h:226
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:277
#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:272
T * obj
Real pointer, don't mess with it.
Definition: GyotoSmartPointer.h:142
const T * operator()() const
Get standard, non-smart pointer to object. Use with care.
Definition: GyotoSmartPointer.h:352
SmartPointer(T *orig=NULL)
Constructor from a standard pointer-to-class.
Definition: GyotoSmartPointer.h:170
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:115
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:46
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:190
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:250
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:283
void decRef()
Decrement the reference counter. Warning: don't mess with it.
Definition: GyotoSmartPointer.h:148