ImagingTools Core SDK
CCommandLineParamsAdapterComp.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// ACF includes
5#include <icomp/CComponentBase.h>
6#include <imod/TSingleModelObserverBase.h>
7#include <iprm/CParamsSet.h>
8#include <iprm/IOptionsList.h>
9#include <iser/ISerializable.h>
10
11namespace imtbase
12{
13
14
15class CCommandLineParamsAdapterComp:
16 public icomp::CComponentBase,
17 public iprm::CParamsSet,
18 public imod::TSingleModelObserverBase<iprm::IOptionsList>
19{
20public:
21 typedef icomp::CComponentBase BaseClass;
22
23 I_BEGIN_COMPONENT(CCommandLineParamsAdapterComp);
24 I_REGISTER_INTERFACE(iprm::IParamsSet);
25 I_ASSIGN(m_prefixAttrPtr, "OptionNamePrefix", "Prefix preceding option name", true, "-");
26 I_ASSIGN_MULTI_0(m_nameAttrPtr, "OptionName", "Option name", false);
27 I_ASSIGN_MULTI_0(m_idAttrPtr, "ParameterId", "Parameter ID in paramset", false);
28 I_ASSIGN_MULTI_0(m_typeAttrPtr, "OptionType", "Option value type\n0 - String\n1 - Integer\n2 - Double", false);
29 I_ASSIGN(m_optionListCompPtr, "OptionList", "List of registered options to search on the command line", false, "");
30 I_ASSIGN_TO(m_paramListModelCompPtr, m_optionListCompPtr, true);
31 I_END_COMPONENT;
32
33 enum ParamType
34 {
35 PT_STRING = 0,
36 PT_INT,
37 PT_DOUBLE
38 };
39
40protected:
41 int GetParameterCount();
42
43 // reimplemented (imod::CSingleModelObserverBase)
44 virtual void OnUpdate(const istd::IChangeable::ChangeSet& changeSet) override;
45
46 // reimplemented (icomp::CComponentBase)
47 virtual void OnComponentCreated() override;
48 virtual void OnComponentDestroyed() override;
49
50private:
51 I_ATTR(QByteArray, m_prefixAttrPtr);
52 I_MULTIATTR(QByteArray, m_nameAttrPtr);
53 I_MULTIATTR(QByteArray, m_idAttrPtr);
54 I_MULTIATTR(int, m_typeAttrPtr);
55 I_REF(iprm::IOptionsList, m_optionListCompPtr);
56 I_REF(imod::IModel, m_paramListModelCompPtr);
57};
58
59
60} // namespace imtbase
61
62