realfactory.h
71 virtual ParameterSettable* create(ConfigurationParameters& settings, QString prefix, bool configure) const = 0;
115 virtual ParameterSettableInConstructor* create(ConfigurationParameters& settings, QString prefix, bool configure) const;
161 virtual ParameterSettableWithConfigureFunction* create(ConfigurationParameters& settings, QString prefix, bool configure) const;
252 TypeToCreate* create(const QString& className, QString prefix, bool configure = true, bool* actuallyConfigured = NULL);
282 TypeToCreate* createFromParameter(QString prefix, bool configure = true, bool* actuallyConfigured = NULL);
412 ParameterSettableInConstructor* ParameterSettableCreatorT<T, ConfigureInConstructor>::create(ConfigurationParameters& settings, QString prefix, bool /*configure*/) const
416 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix is about
424 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix has been
434 ParameterSettableWithConfigureFunction* ParameterSettableCreatorT<T, false>::create(ConfigurationParameters& settings, QString prefix, bool configure) const
438 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix is about
446 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix has been
453 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix is about
461 // Telling the ConfigurationParameters object that the object for the group in terminatedPrefix has been
472 TypeToCreate* RealFactory::create(const QString& className, QString prefix, bool configure, bool* actuallyConfigured)
474 // This is a simple class to implement RAII for the m_createRecursionLevel variable, so that in case
479 RecursionLevelRAII(unsigned int& createRecursionLevel, QList<ParameterSettable*>& objectsConfiguredNotInitialized) :
483 // As this is the first call to create for the current m_settings, we remove the list of objects, if
500 RecursionLevelRAII(const RecursionLevelRAII& other) : m_createRecursionLevel(other.m_createRecursionLevel) {}
505 RecursionLevelRAII recursionLevelRAII(m_createRecursionLevel, m_objectsConfiguredNotInitialized);
527 std::auto_ptr<ParameterSettable> newObj(Factory::getInstance().m_classMap[className]->create(m_configurationParameters, prefix, configure));
542 // If we are outside any call to ConfigurationParameters::getObjectFromGroup() and this is the most external
543 // call to create (m_createRecursionLevel has been incremented from 0 to 1 by the constructor of RecursionLevelRAII),
544 // here we initialize all objects that have been configured. If the most external call to this function have been
545 // performed inside a call to ConfigurationParameters::getObjectFromGroup(), that function will do the job
546 // NOTE: this check should be useless now that create is protected and can only be called by ConfigurationParameters:
547 // calling postConfigureInitialization is always done inside ConfigurationParameters::getObjectFromGroup().
549 if (m_configurationParameters.outsideCallsToGetObjectFromGroup() && (m_createRecursionLevel == 1)) {
565 TypeToCreate* RealFactory::createFromParameter(QString prefix, bool configure, bool* actuallyConfigured)
567 QString type = m_configurationParameters.getValue(prefix + ConfigurationParameters::GroupSeparator() + QString("type"), false);
584 QStringList objectsGroups = m_configurationParameters.getGroupsWithPrefixList(prefix, basename);
588 objects.push_back(createFromParameter<TypeToCreate>(prefix + ConfigurationParameters::GroupSeparator() + *it));
595 QVector<TypeToCreate *> RealFactory::createVectorFromParameter(QString prefix, QString basename)
600 QStringList objectsGroups = m_configurationParameters.getGroupsWithPrefixList(prefix, basename);
601 // Order the data, so that the index respect the number specified after the colon in the groupname
606 objects.push_back(createFromParameter<TypeToCreate>(prefix + ConfigurationParameters::GroupSeparator() + *it));
This file contains the common type defitions used on the whole framework.
virtual bool canDeferConfiguration() const
Returns true if the object that is created can be configured after creation.
Definition: realfactory.h:123
The exception thrown when casting an ParameterSettable object to the requested type fails...
Definition: configurationexceptions.h:252
Definition: configurationhelper.cpp:24
The class containing configuration parameters.
Definition: configurationparameters.h:259
The base class for object creators. The implementation is in the template class below.
Definition: realfactory.h:45
QVector< TypeToCreate * > createVectorFromParameter(QString prefix, QString basename)
Creates a vector of objects reading the types from the parameters object.
Definition: realfactory.h:595
virtual bool canDeferConfiguration() const
Returns true if the object that is created can be configured after creation.
Definition: realfactory.h:169
virtual ParameterSettableInConstructor * create(ConfigurationParameters &settings, QString prefix, bool configure) const
Creates an instance and configures it.
Definition: realfactory.h:412
The base for classes that can be configured using a ConfigurationParameters object passed to the cons...
Definition: parametersettable.h:741
The exception thrown when requested class name is registered but cannot be created because it is abst...
Definition: configurationexceptions.h:150
The base for classes that can be configured/saved using a ConfigurationParameters object...
Definition: parametersettable.h:51
QList< TypeToCreate * > createListFromParameter(QString prefix, QString basename)
Creates a list of objects reading the types from the parameters object.
Definition: realfactory.h:579
virtual void onObjectCreation(ConfigurationParameters *confParams, ParameterSettable *object, QString path, bool configured)=0
called when an object has been created
The class implementing the create function of the class above.
Definition: realfactory.h:93
The exception thrown when requested class name is not registered with the factory.
Definition: configurationexceptions.h:48
FactoryObserver class to keep trace on operations done by Factory.
Definition: factoryobserver.h:36
QString getValue(QString path, bool alsoMatchParents=false) const
Returns a parameter value.
Definition: configurationparameters.cpp:219
The base for classes that can be configured using a ConfigurationParameters object.
Definition: parametersettable.h:789
QStringList getGroupsWithPrefixList(QString group, QString prefix) const
Returns the list of sub-groups in the given group whose name starts with the provided string...
Definition: configurationparameters.cpp:134
void callPostConfigureInitializationForConfiguredObjects()
Calls postConfigureInitialization on all objects for the given ConfigurationParameters object...
Definition: realfactory.cpp:69
The exception thrown when trying to create an object from a using a prefi that is not a group...
Definition: configurationexceptions.h:481
TypeToCreate * createFromParameter(QString prefix, bool configure=true, bool *actuallyConfigured=NULL)
Creates an object reading the type from the parameters object.
Definition: realfactory.h:565
The exception thrown when requested to create an object from a group and the "type" parameter is not ...
Definition: configurationexceptions.h:379
static QString GroupSeparator()
The character used to split path in groups.
Definition: configurationparameters.h:268
TypeToCreate * create(const QString &className, QString prefix, bool configure=true, bool *actuallyConfigured=NULL)
Creates an object.
Definition: realfactory.h:472