2014-09-10 17:27:45 +02:00
|
|
|
/************************************************************************
|
|
|
|
**
|
|
|
|
** @file vpropertyfactorymanager.h
|
|
|
|
** @author hedgeware <internal(at)hedgeware.net>
|
|
|
|
** @date
|
|
|
|
**
|
|
|
|
** @brief
|
|
|
|
** @copyright
|
|
|
|
** All rights reserved. This program and the accompanying materials
|
|
|
|
** are made available under the terms of the GNU Lesser General Public License
|
|
|
|
** (LGPL) version 2.1 which accompanies this distribution, and is available at
|
|
|
|
** http://www.gnu.org/licenses/lgpl-2.1.html
|
|
|
|
**
|
|
|
|
** This library is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
** Lesser General Public License for more details.
|
|
|
|
**
|
|
|
|
*************************************************************************/
|
|
|
|
|
|
|
|
#ifndef VPROPERTYFACTORYMANAGER_H
|
|
|
|
#define VPROPERTYFACTORYMANAGER_H
|
|
|
|
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <qcompilerdetection.h>
|
|
|
|
#include <QMetaObject>
|
2014-09-10 17:27:45 +02:00
|
|
|
#include <QObject>
|
2016-08-08 13:44:49 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
#include "vpropertyexplorer_global.h"
|
|
|
|
|
2014-09-10 19:57:08 +02:00
|
|
|
namespace VPE
|
|
|
|
{
|
2014-09-10 17:27:45 +02:00
|
|
|
|
|
|
|
class VAbstractPropertyFactory;
|
|
|
|
class VProperty;
|
2016-08-08 13:44:49 +02:00
|
|
|
class VPropertyFactoryManagerPrivate;
|
2014-09-10 17:27:45 +02:00
|
|
|
|
|
|
|
class VPROPERTYEXPLORERSHARED_EXPORT VPropertyFactoryManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
//! Constructor
|
2015-10-12 13:52:48 +02:00
|
|
|
explicit VPropertyFactoryManager(QObject* parent = nullptr);
|
2014-09-10 17:27:45 +02:00
|
|
|
|
|
|
|
//! Destructor
|
2018-06-26 14:53:48 +02:00
|
|
|
virtual ~VPropertyFactoryManager() override;
|
2014-09-10 17:27:45 +02:00
|
|
|
|
|
|
|
//! Register a factory to the factory manager
|
|
|
|
//! Note that the manager takes ownership of the factory, so don't delete it.
|
|
|
|
//! You can unregister a factory using unregisterFactory()
|
|
|
|
void registerFactory(const QString& type, VAbstractPropertyFactory* factory);
|
|
|
|
|
|
|
|
//! Removes a factory from the manager.
|
|
|
|
//! \param factory The factory to unregister
|
2014-09-10 19:57:08 +02:00
|
|
|
//! \param type The type from which to remove the factory. If this is empty, all the types the factory is registered
|
|
|
|
//! for are being removed
|
|
|
|
//! \param delete_if_unused Determines whether the factory should be deleted, if it not used anymore by this
|
|
|
|
//! manager. Default: true. Otherwise, if the factory is unused by this manager, ownership is being passed on.
|
2014-09-10 17:27:45 +02:00
|
|
|
void unregisterFactory(VAbstractPropertyFactory* factory, const QString& type = QString(),
|
|
|
|
bool delete_if_unused = true);
|
|
|
|
|
|
|
|
//! Returns whether a factory is registered (and thus owned) by this factory manager
|
|
|
|
bool isRegistered(VAbstractPropertyFactory* factory);
|
|
|
|
|
|
|
|
//! Returns a pointer to a factory registered for a certain type
|
|
|
|
//! \param type The type to return the factory for
|
|
|
|
//! \return Returns NULL, if there is none registered for this type
|
|
|
|
VAbstractPropertyFactory* getFactory(const QString& type);
|
|
|
|
|
|
|
|
//! Creates a new property of a certain type and assigns a name and description (otionally)
|
|
|
|
//! \param type The type of the property as string
|
|
|
|
//! \param name The name of the property
|
|
|
|
//! \param description The property's description. Optional.
|
|
|
|
//! \param default_value The properties initial value as string. Optional.
|
|
|
|
//! \return Returns the created property or NULL if it couldn't be be created
|
|
|
|
VProperty* createProperty(const QString& type, const QString& name, const QString& description = QString(),
|
|
|
|
const QString& default_value = QString());
|
|
|
|
|
|
|
|
//! Returns the default manager.
|
2016-12-21 21:40:01 +01:00
|
|
|
//static VPropertyFactoryManager* getDefaultManager();
|
2014-09-10 17:27:45 +02:00
|
|
|
|
|
|
|
//! Returns a list of all supported property types
|
|
|
|
QStringList getSupportedTypes();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
VPropertyFactoryManagerPrivate* d_ptr;
|
|
|
|
|
|
|
|
//! The default manager
|
|
|
|
static VPropertyFactoryManager* DefaultManager;
|
2014-09-20 18:05:21 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(VPropertyFactoryManager)
|
2014-09-10 17:27:45 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // VPROPERTYFACTORYMANAGER_H
|