ImagingTools Core SDK
CObjectCollectionComp.h
1// SPDX-License-Identifier: LGPL-2.1-or-later OR GPL-2.0-or-later OR GPL-3.0-or-later OR LicenseRef-ImtCore-Commercial
2#pragma once
3
4
5// ACF includes
6#include <icomp/CComponentBase.h>
7#include <iprm/COptionsManager.h>
8
9// ImtCore includes
10#include <imtbase/CObjectCollection.h>
11#include <imtbase/TFilterableCollectionWrap.h>
12
13
14namespace imtbase
15{
16
17
24 public icomp::CComponentBase,
25 public imtbase::TFilterableCollectionWrap<CObjectCollectionBase>,
26 virtual public IObjectCollection::IDataFactory
27{
28public:
29 typedef icomp::CComponentBase BaseClass;
30 typedef imtbase::TFilterableCollectionWrap <CObjectCollectionBase> BaseClass2;
31
32 I_BEGIN_COMPONENT(CObjectCollectionComp);
33 I_REGISTER_INTERFACE(IObjectCollection);
34 I_REGISTER_INTERFACE(IObjectCollectionInfo);
35 I_REGISTER_INTERFACE(ICollectionInfo);
36 I_REGISTER_INTERFACE(iser::ISerializable);
37 I_REGISTER_INTERFACE(IObjectCollection::IDataFactory);
38 I_ASSIGN_MULTI_0(m_objectFactoriesCompPtr, "ObjectFactories", "List of factories used for object creation", false);
39 I_ASSIGN_MULTI_0(m_objectPersistenceListCompPtr, "ObjectPersistenceList", "List of persistence components used for object data persistence", false);
40 I_ASSIGN_MULTI_0(m_typeIdsAttrPtr, "TypeIds", "List of type-ID corresponding to the registered factories", false);
41 I_ASSIGN_MULTI_0(m_typeNamesAttrPtr, "TypeNames", "List of type names corresponding to the registered factories", false);
42 I_ASSIGN_MULTI_0(m_fixedObjectsCompPtr, "FixedObjects", "List of static defined objects", false);
43 I_ASSIGN_MULTI_0(m_fixedObjectIdsAttrPtr, "FixedObjectIds", "List of IDs for corresponding fixed object", false);
44 I_ASSIGN_MULTI_0(m_fixedObjectTypeIdsAttrPtr, "FixedObjectTypeIds", "List of type-IDs for corresponding fixed object", false);
45 I_ASSIGN_MULTI_0(m_fixedObjectNamesAttrPtr, "FixedObjectNames", "List of names for corresponding fixed object", false);
46 I_ASSIGN_MULTI_0(m_fixedObjectTypeNamesAttrPtr, "FixedObjectTypeNames", "List of names for corresponding fixed object type", false);
47 I_ASSIGN_MULTI_0(m_externalTypeIdsAttrPtr, "ExternaObjectTypeIds", "List of IDs for object types should be stored in the external storage", false);
48 I_ASSIGN(m_externalStorageCompPtr, "ExternalStorage", "External storage used to persist objects of types specified in 'ExternaObjectTypeIds'", false, "ExternalStorage");
49 I_END_COMPONENT;
50
51 // reimplemented (IObjectCollection::IDataFactory)
52 virtual istd::IChangeableUniquePtr CreateInstance(const QByteArray& keyId = "") const override;
53 virtual istd::IFactoryInfo::KeyList GetFactoryKeys() const override;
54
55 // reimplemented (IObjectCollectionInfo)
56 virtual const iprm::IOptionsList* GetObjectTypesInfo() const override;
57
58 // reimplemented (ICollectionDataController)
59 virtual const ifile::IFilePersistence* GetPersistenceForObjectType(const QByteArray& typeId) const override;
60
61 // reimplemented (istd::IChangeable)
62 virtual bool ResetData(CompatibilityMode mode = CM_WITHOUT_REFS) override;
63
64protected:
65 // reimplemented (CObjectCollectionBase)
66 virtual istd::IChangeableUniquePtr CreateObjectInstance(const QByteArray& typeId) const override;
67 virtual IObjectCollection* GetObjectStorage(const QByteArray& typeId, const istd::IChangeable* objectPtr) const override;
68
69 // reimplemented (icomp::CComponentBase)
70 virtual void OnComponentCreated() override;
71 virtual void OnComponentDestroyed() override;
72
73private:
74 I_MULTIFACT(istd::IChangeable, m_objectFactoriesCompPtr);
75 I_MULTIATTR(QByteArray, m_typeIdsAttrPtr);
76 I_MULTITEXTATTR(m_typeNamesAttrPtr);
77 I_MULTIREF(istd::IChangeable, m_fixedObjectsCompPtr);
78 I_MULTIATTR(QByteArray, m_fixedObjectIdsAttrPtr);
79 I_MULTIATTR(QByteArray, m_fixedObjectTypeIdsAttrPtr);
80 I_MULTITEXTATTR(m_fixedObjectNamesAttrPtr);
81 I_MULTITEXTATTR(m_fixedObjectTypeNamesAttrPtr);
82 I_MULTIREF(ifile::IFilePersistence, m_objectPersistenceListCompPtr);
83 I_MULTIATTR(QByteArray, m_externalTypeIdsAttrPtr);
84 I_REF(imtbase::IObjectCollection, m_externalStorageCompPtr);
85
86 iprm::COptionsManager m_typesInfo;
87};
88
89
90} // namespace imtbase
91
92