[KLF Application][KLF Tools][KLF Backend][KLF Home]
KLatexFormula Project
Public Types | Public Member Functions | Static Public Member Functions

KLFLibEngineFactory Class Reference

#include <klflib.h>

Inheritance diagram for KLFLibEngineFactory:
Inheritance graph
[legend]
Collaboration diagram for KLFLibEngineFactory:
Collaboration graph
[legend]

List of all members.

Public Types

enum  SchemeFunctions { FuncOpen = 0x01, FuncCreate = 0x02, FuncSaveTo = 0x04 }
typedef QMap< QString, QVariantParameters

Public Member Functions

 KLFLibEngineFactory (QObject *parent=NULL)
virtual ~KLFLibEngineFactory ()
virtual QStringList supportedTypes () const =0
 A list of supported URL schemes this factory can open.
virtual uint schemeFunctions (const QString &scheme) const
 What this factory is capable of doing.
virtual QString schemeTitle (const QString &scheme) const =0
virtual QString correspondingWidgetType (const QString &scheme) const =0
virtual KLFLibResourceEngineopenResource (const QUrl &location, QObject *parent=NULL)=0
virtual KLFLibResourceEnginecreateResource (const QString &scheme, const Parameters &parameters, QObject *parent=NULL)
 Create a new resource of given type and parameters.
virtual bool saveResourceTo (KLFLibResourceEngine *resource, const QUrl &newLocation)
 Save the given resource to a new location.

Static Public Member Functions

static KLFLibEngineFactoryfindFactoryFor (const QUrl &url)
static KLFLibEngineFactoryfindFactoryFor (const QString &urlScheme)
static QStringList allSupportedSchemes ()
static KLFLibResourceEngineopenURL (const QUrl &location, QObject *parent=NULL)
static QStringList listSubResources (const QUrl &url)
static QMap< QString, QStringlistSubResourcesWithTitles (const QUrl &url)

Detailed Description

An abstract factory class for opening resources identified by their URL, and creating objects of the currect subclass of KLFLibResourceEngine.

See also KLFLibResourceEngine, KLFLibDBEngine, KLFLibLegacyEngine. More about factory common functions in KLFFactoryManager documentation.

Definition at line 1685 of file klflib.h.


Member Typedef Documentation

A generalized way of passing arbitrary parameters for creating new resources or saving resources to new locations.

Definition at line 1693 of file klflib.h.


Member Enumeration Documentation

Enumerator:
FuncOpen 

Open Resources.

FuncCreate 

Create New Resources.

FuncSaveTo 

Save Resources to new locations.

Definition at line 1695 of file klflib.h.


Constructor & Destructor Documentation

KLFLibEngineFactory::KLFLibEngineFactory ( QObject parent = NULL)

Constructs an engine factory and automatically regisers it.

Definition at line 1137 of file klflib.cpp.

KLFLibEngineFactory::~KLFLibEngineFactory ( ) [virtual]

Destroys this engine factory and unregisters it.

Definition at line 1141 of file klflib.cpp.


Member Function Documentation

QStringList KLFLibEngineFactory::allSupportedSchemes ( ) [static]

Returns a concatenated list of all schemes that all registered factories support

Definition at line 1160 of file klflib.cpp.

References KLFFactoryManager::allSupportedTypes().

virtual QString KLFLibEngineFactory::correspondingWidgetType ( const QString scheme) const [pure virtual]

Returns the widget type that should be used to present to user to "open" or "create" or "save" a resource of the given scheme.

For example, both "klf+sqlite" and "klf+legacy" schemes could return a "LocalFile" widget that prompts to open/create/save-as a file.

Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.

Referenced by KLFLibOpenResourceDlg::KLFLibOpenResourceDlg().

KLFLibResourceEngine * KLFLibEngineFactory::createResource ( const QString scheme,
const Parameters parameters,
QObject parent = NULL 
) [virtual]

Create a new resource of given type and parameters.

Create the new resource, with the given settings. This function opens the resource and returns the KLFLibResourceEngine object, which is instantiated as child of parent.

The parameters' structure are defined for each widget type. That is, if the correspondingWidgetType() for a given scheme is eg. "LocalFile", then the parameters are defined by whatever the "LocalFile" widget sets. For example "LocalFile" documents its parameters in KLFLibBasicWidgetFactory::retrieveCreateParametersFromWidget(), eg. parameter "Filename" contains a QString with the entered local file name.

Additional parameters may also be set by KLFLibCreateResourceDlg itself (eg. default sub-resource name/title, .........TODO............)

The default implementation of this function does nothing and returns NULL. To enable creating resources, reimplement schemeFunctions() to return also FuncCreate and reimplement this function.

Reimplemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.

Definition at line 1165 of file klflib.cpp.

Referenced by KLFLibCreateResourceDlg::createResource(), KLFMainWin::loadLibrary(), KLFLibExportDialog::showExportDialogCreateResource(), and KLFLibBrowser::slotExportSelection().

KLFLibEngineFactory * KLFLibEngineFactory::findFactoryFor ( const QString urlScheme) [static]

Finds the last registered factory that should be able to open URLs with scheme urlScheme and returns a pointer to that factory.

Definition at line 1155 of file klflib.cpp.

References KLFFactoryManager::findFactoryFor().

KLFLibEngineFactory * KLFLibEngineFactory::findFactoryFor ( const QUrl url) [static]

Finds the last registered factory that should be able to open URL url (determined by the URL's scheme) and returns a pointer to that factory.

This function is provided for convenience; it is equivalent to

 findFactoryFor(url.scheme()) 

Definition at line 1150 of file klflib.cpp.

References QUrl::scheme().

Referenced by KLFLibCreateResourceDlg::createResource(), KLFLibOpenResourceDlg::KLFLibOpenResourceDlg(), KLFMainWin::loadLibrary(), KLFLibBrowser::openResource(), openURL(), KLFLibExportDialog::showExportDialogCreateResource(), and KLFLibBrowser::slotExportSelection().

QStringList KLFLibEngineFactory::listSubResources ( const QUrl url) [static]

Opens resource designated by url, and then lists the subresources. An empty list is returned if the resource cannot be opened, or if the resource does not support sub-resources.

The resource is immedately closed after reading the list of sub-resources.

This function:

Definition at line 1218 of file klflib.cpp.

References listSubResourcesWithTitles().

Referenced by KLFMainWin::openLibFile(), and KLFLibBrowser::slotOpenAll().

QMap< QString, QString > KLFLibEngineFactory::listSubResourcesWithTitles ( const QUrl url) [static]

Opens resource designated by url, and then lists the subresources with as key the resource name and as value the sub-resource title (if sub-resource properties are supported, or an empty string if not). An empty map is returned if the resource cannot be opened, or if the resource does not support sub-resources.

This function works in a very similar way to listSubResources().

The resource is immedately closed after reading the list of sub-resources.

Definition at line 1189 of file klflib.cpp.

References QUrl::addQueryItem(), KLFLibResourceEngine::FeatureSubResourceProps, KLFLibResourceEngine::FeatureSubResources, openURL(), KLFLibResourceEngine::subResourceList(), KLFLibResourceEngine::subResourceProperty(), KLFLibResourceEngine::SubResPropTitle, KLFLibResourceEngine::supportedFeatureFlags(), and QVariant::toString().

Referenced by listSubResources(), and KLFLibOpenResourceDlg::updateReadyToOpen().

virtual KLFLibResourceEngine* KLFLibEngineFactory::openResource ( const QUrl location,
QObject parent = NULL 
) [pure virtual]

Instantiate a library engine that opens resource stored at location. The resource engine should be constructed as a child of object parent.

Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.

Referenced by KLFMainWin::loadLibrary(), KLFLibBrowser::openResource(), and openURL().

KLFLibResourceEngine * KLFLibEngineFactory::openURL ( const QUrl location,
QObject parent = NULL 
) [static]

Finds the good factory for URL location, and opens the resource using that factory. The created resource will be a child of parent.

Definition at line 1178 of file klflib.cpp.

References findFactoryFor(), openResource(), and QUrl::scheme().

Referenced by listSubResourcesWithTitles(), and KLFMainWin::loadLibrary().

bool KLFLibEngineFactory::saveResourceTo ( KLFLibResourceEngine resource,
const QUrl newLocation 
) [virtual]

Save the given resource to a new location.

Save the resource resource to the new location given by newLocation.

The caller should garantee that resource is a resource engine of a scheme supported by this factory.

Note:
The resource a the new location is not opened. resource will still continue pointing to the previous location.

For example, an "klf+sqlite" Sqlite database may choose to simply copy the database file to the new location. This example is implemented in KLFLibDBEngine::saveTo().

Returns:
TRUE for success or FALSE for failure.

The default implementation of this function does nothing and returns false. To enable creating resources, reimplement schemeFunctions() to return also FuncCreate and reimplement this function.

Definition at line 1172 of file klflib.cpp.

uint KLFLibEngineFactory::schemeFunctions ( const QString scheme) const [virtual]

What this factory is capable of doing.

Informs the caller of what functionality this factory provides for the given scheme.

The FuncOpen must be provided in every factory.

Returns:
a bitwise-OR of flags defined in the SchemeFunctions enum.

The default implementation returns FuncOpen.

Reimplemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.

Definition at line 1145 of file klflib.cpp.

References FuncOpen.

virtual QString KLFLibEngineFactory::schemeTitle ( const QString scheme) const [pure virtual]

Should return a human (short) description of the given scheme (which is one returned by supportedTypes())

Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.

Referenced by KLFLibBrowser::slotExportSelection().

virtual QStringList KLFLibEngineFactory::supportedTypes ( ) const [pure virtual]

A list of supported URL schemes this factory can open.

If two factories provide a common scheme name, only the last instantiated is used; the consequent ones will be ignored for that scheme name. See KLFFactoryBase::supportedTypes() and KLFFactoryManager::findFactoryFor()

Implements KLFFactoryBase.

Implemented in KLFLibDBEngineFactory, and KLFLibLegacyEngineFactory.


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

Generated by doxygen 1.7.3