26 #include <QStringList>
45 while (!tmpFactories.isEmpty())
48 tmpFactories.removeAll(tmpFactory);
54 if (
this == DefaultManager)
56 DefaultManager =
nullptr;
68 unregisterFactory(getFactory(type), type,
true);
70 d_ptr->Factories[type] = factory;
74 bool delete_if_unused)
87 tmpKey = d_ptr->Factories.key(factory, QString());
88 if (!tmpKey.isEmpty())
90 d_ptr->Factories.remove(tmpKey);
92 }
while(!tmpKey.isEmpty());
97 if (d_ptr->Factories.value(type,
nullptr) == factory)
99 d_ptr->Factories.remove(type);
103 if (delete_if_unused && !isRegistered(factory))
111 return (!d_ptr->Factories.key(factory, QString()).isEmpty());
116 return d_ptr->Factories.value(type,
nullptr);
121 const QString& description,
const QString &default_value)
133 if (!default_value.isEmpty())
158 return d_ptr->Factories.keys();
virtual VProperty * createProperty(const QString &type, const QString &name)=0
Creates a new property of a certain type and assigns a name and description (otionally)
static VPropertyFactoryManager * DefaultManager
The default manager.
virtual ~VPropertyFactoryManager() Q_DECL_OVERRIDE
Destructor.
void unregisterFactory(VAbstractPropertyFactory *factory, const QString &type=QString(), bool delete_if_unused=true)
Removes a factory from the manager.
bool isRegistered(VAbstractPropertyFactory *factory)
Returns whether a factory is registered (and thus owned) by this factory manager.
void registerFactory(const QString &type, VAbstractPropertyFactory *factory)
Register a factory to the factory manager Note that the manager takes ownership of the factory,...
VPropertyFactoryManager(QObject *parent=nullptr)
Constructor.
QStringList getSupportedTypes()
Returns the default manager.
VProperty * createProperty(const QString &type, const QString &name, const QString &description=QString(), const QString &default_value=QString())
Creates a new property of a certain type and assigns a name and description (otionally)
VAbstractPropertyFactory * getFactory(const QString &type)
Returns a pointer to a factory registered for a certain type.
virtual void setDescription(const QString &desc)
Sets the name of the property.
virtual void deserialize(const QString &value)
Deserializes the value from a string.