PLearn 0.1
Public Types | Public Member Functions | Protected Attributes
PLearn::PP< T > Class Template Reference

#include <PP.h>

Collaboration diagram for PLearn::PP< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef T element_type
 The type of the element this smart pointer points to.

Public Member Functions

 PP ()
 empty constructor
 PP (const T *the_ptr)
 copie constructor with ordinary ptr
 PP (const PP< T > &other)
 copie constructor with same type PP
template<class U >
 PP (const PP< U > &other)
 copie constructor with other type PP
bool isNull () const
bool isNotNull () const
 operator T * () const
 conversion to ordinary ptr
T * operator-> () const
 access to PPointable methods
T & operator* () const
 access to the pointed object
PP< T > & operator= (const T *otherptr)
 affectation operator to ordinary ptr
PP< T > & operator= (const PP< T > &other)
 affectation operator to same type PP
bool operator== (const PP< T > &other) const
bool operator== (const T *other) const
 ~PP ()

Protected Attributes

T * ptr

Detailed Description

template<class T>
class PLearn::PP< T >

Definition at line 90 of file PP.h.


Member Typedef Documentation

template<class T>
typedef T PLearn::PP< T >::element_type

The type of the element this smart pointer points to.

Definition at line 98 of file PP.h.


Constructor & Destructor Documentation

template<class T>
PLearn::PP< T >::PP ( ) [inline]

empty constructor

Definition at line 101 of file PP.h.

        :ptr(0)
    {}
template<class T>
PLearn::PP< T >::PP ( const T *  the_ptr) [inline]

copie constructor with ordinary ptr

Definition at line 106 of file PP.h.

    {
        ptr = const_cast<T*>(the_ptr);
        if(ptr)
            ptr->ref();
    }
template<class T>
PLearn::PP< T >::PP ( const PP< T > &  other) [inline]

copie constructor with same type PP

Definition at line 114 of file PP.h.

    { 
        ptr = const_cast<T*>((T*)other);
        if(ptr)
            ptr->ref();
    }
template<class T>
template<class U >
PLearn::PP< T >::PP ( const PP< U > &  other) [inline, explicit]

copie constructor with other type PP

this line is to make sure at compile time that U and T are compatible (one is a subclass of the other)

this line is to make sure at execution time that the true class of other.ptr is compatible with T, i.e. other.ptr is a T or a subclass of (otherwise return ptr = 0).

Note that dynamic_cast<T*>(const_cast<T*>(static_cast<const T*>((U*)other))) does not work properly (the dynamic_cast returns non-null when it should return 0, when the dynamic type is not correct).

Definition at line 123 of file PP.h.

    {
        if(other.isNull())
            ptr = 0;
        else
        {
            ptr = static_cast<T*>((U*)other);

            ptr = dynamic_cast<T*>((U*)other);

            if (!ptr)
                PLERROR("In PP constructor from smart pointer "
                        "of other class (constructing %s from %s)",
                        typeid(T).name(),typeid(U).name());
            ptr->ref();
        }
    }
template<class T>
PLearn::PP< T >::~PP ( ) [inline]

Definition at line 194 of file PP.h.

    { 
        if(ptr)
            ptr->unref();
    }

Member Function Documentation

template<class T>
bool PLearn::PP< T >::isNotNull ( ) const [inline]
template<class T>
bool PLearn::PP< T >::isNull ( ) const [inline]

Definition at line 152 of file PP.h.

Referenced by PLearn::VarArray::accumulateGradientFrom(), PLearn::VarArray::accumulateGradientTo(), PLearn::VarArray::accumulateTo(), PLearn::BasisSelectionRegressor::appendKernelFunctions(), PLearn::DeepReconstructorNet::build(), PLearn::VPLProcessor::build_(), PLearn::VPLPreprocessedLearner2::build_(), PLearn::VPLCombinedLearner::build_(), PLearn::VecStatsCollector::build_(), PLearn::TextSenseSequenceVMatrix::build_(), PLearn::PLearnerDiagonalKernel::build_(), PLearn::ObjectGenerator::build_(), PLearn::NeighborhoodBoxVolumeDensityEstimator::build_(), PLearn::LocallyMagnifiedDistribution::build_(), PLearn::KNNVMatrix::build_(), PLearn::InferenceRBM::build_(), PLearn::EntropyContrastLearner::build_(), PLearn::EntropyContrast::build_(), PLearn::DiverseComponentAnalysis::build_(), PLearn::BestAveragingPLearner::build_(), PLearn::PLearnerDiagonalKernel::computeGramMatrix(), PLearn::BasisSelectionRegressor::computeOutputFromFeaturevec(), PLearn::VarArray::copyFrom(), PLearn::VarArray::copyGradientFrom(), PLearn::VarArray::copyGradientTo(), PLearn::VarArray::copyMaxValueTo(), PLearn::VarArray::copyMinValueTo(), PLearn::VarArray::copyRValueFrom(), PLearn::VarArray::copyRValueTo(), PLearn::VarArray::copyTo(), PLearn::VVMatrix::createPreproVMat(), PLearn::deepCopy(), PLearn::diff(), PLearn::PLearnerDiagonalKernel::evaluate(), PLearn::DeepReconstructorNet::fineTuningFor1Epoch(), PLearn::SaltPepperNoiseVariable::fprop(), PLearn::RandomForcedValuesVariable::fprop(), PLearn::MultiSampleVariable::fprop(), PLearn::BernoulliSampleVariable::fprop(), PLearn::AdditiveGaussianNoiseVariable::fprop(), PLearn::ObjectGenerator::generateAllObjects(), PLearn::NNet::getCost(), PLearn::getDataSet(), PLearn::PrecomputedVMatrix::getNewRow(), PLearn::SequentialSplitter::getSplit(), PLearn::PLearnService::instance(), PLearn::VarArray::makeSharedGradient(), PLearn::VarArray::makeSharedRValue(), PLearn::VarArray::makeSharedValue(), PLearn::RemotePLearnServer::newObject(), PLearn::RemotePLearnServer::newObjectAsync(), PLearn::SequentialSplitter::nsplits(), PLearn::operator+=(), PLearn::operator-=(), PLearn::operator>>(), PLearn::HyperRetrain::optimize(), PLearn::PLearnService::reserveServers(), PLearn::NNet::train(), PLearn::NeighborhoodSmoothnessNNet::train(), PLearn::MultiInstanceNNet::train(), PLearn::LinearInductiveTransferClassifier::train(), PLearn::HyperLearner::train(), PLearn::DistRepNNet::train(), PLearn::DeepFeatureExtractorNNet::train(), and PLearn::ConditionalDensityNet::train().

    { return ptr==0; }
template<class T>
PLearn::PP< T >::operator T * ( ) const [inline]

conversion to ordinary ptr

Definition at line 159 of file PP.h.

    { return ptr; }
template<class T>
T& PLearn::PP< T >::operator* ( ) const [inline]

access to the pointed object

Definition at line 167 of file PP.h.

    { return *ptr; }
template<class T>
T* PLearn::PP< T >::operator-> ( ) const [inline]

access to PPointable methods

Definition at line 163 of file PP.h.

    { return ptr; }
template<class T>
PP<T>& PLearn::PP< T >::operator= ( const PP< T > &  other) [inline]

affectation operator to same type PP

Definition at line 185 of file PP.h.

Referenced by PLearn::PP< Storage< PP< OnlineLearningModule > > >::operator=().

    { return operator=((T*)other); }

Here is the caller graph for this function:

template<class T>
PP<T>& PLearn::PP< T >::operator= ( const T *  otherptr) [inline]

affectation operator to ordinary ptr

Definition at line 171 of file PP.h.

    {
        if(otherptr!=ptr)
        {
            if(ptr)
                ptr->unref();
            ptr = const_cast<T*>(otherptr);
            if(ptr)
                ptr->ref();
        }
        return *this;
    }
template<class T>
bool PLearn::PP< T >::operator== ( const PP< T > &  other) const [inline]

Definition at line 188 of file PP.h.

    { return ptr==other.ptr; }
template<class T>
bool PLearn::PP< T >::operator== ( const T *  other) const [inline]

Definition at line 191 of file PP.h.

    { return ptr==other; }

Member Data Documentation

template<class T>
T* PLearn::PP< T >::ptr [protected]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines