[KLF Backend][KLF Tools][KLF Home]
KLatexFormula Project
Public Member Functions
KLFFactoryManager Class Reference

A base abstract factory manager class. More...

#include <klffactory.h>

List of all members.

Public Member Functions

 KLFFactoryManager ()
virtual ~KLFFactoryManager ()
KLFFactoryBasefindFactoryFor (const QString &objType)
QStringList allSupportedTypes ()
QList< KLFFactoryBase * > registeredFactories ()

Detailed Description

A base abstract factory manager class.

An abstract class that provides base common functions for factories of different kinds.

A Factory is a class that can instantiate another class of given types. For example, you may have a factory that can create objects of the correct sub-class of KLFLibResourceEngine depending on the URL to open. Multiple factories can be installed, each capable of opening one or more subtypes of the given object, a library resource in our example.

Factories need to be explicitely registered and unregistered, they are done so in the KLFFactoryBase constructor and destructor.

Example usage of KLFFactoryManager and KLFFactoryBase. Note that MyFactory is a base class which can be derived to actually implement your factories.

  // in .h:
  class MyFactory : public KLFFactoryBase {
  public:
    MyFactory() : KLFFactoryBase(&pFactoryManager) { }

    virtual QStringList supportedTypes() const = 0;

    virtual MyObject * createMyObject(const QString& ofThisObjectType, ...params...) = 0;

    ...

    static MyFactory * findFactoryFor(...) {
      return dynamic_cast<MyFactory*>(pFactoryManager.findFactoryFor(...));
    }

  private:
    static KLFFactoryManager pFactoryManager;
  };

  // in .cpp:
  KLFFactoryManager MyFactory::pFactoryManager ;

Definition at line 91 of file klffactory.h.


Constructor & Destructor Documentation

Constructor. does nothing

Definition at line 45 of file klffactory.cpp.

Destructor. This function unregisters the factory.

Definition at line 48 of file klffactory.cpp.


Member Function Documentation

Returns a combined list of all object types all registered factories combined support. (ie. a list of all object types we're capable of instantiating)

Definition at line 67 of file klffactory.cpp.

References QList::size().

Referenced by KLFSideWidgetManagerFactory::allSupportedTypes().

Returns the first factory in registered factory list that is capable of creating an object of type objType.

Definition at line 52 of file klffactory.cpp.

References QStringList::contains(), QList::size(), and KLFFactoryBase::supportedTypes().

Referenced by KLFSideWidgetManagerFactory::findFactoryFor(), and KLFAbstractPropertizedObjectSaver::findSaverFor().

Returns a list of all registered factories.

Definition at line 107 of file klffactory.h.

Referenced by KLFAbstractPropertizedObjectSaver::findRecognizedFormat().


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

Generated by doxygen 1.7.6.1. The KLatexFormula website is hosted on sourceforge.net