STK++ 0.9.13
STK::IMixtureManager< Derived > Class Template Reference

Interface base class for mixture managers. More...

#include <STK_IMixtureManager.h>

Inheritance diagram for STK::IMixtureManager< Derived >:
Inheritance graph

Public Types

typedef hidden::MixtureManagerTraits< Derived >::DataHandler DataHandler
typedef hidden::MixtureManagerTraits< Derived >::Type Type
typedef hidden::MixtureManagerTraits< Derived >::MissingIndexes MissingIndexes
typedef hidden::MixtureManagerTraits< Derived >::MissingValues MissingValues
typedef hidden::MixtureManagerTraits< Derived >::Data Data
typedef hidden::MixtureManagerTraits< Derived >::DataBridgeType DataBridgeType

Public Member Functions

 IMixtureManager (DataHandler const *const p_handler)
 Default constructor, need an instance of a DataHandler.
 ~IMixtureManager ()
 destructor
DataHandler const *const p_handler () const
Clust::Mixture getIdModel (String const &idData) const
 Utility function allowing to find the idModel from the idData.
String getIdModelName (String const &idData) const
 Utility function allowing to find the idModel name from the idData.
IMixture * createMixture (String const &idData, int nbCluster)
 create a mixture and initialize it.
void registerDataBridge (IDataBridge *p_data)
 register a data bridge to the IMixtureManager.
void releaseDataBridge (String const &idData)
 release a data bridge from v_data_.
Data const & getData (String const &idData) const
 get the wrapper for any kind of data set using its Id
void getMissingValues (IMixture *p_mixture, MissingValues &missing) const
 get the missing values
void getParameters (IMixture *p_mixture, ArrayXX &data) const
 get the parameters from an IMixture.
void setParameters (IMixture *p_mixture, ArrayXX const &data) const
 set the parameters from an IMixture.
Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
Derived const & asDerived () const
 static cast : return a const reference of this with a cast to the derived class.
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
Derived const * asPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.

Protected Member Functions

IDataBridge * getDataBridge (String const &idData) const
 Utility lookup function allowing to find a DataBridge from its idData.
Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 ~IRecursiveTemplate ()
 destructor.

Private Member Functions

IMixture * createMixture (String const &modelName, String const &idData, int nbCluster)
 create a concrete mixture and initialize it.

Private Attributes

DataHandler const *const p_handler_
 A pointer on the concrete instance of the data handler.
std::vector< IDataBridge * > v_data_
 vector of pointers to the data components

Detailed Description

template<class Derived>
class STK::IMixtureManager< Derived >

Interface base class for mixture managers.

A mixture manager is a factory class for injection dependency in the STK++ derived class of the IMixtureComposer:

  • It handles all the creation and initialization stuff needed by mixture models,
  • It allows to get parameters and imputed missing values from specific mixtures,
  • It allows also to set parameters to a specific mixture,
  • all data set are enclosed in a DataBridge structure and stored in vector v_data_

The pseudo pure virtual method to implement in derived classes are

void getMissingValuesImpl(IMixture* p_mixture, MissingValues& missing) const;
void getParametersImpl(IMixture* p_mixture, ArrayXX& data) const;
void setParametersImpl(IMixture* p_mixture, ArrayXX const& data) const;
IMixture* createMixtureImpl(String const& modelName, String const& idData, int nbCluster);
hidden::MixtureManagerTraits< Derived >::MissingValues MissingValues
Interface base class for all the mixture models that will be processed by the composer.
Array2D< Real > ArrayXX
Specialization of the Array2D class for Real values.
Definition STK_Array2D.h:53
std::basic_string< Char > String
STK fundamental type of a String.
Template Parameters
Derivedany concrete class derived from this interface

Definition at line 69 of file STK_IMixtureManager.h.

Member Typedef Documentation

◆ Data

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::Data STK::IMixtureManager< Derived >::Data

Definition at line 76 of file STK_IMixtureManager.h.

◆ DataBridgeType

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::DataBridgeType STK::IMixtureManager< Derived >::DataBridgeType

Definition at line 77 of file STK_IMixtureManager.h.

◆ DataHandler

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::DataHandler STK::IMixtureManager< Derived >::DataHandler

Definition at line 72 of file STK_IMixtureManager.h.

◆ MissingIndexes

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::MissingIndexes STK::IMixtureManager< Derived >::MissingIndexes

Definition at line 74 of file STK_IMixtureManager.h.

◆ MissingValues

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::MissingValues STK::IMixtureManager< Derived >::MissingValues

Definition at line 75 of file STK_IMixtureManager.h.

◆ Type

template<class Derived>
typedef hidden::MixtureManagerTraits<Derived>::Type STK::IMixtureManager< Derived >::Type

Definition at line 73 of file STK_IMixtureManager.h.

Constructor & Destructor Documentation

◆ IMixtureManager()

template<class Derived>
STK::IMixtureManager< Derived >::IMixtureManager ( DataHandler const *const p_handler)

Default constructor, need an instance of a DataHandler.

Definition at line 191 of file STK_IMixtureManager.h.

193{}
DataHandler const *const p_handler() const
DataHandler const *const p_handler_
A pointer on the concrete instance of the data handler.

References p_handler(), and p_handler_.

◆ ~IMixtureManager()

template<class Derived>
STK::IMixtureManager< Derived >::~IMixtureManager ( )

destructor

Definition at line 196 of file STK_IMixtureManager.h.

197{
199 for (DataIterator it = v_data_.begin() ; it != v_data_.end(); ++it)
200 { delete (*it);}
201}
Interface base class for mixture managers.
std::vector< IDataBridge * > v_data_
vector of pointers to the data components

References v_data_.

Member Function Documentation

◆ createMixture() [1/2]

template<class Derived>
IMixture * STK::IMixtureManager< Derived >::createMixture ( String const & idData,
int nbCluster )

create a mixture and initialize it.

This method get the modelName from the DataHandler and then delegate the concrete creation to derived class using the pseudo pure virtual method createMixture( modelName, idData, nbCluster).

Parameters
idDataname of the model
nbClusternumber of cluster of the model
Returns
0 if the idData is not find, the result of createMixture( modelName, idData, nbCluster) otherwise.

Definition at line 230 of file STK_IMixtureManager.h.

231{
233 if (!p_handler_->getIdModelName( idData, modelName)) { return 0;};
235}
IMixture * createMixture(String const &idData, int nbCluster)
create a mixture and initialize it.

References createMixture(), and p_handler_.

Referenced by createMixture(), STK::IMixtureStatModel::createMixture(), and STK::IMixtureStatModel::createMixture().

◆ createMixture() [2/2]

template<class Derived>
IMixture * STK::IMixtureManager< Derived >::createMixture ( String const & modelName,
String const & idData,
int nbCluster )
inlineprivate

create a concrete mixture and initialize it.

Parameters
modelName,idDatastrings with the Id name of the model and of the data
nbClusternumber of cluster of the model

Definition at line 163 of file STK_IMixtureManager.h.

164 { return this->asDerived().createMixtureImpl(modelName, idData, nbCluster);}
Derived & asDerived()
static cast : return a reference of this with a cast to the derived class.

◆ getData()

template<class Derived>
hidden::MixtureManagerTraits< Derived >::Data const & STK::IMixtureManager< Derived >::getData ( String const & idData) const

get the wrapper for any kind of data set using its Id

Parameters
idDataId name of the data set attached to the mixture
Returns
a constant reference on the array with the data set

Definition at line 274 of file STK_IMixtureManager.h.

275{
277 if (p_bridge)
278 return static_cast<DataBridgeType*>(p_bridge)->dataij();
279 else
281}
#define STKRUNTIME_ERROR_1ARG(Where, Arg, Error)
Definition STK_Macros.h:129
hidden::MixtureManagerTraits< Derived >::DataBridgeType DataBridgeType
IDataBridge * getDataBridge(String const &idData) const
Utility lookup function allowing to find a DataBridge from its idData.

References getData(), getDataBridge(), and STKRUNTIME_ERROR_1ARG.

Referenced by getData().

◆ getDataBridge()

template<class Derived>
IDataBridge * STK::IMixtureManager< Derived >::getDataBridge ( String const & idData) const
protected

Utility lookup function allowing to find a DataBridge from its idData.

Parameters
idDatathe id name of the mixture we want to get
Returns
a pointer on the DataBridge

Definition at line 261 of file STK_IMixtureManager.h.

262{
264 for (ConstDataIterator it = v_data_.begin(); it != v_data_.end(); ++it)
265 { if ((*it)->idData() == idData) return (*it);}
266 return 0;
267}

References v_data_.

Referenced by getData().

◆ getIdModel()

template<class Derived>
Clust::Mixture STK::IMixtureManager< Derived >::getIdModel ( String const & idData) const

Utility function allowing to find the idModel from the idData.

Parameters
idDatathe id name of the data we want the idModel
Returns
the idModel

Definition at line 172 of file STK_IMixtureManager.h.

173{
176 {
177#ifdef STK_MIXTURE_VERY_VERBOSE
178 stk_cout << _T("In IMixtureManager::getIdModel, fail to get idData = ") << idData << _T("\n");
179#endif
181 }
182#ifdef STK_MIXTURE_VERY_VERBOSE
183 stk_cout << _T("In IMixtureManager::getIdModel, success to get idData = ") << idData << _T("\n");
184 stk_cout << _T("In IMixtureManager::getIdModel, modelName = ") << modelName << _T("\n");
185#endif
187}
#define _T(x)
Let x unmodified.
String getIdModelName(String const &idData) const
Utility function allowing to find the idModel name from the idData.
Mixture stringToMixture(String const &type)
Convert a String to a Mixture.

References _T, getIdModelName(), p_handler(), stk_cout, STK::Clust::stringToMixture(), and STK::Clust::unknown_mixture_.

◆ getIdModelName()

template<class Derived>
String STK::IMixtureManager< Derived >::getIdModelName ( String const & idData) const

Utility function allowing to find the idModel name from the idData.

Parameters
idDatathe id name of the data we want the idModel
Returns
the idModel name

Definition at line 207 of file STK_IMixtureManager.h.

208{
210 if (!p_handler_->getIdModelName( idData, modelName))
211 {
212#ifdef STK_MIXTURE_VERY_VERBOSE
213 stk_cout << _T("In IMixtureManager::getIdModelName, fail to get idData = ") << idData << _T("\n");
214#endif
215 }
216#ifdef STK_MIXTURE_VERY_VERBOSE
217 stk_cout << _T("In IMixtureManager::getIdModeName, success to get idData = ") << idData << _T("\n");
218 stk_cout << _T("In IMixtureManager::getIdModel, modelName = ") << modelName << _T("\n");
219#endif
220 return modelName;
221}

References _T, p_handler_, and stk_cout.

Referenced by getIdModel().

◆ getMissingValues()

template<class Derived>
void STK::IMixtureManager< Derived >::getMissingValues ( IMixture * p_mixture,
MissingValues & missing ) const
inline

get the missing values

Parameters
p_mixturepointer on the mixture
missingarray with the indexes and the missing values

Definition at line 131 of file STK_IMixtureManager.h.

132 {this->asDerived().getMissingValuesImpl(p_mixture, missing);}

Referenced by STK::IMixtureStatModel::getMissingValues().

◆ getParameters()

template<class Derived>
void STK::IMixtureManager< Derived >::getParameters ( IMixture * p_mixture,
ArrayXX & data ) const
inline

get the parameters from an IMixture.

Parameters
p_mixturepointer on the mixture
datathe array to return with the parameters

Definition at line 137 of file STK_IMixtureManager.h.

138 { this->asDerived().getParametersImpl(p_mixture, data);}

Referenced by STK::IMixtureStatModel::getParameters().

◆ p_handler()

template<class Derived>
DataHandler const *const STK::IMixtureManager< Derived >::p_handler ( ) const
inline
Returns
constant pointer on the data handler

Definition at line 85 of file STK_IMixtureManager.h.

85{ return p_handler_;}

Referenced by STK::IMixtureStatModel::createMixture(), getIdModel(), and IMixtureManager().

◆ registerDataBridge()

template<class Derived>
void STK::IMixtureManager< Derived >::registerDataBridge ( IDataBridge * p_data)

register a data bridge to the IMixtureManager.

For each mixture created and registered, a data bridge is created and registered so that it will be deleted when the mixture itself is deleted.

Parameters
p_dataa pointer on the data manager

Definition at line 243 of file STK_IMixtureManager.h.

244{ v_data_.push_back(p_data);}

References v_data_.

◆ releaseDataBridge()

template<class Derived>
void STK::IMixtureManager< Derived >::releaseDataBridge ( String const & idData)

release a data bridge from v_data_.

Parameters
idDataname of the data set to release

Definition at line 249 of file STK_IMixtureManager.h.

250{
252 for (DataIterator it = v_data_.begin(); it != v_data_.end(); ++it)
253 { if ((*it)->idData() == idData) {delete (*it); v_data_.erase(it); break;}}
254}

References v_data_.

Referenced by STK::IMixtureStatModel::removeMixture().

◆ setParameters()

template<class Derived>
void STK::IMixtureManager< Derived >::setParameters ( IMixture * p_mixture,
ArrayXX const & data ) const
inline

set the parameters from an IMixture.

Parameters
p_mixturepointer on the mixture
datathe array with the parameters to set

Definition at line 143 of file STK_IMixtureManager.h.

144 { this->asDerived().setParametersImpl(p_mixture, data);}

Referenced by STK::IMixtureStatModel::setParameters().

Member Data Documentation

◆ p_handler_

template<class Derived>
DataHandler const* const STK::IMixtureManager< Derived >::p_handler_
private

A pointer on the concrete instance of the data handler.

Definition at line 155 of file STK_IMixtureManager.h.

Referenced by createMixture(), getIdModelName(), and IMixtureManager().

◆ v_data_

template<class Derived>
std::vector<IDataBridge*> STK::IMixtureManager< Derived >::v_data_
private

vector of pointers to the data components

Definition at line 157 of file STK_IMixtureManager.h.

Referenced by getDataBridge(), registerDataBridge(), releaseDataBridge(), and ~IMixtureManager().


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