RealFactory Class Reference

Factory class to create ParameterSettable objects. More...

Public Member Functions

 RealFactory (ConfigurationParameters &configurationParameters)
 Constructor.
 
 ~RealFactory ()
 Destructor.
 
void addObserver (FactoryObserver *observer)
 Adds a new observer.
 
void addObservers (const QSet< FactoryObserver * > &observers)
 Adds a set of observers.
 
void callPostConfigureInitializationForConfiguredObjects ()
 Calls postConfigureInitialization on all objects for the given ConfigurationParameters object.
 
void clearObservers ()
 Removes all observers.
 
template<class TypeToCreate >
TypeToCreate * create (const QString &className, QString prefix, bool configure=true, bool *actuallyConfigured=NULL)
 Creates an object.
 
template<class TypeToCreate >
TypeToCreate * createFromParameter (QString prefix, bool configure=true, bool *actuallyConfigured=NULL)
 Creates an object reading the type from the parameters object.
 
template<class TypeToCreate >
QList< TypeToCreate * > createListFromParameter (QString prefix, QString basename)
 Creates a list of objects reading the types from the parameters object.
 
template<class TypeToCreate >
QVector< TypeToCreate * > createVectorFromParameter (QString prefix, QString basename)
 Creates a vector of objects reading the types from the parameters object.
 
const QSet< FactoryObserver * > & getObservers () const
 Returns the set of observers.
 
void objectConfigured (ParameterSettable *object)
 Adds object to the list of objects created and configured but not initialized.
 
bool outsideCallsToCreate () const
 Returns true if we are outside any call to create.
 

Detailed Description

Factory class to create ParameterSettable objects.

This creates instances of ParameterSettable subclasses. You should never refer to this class directly, it is used internally by ConfigurationParameters objects to manage object creation. Refer to the documentation of the ConfigurationParameters class for information on how to create objects.

Definition at line 186 of file realfactory.h.

Constructor & Destructor Documentation

RealFactory ( ConfigurationParameters configurationParameters)

Constructor.

Definition at line 26 of file realfactory.cpp.

Destructor.

Definition at line 34 of file realfactory.cpp.

Member Function Documentation

void addObserver ( FactoryObserver observer)

Adds a new observer.

Parameters
observeris the object acting as FactoryObserver

Definition at line 39 of file realfactory.cpp.

void addObservers ( const QSet< FactoryObserver * > &  observers)

Adds a set of observers.

Parameters
observersis the set of objects acting as FactoryObserver

Definition at line 44 of file realfactory.cpp.

void callPostConfigureInitializationForConfiguredObjects ( )

Calls postConfigureInitialization on all objects for the given ConfigurationParameters object.

Note: this doesn't clear the list.

Definition at line 69 of file realfactory.cpp.

Referenced by RealFactory::create().

void clearObservers ( )

Removes all observers.

Definition at line 54 of file realfactory.cpp.

TypeToCreate * create ( const QString &  className,
QString  prefix,
bool  configure = true,
bool *  actuallyConfigured = NULL 
)

Creates an object.

The TypeToCreate template parameter is the base type for the object to create

Parameters
classNamethe name of the type to create
prefixthe prefix for configuration parameters (i.e. the group containing parameters). When calling configure for the new object, prefix is appended with the separator
configureif true the object is created and configured, otherwise, if possible, only object creation occurs ("if possible" means that if a non-configured object was requested but the object can only be created and configured at the same time, the object is actually configured). When an object is configured (either because it was requested so or because it was only possible to create and configure it), also the postConfigureInitialization() function is called on it just before returning from the most external call to this function. If the object is not configured, the caller is responsible of configuring it and then calling postConfigureInitialization().
actuallyConfiguredif not NULL, the pointed variable is set to true if the object was actually configured, to false otherwise
Returns
the new object

Definition at line 472 of file realfactory.h.

References RealFactory::callPostConfigureInitializationForConfiguredObjects(), Factory::getInstance(), and FactoryObserver::onObjectCreation().

TypeToCreate * createFromParameter ( QString  prefix,
bool  configure = true,
bool *  actuallyConfigured = NULL 
)

Creates an object reading the type from the parameters object.

The TypeToCreate template parameter is the base type for the object to create. This function needs a "type" property under prefix from which to read the type to create

Parameters
prefixthe prefix for configuration parameters (i.e. the group containing parameters). When calling configure for the new object, prefix is appended with the separator
configureif true the object is created and configured, otherwise, if possible, only object creation occurs ("if possible" means that if a non-configured object was requested but the object can only be created and configured at the same time, the object is actually configured). When an object is configured (either because it was requested so or because it was only possible to create and configure it), also the postConfigureInitialization() function is called on it just before returning from the most external call to this function. If the object is not configured, the caller is responsible of configuring it and then calling postConfigureInitialization().
actuallyConfiguredif not NULL, the pointed variable is set to true if the object was actually configured, to false otherwise
Returns
the new object

Definition at line 558 of file realfactory.h.

References ConfigurationParameters::getValue(), and ConfigurationParameters::GroupSeparator().

QList< TypeToCreate * > createListFromParameter ( QString  prefix,
QString  basename 
)

Creates a list of objects reading the types from the parameters object.

The TypeToCreate template parameter is the base type for objects to create. This function needs a "type" property under groups from which to read the type to create

Parameters
prefixthe prefix for configuration parameters (i.e. the group containing the groups for objects to create). When calling configure for the new object, prefix is appended with the separator
basenamethe initial part of the name of groups under prefix corresponding to objects to create
Returns
a list of objects. All objects are created and configured

Definition at line 572 of file realfactory.h.

References ConfigurationParameters::getGroupsWithPrefixList(), and ConfigurationParameters::GroupSeparator().

QVector< TypeToCreate * > createVectorFromParameter ( QString  prefix,
QString  basename 
)

Creates a vector of objects reading the types from the parameters object.

The TypeToCreate template parameter is the base type for objects to create. This function needs a "type" property under groups from which to read the type to create

Parameters
prefixthe prefix for configuration parameters (i.e. the group containing the groups for objects to create). When calling configure for the new object, prefix is appended with the separator
basenamethe initial part of the name of groups under prefix corresponding to objects to create
Returns
a vector of objects. All objects are created and configured

Definition at line 588 of file realfactory.h.

References ConfigurationParameters::getGroupsWithPrefixList(), and ConfigurationParameters::GroupSeparator().

const QSet< FactoryObserver * > & getObservers ( ) const

Returns the set of observers.

Returns
the set of observers

Definition at line 49 of file realfactory.cpp.

void objectConfigured ( ParameterSettable object)

Adds object to the list of objects created and configured but not initialized.

This is called by ConfigurationParameters when it configures an object that has previously been only created, so that it can be initialized at the end of the most external call to create()

Parameters
objectthe object which has been configured

Definition at line 59 of file realfactory.cpp.

bool outsideCallsToCreate ( ) const

Returns true if we are outside any call to create.

This is mostly used by ConfigurationParameters to check whether it has to do the call to postConfigureInitialization() or we have to

Returns
true if we are outside any call to create

Definition at line 64 of file realfactory.cpp.


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