6#include <QtCore/QtGlobal>
7#include <QtCore/QStringList>
8#include <QtCore/QtDebug>
25template <
class ParamsSet,
class ParameterInterace>
40 TParamsPtrBase(ParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory =
true);
52 bool isObligatory =
true);
60 void Init(ParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory =
true);
69 void Init(ParamsSet* parameterSetPtr,
72 bool isObligatory =
true);
78template <
class ParamsSet,
class ParameterInterace>
85template <
class ParamsSet,
class ParameterInterace>
87 ParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory)
89 Init(parameterSetPtr, parameterId, isObligatory);
93template <
class ParamsSet,
class ParameterInterace>
95 ParamsSet* parameterSetPtr,
100 Init(parameterSetPtr, parameterIdAttribute, defaultRef, isObligatory);
104template <
class ParamsSet,
class ParameterInterace>
106 ParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory)
108 Q_UNUSED(isObligatory);
109 Q_STATIC_ASSERT(std::is_const<ParamsSet>{} == std::is_const<ParameterInterace>{});
113 if ((parameterSetPtr !=
NULL) && !parameterId.isEmpty()){
116 if constexpr (std::is_const<ParamsSet>{}){
117 constParameterPtr = parameterSetPtr->GetParameter(parameterId);
118 BaseClass::SetPtr(
dynamic_cast<ParameterInterace*
>(constParameterPtr));
122 BaseClass::SetPtr(
dynamic_cast<ParameterInterace*
>(parameterPtr));
124 constParameterPtr = parameterPtr;
127#if QT_VERSION >= 0x040800
129 if (!BaseClass::IsValid() && isObligatory){
131 QStringList existingIds;
132 for (iprm::IParamsSet::Ids::ConstIterator index = existingParamIds.constBegin(); index != existingParamIds.constEnd(); index++){
133 existingIds.push_back(*index);
136 QString idList = existingIds.join(
", ");
138 if (constParameterPtr ==
NULL){
139 qDebug(
"Parameter %s was not found in the parameter set. Following parameter IDs are registered: %s", qPrintable(parameterId), qPrintable(idList));
142 qDebug(
"Parameter %s was found in the parameter set, but it doesn't implement the required interface: %s", qPrintable(parameterId), qPrintable(
typeid(ParameterInterace).name()));
154template <
class ParamsSet,
class ParameterInterace>
156 ParamsSet* parameterSetPtr,
161 Q_UNUSED(isObligatory);
162 Q_STATIC_ASSERT(std::is_const<ParamsSet>{} == std::is_const<ParameterInterace>{});
166 if (parameterIdAttribute.
IsValid()){
167 if (parameterSetPtr !=
NULL){
170 if constexpr (std::is_const<ParamsSet>{}){
171 constParameterPtr = parameterSetPtr->GetParameter(*parameterIdAttribute);
172 BaseClass::SetPtr(
dynamic_cast<ParameterInterace*
>(constParameterPtr));
175 iser::ISerializable* parameterPtr = parameterSetPtr->GetEditableParameter(*parameterIdAttribute);
176 BaseClass::SetPtr(
dynamic_cast<ParameterInterace*
>(parameterPtr));
178 constParameterPtr = parameterPtr;
181#if QT_VERSION >= 0x050000
183 if ((!BaseClass::IsValid()) && (constParameterPtr !=
NULL)){
184 qDebug(
"Parameter %s in parameter set is not compatible, should be %s", qPrintable(*parameterIdAttribute), qPrintable(istd::CClassInfo::GetName<ParameterInterace>()));
189#if QT_VERSION >= 0x050000
191 else if (isObligatory){
192 qDebug(
"Parameter set unavailable, cannot extract obligatory parameter %s", qPrintable(*parameterIdAttribute));
198 if (!BaseClass::IsValid() && defaultRef.
IsValid()){
199 BaseClass::SetPtr(defaultRef.
GetPtr());
202#if QT_VERSION >= 0x040800
204 if (!BaseClass::IsValid() && isObligatory){
205 QString debugMessage;
207 if (parameterSetPtr ==
NULL){
208 debugMessage = QString(
"There is no parameter set and no default parameter is active");
210 else if (parameterIdAttribute.
IsValid()){
212 QStringList existingIds;
213 for (iprm::IParamsSet::Ids::ConstIterator index = existingParamIds.constBegin(); index != existingParamIds.constEnd(); index++){
214 existingIds.push_back(*index);
217 QString idList = existingIds.join(
", ");
219 debugMessage = QString(
"Parameter %1 was not found in the parameter set and no default parameter is active. Following parameter IDs are registered: %2").arg(QString(*parameterIdAttribute)).arg(idList);
222 debugMessage = QString(
"Parameter was not specified and no default parameter is active");
225 qDebug() << debugMessage;
232template <
class ParameterInterace>
243 :
BaseClass(parameterSetPtr, parameterId, isObligatory)
251 bool isObligatory =
true)
252 :
BaseClass(parameterSetPtr, parameterIdAttribute, defaultRef, isObligatory)
256 void Init(
const IParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory =
true)
264 bool isObligatory =
true)
266 BaseClass::Init(parameterSetPtr, parameterIdAttribute, defaultRef, isObligatory);
271template <
class ParameterInterace>
283 :
BaseClass(parameterSetPtr, parameterId, isObligatory)
291 bool isObligatory =
true)
292 :
BaseClass(parameterSetPtr, parameterIdAttribute, defaultRef, isObligatory)
296 void Init(
IParamsSet* parameterSetPtr,
const QByteArray& parameterId,
bool isObligatory =
true)
304 bool isObligatory =
true)
306 BaseClass::Init(parameterSetPtr, parameterIdAttribute, defaultRef, isObligatory);
Pointer to component attribute.
bool IsValid() const
Check if this attribute is valid.
Pointer to referenced component object.
Interface * GetPtr() const
Direct cccess to internal pointer.
bool IsValid() const
Check if this reference can be resolved.
Set of general parameters.
TEditableParamsPtr(ParameterInterace *ptr=NULL)
TEditableParamsPtr(IParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< ParameterInterace > &defaultRef, bool isObligatory=true)
TParamsPtrBase< IParamsSet, ParameterInterace > BaseClass
void Init(IParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< ParameterInterace > &defaultRef, bool isObligatory=true)
TEditableParamsPtr(IParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
void Init(IParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
Help pointer wrapper for management of a parameter from the parameter set.
TParamsPtrBase(ParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
Construct and initialize the pointer with the given parameter set and parameter ID.
void Init(ParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
Initialize the pointer with the given parameter set and parameter ID.
void Init(ParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< NonConstParameterInterface > &defaultRef, bool isObligatory=true)
Initialize the pointer with the component parameters.
TParamsPtrBase(ParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< NonConstParameterInterface > &defaultRef, bool isObligatory=true)
Construct and initialize the pointer with the component parameters.
istd::TPointerBase< ParameterInterace > BaseClass
std::remove_const_t< ParameterInterace > NonConstParameterInterface
TParamsPtrBase(ParameterInterace *ptr=NULL)
TParamsPtr(const IParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
TParamsPtrBase< const IParamsSet, const ParameterInterace > BaseClass
TParamsPtr(const IParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< ParameterInterace > &defaultRef, bool isObligatory=true)
TParamsPtr(const ParameterInterace *ptr=NULL)
void Init(const IParamsSet *parameterSetPtr, const icomp::TAttributeMember< iattr::CIdAttribute > ¶meterIdAttribute, const icomp::TReferenceMember< ParameterInterace > &defaultRef, bool isObligatory=true)
void Init(const IParamsSet *parameterSetPtr, const QByteArray ¶meterId, bool isObligatory=true)
Common class for all classes which objects can be archived or restored from archive.
Implementation of pointer wrapper.
#define I_IF_DEBUG(instructions)
Contains interfaces and implementations of flexible parameter concept.