Public Member Functions | Private Member Functions | Private Attributes | Friends

alize::MixtureServer Class Reference

#include <MixtureServer.h>

Inheritance diagram for alize::MixtureServer:
Inheritance graph
[legend]
Collaboration diagram for alize::MixtureServer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MixtureServer (const Config &config)
 MixtureServer (const FileName &f, const Config &c)
virtual ~MixtureServer ()
void reset ()
DistribcreateDistrib ()
DistribcreateDistrib (const DistribType type, unsigned long vectSize)
DistribduplicateDistrib (const Distrib &d)
MixturecreateMixture ()
MixturecreateMixture (unsigned long dc)
MixturecreateMixture (unsigned long dc, DistribType)
MixtureduplicateMixture (const Mixture &mix, DuplDistrib=DUPL_DISTRIB)
DistribgetDistrib (unsigned long index) const
MixturegetMixture (unsigned long index) const
void setDistribToMixture (Mixture &mix, Distrib &distr, weight_t w, unsigned long index)
void addDistribToMixture (Mixture &mix, Distrib &distr, weight_t w=0.0)
void deleteMixtures (unsigned long f, unsigned long l)
void deleteMixture (const Mixture &m)
void deleteUnusedDistribs ()
DistribGDcreateDistribGD ()
DistribGFcreateDistribGF ()
DistribGDduplicateDistrib (const DistribGD &d)
DistribGFduplicateDistrib (const DistribGF &d)
MixtureGDcreateMixtureGD ()
MixtureGFcreateMixtureGF ()
MixtureGDcreateMixtureGD (unsigned long dc)
MixtureGFcreateMixtureGF (unsigned long dc)
MixtureGDduplicateMixture (const MixtureGD &mix, DuplDistrib=DUPL_DISTRIB)
MixtureGFduplicateMixture (const MixtureGF &mix, DuplDistrib=DUPL_DISTRIB)
MixtureGDduplicateMixtureGD (const Mixture &mix, DuplDistrib=DUPL_DISTRIB)
MixtureGFduplicateMixtureGF (const Mixture &mix, DuplDistrib=DUPL_DISTRIB)
DistribGDgetDistribGD (unsigned long index) const
DistribGFgetDistribGF (unsigned long index) const
MixtureGDgetMixtureGD (unsigned long index) const
MixtureGFgetMixtureGF (unsigned long index) const
MixtureloadMixture (const FileName &f)
MixtureGDloadMixtureGD (const FileName &f)
MixtureGFloadMixtureGF (const FileName &f)
void loadMixture (Mixture &m, const FileName &f)
unsigned long loadMixture (const XLine &l)
unsigned long getDistribCount () const
unsigned long getVectSize () const
unsigned long getMixtureCount () const
long getMixtureIndex (const String &id) const
void setMixtureId (Mixture &mix, const String &id)
const StringgetServerName () const
void setServerName (const String &)
void load (const FileName &f)
void save (const FileName &f) const
virtual String getClassName () const
virtual String toString () const

Private Member Functions

void addDistribToDict (Distrib &)
void addMixtureToDict (Mixture &)
String newId ()
MixtureloadMixture (const FileName &f, DistribType)
void autoSetMixtureId (Mixture &m, String id)
 MixtureServer (const MixtureServer &m)
const MixtureServeroperator= (const MixtureServer &)
bool operator== (const MixtureServer &)
bool operator!= (const MixtureServer &)

Private Attributes

const Config_config
String _serverName
DistribRefVector _distribDict
MixtureDict _mixtureDict
unsigned long _lastMixtureId
unsigned long _vectSize
bool _vectSizeDefined

Friends

class TestMixtureServer

Detailed Description

Class used to store and manage Mixture and Distrib objects. This class is responsible for creating and deleting these objects. Both mixtures and distributions can be accessed by an index. Mixtures can share the same distributions. In addition, mixtures can be found using the identifier. Each mixture identifier is unique.

Author:
Frederic Wils frederic.wils@lia.univ-avignon.fr
Version:
1.0
Date:
2003

Definition at line 92 of file MixtureServer.h.


Constructor & Destructor Documentation

alize::MixtureServer::MixtureServer ( const Config config ) [explicit]

Creates a MixtureServer object

Parameters:
configparameters to build the server.
alize::MixtureServer::MixtureServer ( const FileName f,
const Config c 
) [explicit]

Creates a MixtureServer object and load data from a file

Parameters:
fname of the file.
cconfiguration
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
virtual alize::MixtureServer::~MixtureServer (  ) [virtual]
alize::MixtureServer::MixtureServer ( const MixtureServer m ) [private]

Member Function Documentation

void alize::MixtureServer::addDistribToDict ( Distrib  ) [private]
void alize::MixtureServer::addDistribToMixture ( Mixture mix,
Distrib distr,
weight_t  w = 0.0 
)

Adds a distribution to a mixture. The number of distributions increases by 1 for the mixture.

Parameters:
mixthe mixture
distrthe distribution to add
wweight of the distribution
void alize::MixtureServer::addMixtureToDict ( Mixture  ) [private]
void alize::MixtureServer::autoSetMixtureId ( Mixture m,
String  id 
) [private]
Distrib& alize::MixtureServer::createDistrib (  )

Creates a new distribution. The type and other parameters are specified in the configuration of the server

Returns:
a reference to the distribution
Distrib& alize::MixtureServer::createDistrib ( const DistribType  type,
unsigned long  vectSize 
)

Creates a new distribution

Parameters:
typedistribution type
vectSize
Returns:
a reference to the distribution
DistribGD& alize::MixtureServer::createDistribGD (  )

Creates a new distribution GD and adds it to the internal dictionnary of the server

Returns:
a reference to the distribution
DistribGF& alize::MixtureServer::createDistribGF (  )

Creates a new distribution GF and adds it to the internal dictionnary of the server

Returns:
a reference to the distribution
Mixture& alize::MixtureServer::createMixture (  )

Creates a new mixture inside the server. The type and the number of distributions must be defined in the configuration of the server. A default identifier "#n" is set where n is a number.

Returns:
a reference to the mixture
Mixture& alize::MixtureServer::createMixture ( unsigned long  dc )

Creates a new mixture inside the server. The type must be defined in the configuration of the server. A default identifier "#n" is set where n is a number.

Parameters:
dcthe number of distribution to create for this mixture.
Returns:
a reference to the mixture
Mixture& alize::MixtureServer::createMixture ( unsigned long  dc,
DistribType   
)

Creates a new mixture inside the server. A default identifier "#n" is set where n is a number.

Parameters:
dcthe number of distribution to create for this mixture.
typedistribution type
Returns:
a reference to the mixture
MixtureGD& alize::MixtureServer::createMixtureGD (  )

Creates a new mixture GD inside the server. The number of distributions must be specified in the configuration of the server. A default identifier "#n" is set where n is a number.

Returns:
a reference to the mixture GD
Exceptions:
IdAlreadyExistsException
MixtureGD& alize::MixtureServer::createMixtureGD ( unsigned long  dc )

Creates a new mixture GD inside the server. The type must be defined in the configuration of the server. A default identifier "#n" is set where n is a number.

Parameters:
dcthe number of distribution to create for this mixture.
Returns:
a reference to the mixture GD
MixtureGF& alize::MixtureServer::createMixtureGF (  )

Creates a new mixture GF inside the server. The number of distributions must be specified in the configuration of the server. A default identifier "#n" is set where n is a number.

Returns:
a reference to the mixture GF
Exceptions:
IdAlreadyExistsException
MixtureGF& alize::MixtureServer::createMixtureGF ( unsigned long  dc )

Creates a new mixture GF inside the server. The type must be defined in the configuration of the server. A default identifier "#n" is set where n is a number.

Parameters:
dcthe number of distribution to create for this mixture.
Returns:
a reference to the mixture GF
void alize::MixtureServer::deleteMixture ( const Mixture m )

Deletes a mixture

Warning:
Does not delete associated distributions. Use method deleteUnusedDistribs()
Parameters:
mthe mixture
void alize::MixtureServer::deleteMixtures ( unsigned long  f,
unsigned long  l 
)

Deletes a set of mixtures.

Warning:
Does not delete associated distributions. Use method deleteUnusedDistribs()
Parameters:
findex of the first mixture
lindex of the last mixture
void alize::MixtureServer::deleteUnusedDistribs (  )

Removes all unused distributions (unreferenced by a mixture)

DistribGD& alize::MixtureServer::duplicateDistrib ( const DistribGD d )

Duplicates an existing distribution GD. The new one is added to the internal dictionnary

Parameters:
dthe distribution to copy
Returns:
a reference to the new distribution GD
DistribGF& alize::MixtureServer::duplicateDistrib ( const DistribGF d )

Duplicates an existing distribution GF. The new one is added to the internal dictionnary

Parameters:
dthe distribution to copy
Returns:
a reference to the new distribution GF
Distrib& alize::MixtureServer::duplicateDistrib ( const Distrib d )

Duplicates an existing distribution. The new one is added to the internal dictionnary

Parameters:
dthe distribution to copy
Returns:
a reference to the new distribution
Mixture& alize::MixtureServer::duplicateMixture ( const Mixture mix,
DuplDistrib  = DUPL_DISTRIB 
)

Duplicates inside the server an existing mixture. Distributions can be duplicated too. If they are not, the new mixture and the original one share the same distributions. The new mixture identifier is equal to the original mixture identifier followed by " #n" where n is a number

Parameters:
mixthe mixture to duplicate.
duplicateDistribDUPL_DISTRIB to duplicate the distributions; SHARE_DISTRIB to share the existing distributions. Default = DUPL_DISTRIB.
Returns:
a reference to the new mixture
MixtureGD& alize::MixtureServer::duplicateMixture ( const MixtureGD mix,
DuplDistrib  = DUPL_DISTRIB 
)

Duplicates inside the server an existing mixture GD. Distributions can be duplicated too. If they are not, the new mixture and the original one share the same distributions. The new mixture identifier is equal to the original mixture identifier followed by "#n" where n is a number

Parameters:
mixthe mixture GD to duplicate.
duplicateDistribDUPL_DISTRIB to duplicate the distributions; SHARE_DISTRIB to share the existing distributions. Default = DUPL_DISTRIB.
Returns:
a reference to the new mixture GD
MixtureGF& alize::MixtureServer::duplicateMixture ( const MixtureGF mix,
DuplDistrib  = DUPL_DISTRIB 
)

Duplicates inside the server an existing mixture GF. Distributions can be duplicated too. If they are not, the new mixture and the original one share the same distributions. The new mixture identifier is equal to the original mixture identifier followed by "#n" where n is a number

Parameters:
mixthe mixture GF to duplicate.
duplicateDistribDUPL_DISTRIB to duplicate the distributions; SHARE_DISTRIB to share the existing distributions. Default = DUPL_DISTRIB.
Returns:
a reference to the new mixture GF
MixtureGD& alize::MixtureServer::duplicateMixtureGD ( const Mixture mix,
DuplDistrib  = DUPL_DISTRIB 
)

Duplicates inside the server an existing mixture GD. Distributions can be duplicated too. If they are not, the new mixture and the original one share the same distributions. The new mixture identifier is equal to the original mixture identifier followed by "#n" where n is a number

Parameters:
mixthe mixture GD to duplicate.
duplicateDistribDUPL_DISTRIB to duplicate the distributions; SHARE_DISTRIB to share the existing distributions. Default = DUPL_DISTRIB.
Returns:
a reference to the new mixture GD
MixtureGF& alize::MixtureServer::duplicateMixtureGF ( const Mixture mix,
DuplDistrib  = DUPL_DISTRIB 
)

Duplicates inside the server an existing mixture GF. Distributions can be duplicated too. If they are not, the new mixture and the original one share the same distributions. The new mixture identifier is equal to the original mixture identifier followed by "#n" where n is a number

Parameters:
mixthe mixture GF to duplicate.
duplicateDistribDUPL_DISTRIB to duplicate the distributions; SHARE_DISTRIB to share the existing distributions. Default = DUPL_DISTRIB.
Returns:
a reference to the new mixture GF
virtual String alize::MixtureServer::getClassName (  ) const [virtual]

Returns the name of the class

Returns:
the name of the class of the object as a String

Implements alize::Object.

Distrib& alize::MixtureServer::getDistrib ( unsigned long  index ) const

Gets a distribution using its index

Parameters:
indexthe index
Returns:
a reference to the distribution
Exceptions:
IndexOutOfBoundsException
unsigned long alize::MixtureServer::getDistribCount (  ) const

Returns the number of distributions stored inside the server

Returns:
the number of distributions stored inside the server
DistribGD& alize::MixtureServer::getDistribGD ( unsigned long  index ) const

Gets a distribution GD using its index

Parameters:
indexthe index
Returns:
a reference to the distribution
Exceptions:
IndexOutOfBoundsException
Exceptionif a distrib was found but is not a distrib GD
DistribGF& alize::MixtureServer::getDistribGF ( unsigned long  index ) const

Gets a distribution GF using its index

Parameters:
indexthe index
Returns:
a reference to the distribution
Exceptions:
IndexOutOfBoundsException
Exceptionif a distrib was found but is not a distrib GF
Mixture& alize::MixtureServer::getMixture ( unsigned long  index ) const

Gets a mixture using its index

Parameters:
indexthe index
Returns:
a reference to the mixture
Exceptions:
IndexOutOfBoundsException
unsigned long alize::MixtureServer::getMixtureCount (  ) const

Returns the number of mixtures stored inside the server

Returns:
the number of mixtures stored inside the server
MixtureGD& alize::MixtureServer::getMixtureGD ( unsigned long  index ) const

Gets a mixture GD using its index

Parameters:
indexthe index
Returns:
a reference to the mixture
Exceptions:
IndexOutOfBoundsException
Exceptionif a mixture was found but is not a mixture GD
MixtureGF& alize::MixtureServer::getMixtureGF ( unsigned long  index ) const

Gets a mixture GF using its index

Parameters:
indexthe index
Returns:
a reference to the mixture
Exceptions:
IndexOutOfBoundsException
Exceptionif a mixture was found but is not a mixture GF
long alize::MixtureServer::getMixtureIndex ( const String id ) const

Tests whether a mixture with a particular identifier exists inside the server

Parameters:
ididentifier to find
Returns:
the index of the mixture if it exists; -1 otherwise
const String& alize::MixtureServer::getServerName (  ) const
unsigned long alize::MixtureServer::getVectSize (  ) const

Returns the vectSize value

Returns:
the vectSize value
Exceptions:
Exceptionif neither mixture nor distribution is stored (no vectSize defined)
void alize::MixtureServer::load ( const FileName f )

Loads a mixture server from a file File naming rules are the same as mixture file.

Parameters:
fname of the file.
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
Mixture& alize::MixtureServer::loadMixture ( const FileName f )

Creates a new mixture in the server and loads data from a file

Parameters:
fthe mixture file to read
Returns:
a reference to the mixture
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
void alize::MixtureServer::loadMixture ( Mixture m,
const FileName f 
)

Loads data from a mixture file into an existing mixture

Parameters:
fthe file to read
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
unsigned long alize::MixtureServer::loadMixture ( const XLine l )

Loads mixtures from a list of single mixture file

Parameters:
lthe list of mixture file to read
Returns:
the index of the first mixture loaded in the server
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
Mixture& alize::MixtureServer::loadMixture ( const FileName f,
DistribType   
) [private]
MixtureGD& alize::MixtureServer::loadMixtureGD ( const FileName f )

Creates a new mixtureGD in the server and loads data from a file

Parameters:
fthe mixture file to read
Returns:
a reference to the mixture
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
MixtureGF& alize::MixtureServer::loadMixtureGF ( const FileName f )

Creates a new mixtureGF in the server and loads data from a file

Parameters:
fthe mixture file to read
Returns:
a reference to the mixture
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
String alize::MixtureServer::newId (  ) [private]
bool alize::MixtureServer::operator!= ( const MixtureServer  ) [private]

Not implemented

const MixtureServer& alize::MixtureServer::operator= ( const MixtureServer  ) [private]

Not implemented

bool alize::MixtureServer::operator== ( const MixtureServer  ) [private]

Not implemented

void alize::MixtureServer::reset (  )

Deletes all mixtures and distributions inside the server.

void alize::MixtureServer::save ( const FileName f ) const

Saves a mixture server into a file File naming rules are the same as mixture file.

Parameters:
fname of the file.
Exceptions:
IOExceptionif an I/O error occurs
FileNotFoundException
InvalidDataException
void alize::MixtureServer::setDistribToMixture ( Mixture mix,
Distrib distr,
weight_t  w,
unsigned long  index 
)

Assigns a distribution to a mixture instead of an other distribution. The number of distributions is not changed in the mixture.

Parameters:
mixthe mixture
distrthe distribution to set in the mixture
wweight of the distribution
indexindex of the distribution inside the mixture
Exceptions:
IndexOutOfBoundsException
void alize::MixtureServer::setMixtureId ( Mixture mix,
const String id 
)

Sets the identifier of a mixture

Parameters:
mixthe mixture
idthe id
Exceptions:
IdAlreadyExistsException
void alize::MixtureServer::setServerName ( const String  )
virtual String alize::MixtureServer::toString (  ) const [virtual]

This method is frequently overridden in the derived classes. If it is not, it returns the name of the class of the object and the address of the object

Returns:
a description of the object

Reimplemented from alize::Object.


Friends And Related Function Documentation

friend class TestMixtureServer [friend]

Definition at line 94 of file MixtureServer.h.


Member Data Documentation

Definition at line 484 of file MixtureServer.h.

Definition at line 486 of file MixtureServer.h.

unsigned long alize::MixtureServer::_lastMixtureId [private]

Definition at line 488 of file MixtureServer.h.

Definition at line 487 of file MixtureServer.h.

Definition at line 485 of file MixtureServer.h.

unsigned long alize::MixtureServer::_vectSize [mutable, private]

Definition at line 489 of file MixtureServer.h.

bool alize::MixtureServer::_vectSizeDefined [mutable, private]

Definition at line 490 of file MixtureServer.h.


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