ImagingTools Core SDK
CDeviceIdBasedConfigurationComp.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 <ilog/TLoggerCompWrap.h>
7#include <iprm/CParamsSet.h>
8
9// ImtCore includes
10#include <imtbase/ISelection.h>
11#include <imtbase/TModelUpdateBinder.h>
12#include <imtdev/IDeviceConfigurationManager.h>
13#include <imtdev/IDeviceController.h>
14
15
16namespace imtdev
17{
18
19
90 public ilog::CLoggerComponentBase,
91 public iprm::CParamsSet
92{
93public:
94 typedef ilog::CLoggerComponentBase BaseClass;
95
96 I_BEGIN_COMPONENT(CDeviceIdBasedConfigurationComp)
97 I_REGISTER_INTERFACE(iprm::IParamsSet);
98 I_ASSIGN(m_deviceSelectionCompPtr, "DeviceSelection", "ID of the selected device", false, "DeviceSelection");
99 I_ASSIGN(m_controllerCompPtr, "DeviceController", "Device controller", false, "DeviceController");
100 I_ASSIGN(m_configurationManagerCompPtr, "DeviceConfigurationManager", "Configuration manager of the devices", false, "DeviceConfigurationManager");
101 I_ASSIGN(m_stateProviderCompPtr, "DeviceStateProvider", "Device state provider", false, "DeviceStateProvider");
102 I_END_COMPONENT;
103
105
106protected:
107 // reimplemented (icomp::CComponentBase)
108 void OnComponentCreated() override;
109 void OnComponentDestroyed() override;
110
111private:
112 DeviceInstancePtr GetDeviceInstance(const QByteArray& deviceId) const;
113 void UpdateModel();
114
115 void OnSelectionChanged(const istd::IChangeable::ChangeSet& changeSet, const imtbase::ISelection* objectPtr);
116 void OnConfigurationChanged(const istd::IChangeable::ChangeSet& changeSet, const iprm::IParamsSet* objectPtr);
117 void OnDeviceStateChanged(const istd::IChangeable::ChangeSet& changeSet, const IDeviceStateProvider* objectPtr);
118
119private:
120 class FlagLocker
121 {
122 public:
123 FlagLocker()
124 :m_flagPtr(nullptr),
125 m_controlAllowed(false)
126 {
127 };
128
129 FlagLocker(bool &flag)
130 :m_flagPtr(&flag)
131 {
132 m_controlAllowed = !flag;
133
134 flag = true;
135 }
136
137 ~FlagLocker()
138 {
139 if (m_controlAllowed){
140 *m_flagPtr = false;
141 }
142 }
143
144 private:
145 bool* m_flagPtr;
146 bool m_controlAllowed;
147 };
148
149private:
150 I_REF(imtbase::ISelection, m_deviceSelectionCompPtr);
151 I_REF(imtdev::IDeviceController, m_controllerCompPtr);
152 I_REF(imtdev::IDeviceConfigurationManager, m_configurationManagerCompPtr);
153 I_REF(IDeviceStateProvider, m_stateProviderCompPtr);
154
158
159 bool m_isConfigurationStoreBlocked = false;
160};
161
162
163} // namespace imtdev
164
165
Selection-based device configuration component.
Interface for managing device-specific configurations.
Common interface for controlling devices.
Interface for tracking device connection states.