ImagingTools Core SDK
CDeviceIdBasedAttributesComp.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 <iattr/CAttributesManager.h>
7#include <ilog/TLoggerCompWrap.h>
8#include <imod/TModelWrap.h>
9
10// ImtCore includes
11#include <imtbase/ISelection.h>
12#include <imtbase/TModelUpdateBinder.h>
13#include <imtdev/IDeviceController.h>
14
15
16namespace imtdev
17{
18
19
81class CDeviceIdBasedAttributesComp: public ilog::CLoggerComponentBase
82{
83public:
84 typedef ilog::CLoggerComponentBase BaseClass;
85
86 I_BEGIN_COMPONENT(CDeviceIdBasedAttributesComp)
87 I_REGISTER_INTERFACE(iattr::IAttributesManager);
88 I_REGISTER_SUBELEMENT(StaticAttributes)
89 I_REGISTER_SUBELEMENT_INTERFACE(StaticAttributes, iattr::IAttributesProvider, ExtractStaticAttributes);
90 I_REGISTER_SUBELEMENT_INTERFACE(StaticAttributes, imod::IModel, ExtractStaticAttributes);
91 I_REGISTER_SUBELEMENT_INTERFACE(StaticAttributes, istd::IChangeable, ExtractStaticAttributes);
92 I_REGISTER_SUBELEMENT(InstanceAttributes)
93 I_REGISTER_SUBELEMENT_INTERFACE(InstanceAttributes, iattr::IAttributesProvider, ExtractInstanceAttributes);
94 I_REGISTER_SUBELEMENT_INTERFACE(InstanceAttributes, imod::IModel, ExtractInstanceAttributes);
95 I_REGISTER_SUBELEMENT_INTERFACE(InstanceAttributes, istd::IChangeable, ExtractInstanceAttributes);
96 I_ASSIGN(m_selectionCompPtr, "DeviceSelection", "ID of the selected device", false, "DeviceSelection");
97 I_ASSIGN(m_controllerCompPtr, "DeviceController", "Device controller", false, "DeviceController");
98 I_ASSIGN(m_stateProviderCompPtr, "DeviceStateProvider", "Device state provider", false, "DeviceStateProvider");
99 I_END_COMPONENT;
100
102
103protected:
104 // reimplemented (icomp::CComponentBase)
105 void OnComponentCreated() override;
106 void OnComponentDestroyed() override;
107
108private:
109 DeviceInstancePtr GetDeviceInstance(const QByteArray& deviceId) const;
110 void UpdateModel();
111
112 void OnSelectionChanged(const istd::IChangeable::ChangeSet& changeSet, const imtbase::ISelection* objectPtr);
113 void OnDeviceStateChanged(const istd::IChangeable::ChangeSet& changeSet, const IDeviceStateProvider* objectPtr);
114 void OnInstanceAttributesChanged(const istd::IChangeable::ChangeSet& changeSet, const iattr::IAttributesProvider* objectPtr);
115
116 template<class Interface>
117 static Interface* ExtractStaticAttributes(CDeviceIdBasedAttributesComp& parent)
118 {
119 return dynamic_cast<Interface*>(&parent.m_staticAttributes);
120 }
121
122 template<class Interface>
123 static Interface* ExtractInstanceAttributes(CDeviceIdBasedAttributesComp& parent)
124 {
125 return dynamic_cast<Interface*>(&parent.m_instanceAttributes);
126 }
127
128private:
129 I_REF(imtbase::ISelection, m_selectionCompPtr);
130 I_REF(IDeviceController, m_controllerCompPtr);
131 I_REF(IDeviceStateProvider, m_stateProviderCompPtr);
132
133 imod::TModelWrap<iattr::CAttributesManager> m_staticAttributes;
134 imod::TModelWrap<iattr::CAttributesManager> m_instanceAttributes;
135
139
140 bool m_isConfigurationStoreBlocked = false;
141};
142
143
144} // namespace imtdev
145
146
Selection-based device attributes component.
Common interface for controlling devices.
Interface for tracking device connection states.