Gyoto::SmartPointee Class Reference

Can be pointed to by a SmartPointer. More...

`#include <GyotoSmartPointer.h>`

Inheritance diagram for Gyoto::SmartPointee:

## Public Types

typedef Gyoto::SmartPointer< Gyoto::SmartPointee > | Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &)
| A subcontractor builds an object upon order from the Factory.

## Public Member Functions

| SmartPointee (const SmartPointee &)
| Copy constructor.
void | incRefCount ()
| Increment the reference counter. Warning: Don't mess with the counter.
int | decRefCount ()
| Decrement the reference counter and return current value. Warning: Don't mess with the counter.
int | getRefCount ()
| Get the current number of references.

## Private Attributes

int | refCount
| Reference counter.
pthread_mutex_t | mutex_
| A mutex.

## Detailed Description

Can be pointed to by a SmartPointer.

A class can be pointed to by a SmartPointer when it inherits from class SmartPointee.

The SmartPointee methods need to be public to be accessed by all the SmartPointer < T > classes. However, it is a bad idea to manipulate the counter directly. To protect these methods inside your derive object, you can do as in the following example:

class Gyoto::Metric : protected Gyoto::SmartPointee
{
friend class Gyoto::SmartPointer<Gyoto::Metric::Generic>;
...
};
Gyoto::Metric::Generic
Base class for metrics.
Definition GyotoMetric.h:162
Gyoto::SmartPointee
Can be pointed to by a SmartPointer.
Definition GyotoSmartPointer.h:81
Gyoto::SmartPointer
Pointers performing reference counting.
Definition GyotoSmartPointer.h:135
Gyoto::Metric
Access to metrics.
Definition GyotoAstrobj.h:47
Gyoto
Namespace for the Gyoto library.
Definition GyotoAstrobj.h:44

## Member Typedef Documentation

## Subcontractor_t

typedef Gyoto::SmartPointer< Gyoto::SmartPointee > Gyoto::SmartPointee::Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &)

A subcontractor builds an object upon order from the Factory.

Various classes need to provide a subcontractor to be able to instantiate themselves upon order from the Factory. A subcontractor is a function (often a static member function) which accepts a pointer to a FactoryMessenger as unique parameter, communicates with the Factory using this messenger to read an XML description of the object to build, and returns this objet. SmartPointee::Subcontractor_t* is just generic enough a typedef to cast to and from other subcontractor types: Astrobj::Subcontractor_t, Metric::Subcontractor_t, Spectrum::Subcontractor_t. A subcontractor needs to be registered using the relevant Register() function: Astrobj::Register(), Metric::Register(), Spectrum::Register().

## Member Data Documentation

## mutex_

pthread_mutex_t Gyoto::SmartPointee::mutex_

private

A mutex.

When compiled with libpthread

The documentation for this class was generated from the following file:

- GyotoSmartPointer.h