ImagingTools Core SDK
ICollectionObjectLink.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 <istd/TDelPtr.h>
7#include <iser/IObject.h>
8
9// ImtCore includes
10#include <imtbase/IIdentifiable.h>
11#include <imtbase/IObjectCollection.h>
12
13
14namespace imtbase
15{
16
17
18class ICollectionObjectLink: virtual public IIdentifiable, virtual public iser::IObject
19{
20public:
24 virtual const imtbase::IObjectCollection* GetCollection() const = 0;
25
26 template <class Object>
27 inline bool GetLinkedObject(istd::TSharedInterfacePtr<Object>& dataObject) const
28 {
29 imtbase::IObjectCollection::DataPtr dataPtr;
30 if (GetLinkedObject(dataPtr)){
31 dataObject.MoveCastedPtr(dataPtr->CloneMe());
32
33 return dataObject.IsValid();
34 }
35
36 return false;
37 }
38
39 inline bool GetLinkedObject(imtbase::IObjectCollection::DataPtr& dataObject) const
40 {
41 const imtbase::IObjectCollection* collectionPtr = GetCollection();
42 if (collectionPtr != nullptr){
43 QByteArray objectId = GetObjectUuid();
44 if (!objectId.isEmpty()){
45 return collectionPtr->GetObjectData(objectId, dataObject);
46 }
47 }
48
49 return false;
50 }
51};
52
53
54} // namespace imtbase
55
56
virtual QByteArray GetObjectUuid() const =0
virtual bool GetObjectData(const Id &objectId, DataPtr &dataPtr, const iprm::IParamsSet *dataConfigurationPtr=nullptr) const =0