1 #ifndef GS_CFG_EXT_PARAMS_H
2 #define GS_CFG_EXT_PARAMS_H
6 #include <GoApi/Configuration/Nodes/Container.h>
7 #include <GoApi/Configuration/Nodes/DynamicContainer.h>
8 #include <GoApi/Configuration/Attributes.h>
9 #include <GoApi/Configuration/Nodes/Value.h>
10 #include <GoApi/GoApi.h>
14 typedef struct ExtParamsStatic
16 ExtParamLUT* extParamsLut;
19 kDeclareStaticClassEx(
Gdk, ExtParams)
21 GdkFx(
kStatus) xExtParams_InitStatic();
22 GdkFx(
kStatus) xExtParams_ReleaseStatic();
24 namespace GoCfg = Go::Configuration;
52 GdkCppFx(std::ostream&) operator<<(std::ostream& stream, const ExtParamType& source);
53 GdkCppFx(std::istream&) operator>>(std::istream& stream, ExtParamType& source);
64 using UsedAttrType = GoCfg::UsedAttribute;
65 using StringAttrType = GoCfg::ValueAttribute<std::string>;
66 using ParamTypeAttrType = GoCfg::ValueAttribute<ExtParamType>;
67 using StringOptionsType = GoCfg::OptionsAttribute<std::string>;
69 virtual ~ExtParam() {}
71 virtual void Dispose() = 0;
73 virtual GoCfg::Node& ModelNode() = 0;
75 virtual UsedAttrType& Used() = 0;
76 virtual ParamTypeAttrType& ParamType() = 0;
77 virtual StringAttrType& Label() = 0;
78 virtual StringAttrType& Units() = 0;
80 virtual StringOptionsType& OptionNames() = 0;
81 virtual void ClearOptions() = 0;
82 virtual size_t OptionCount()
const = 0;
83 virtual void RemoveOptionAt(
size_t index) = 0;
85 virtual bool IsRead()
const = 0;
91 virtual void CopyValues(
const ExtParam& other) = 0;
104 ParamTypeAttrType type;
105 StringAttrType label;
106 StringAttrType units;
107 StringOptionsType optionNames;
115 this->RegisterAttribute(used);
117 this->RegisterAttribute(type,
"type");
118 this->RegisterAttribute(label,
"label");
119 this->RegisterAttribute(units,
"units");
120 this->RegisterAttribute(optionNames,
"optionNames");
123 optionNames.enabled =
false;
126 editableParamInfo =
kNULL;
129 T::SetPreWriteHandler([=] () {
130 this->OnBeforeWrite();
133 T::SetPostReadHandler([=] () {
140 kDestroyRef(&editableParamInfo);
148 void CopyValues(
const ExtParam& other)
override
155 type = typedOther.type.Get();
156 label = typedOther.label.Get();
157 units = typedOther.units.Get();
158 optionNames.CopyOptions(typedOther.optionNames);
161 GoCfg::Node& ModelNode()
override
163 return static_cast<GoCfg::Node&
>(*this);
166 ParamTypeAttrType& ParamType()
override
171 UsedAttrType& Used()
override
176 StringAttrType& Label()
override
181 StringAttrType& Units()
override
186 StringOptionsType& OptionNames()
override
191 void ClearOptions()
override
196 size_t OptionCount()
const override
198 return optionNames.Count();
201 void RemoveOptionAt(
size_t index)
203 optionNames.Remove(index);
206 bool IsRead()
const override
213 return !
kIsNull(editableParamInfo) ? editableParamInfo : paramInfo;
220 Go::Test(GdkParamInfo_ConstructParamAttached(&editableParamInfo, (
GdkParam)static_cast<ExtParam*>(
this),
kNULL));
223 return editableParamInfo;
228 this->paramInfo = paramInfo;
229 kDestroyRef(&editableParamInfo);
233 virtual void OnBeforeWrite()
235 units.enabled = (units.Get() !=
"");
236 used.enabled = (used.Get() !=
true);
239 virtual void OnAfterRead()
254 GoCfg::OptionsAttribute<T> options;
258 GoCfg::Value<T>::RegisterAttribute(options,
"options");
261 void CopyValues(
const ExtParam& other)
override
267 this->Set(typedOther.Get());
268 options.CopyOptions(typedOther.options);
271 void ClearOptions()
override
274 this->optionNames.Clear();
277 size_t OptionCount()
const override
279 return options.Count();
282 void RemoveOptionAt(
size_t index)
284 options.Remove(index);
286 if (index < this->optionNames.Count())
288 this->optionNames.Remove(index);
292 using GoCfg::Value<T>::operator=;
295 void OnBeforeWrite()
override
297 BaseType::OnBeforeWrite();
299 bool enableOptions = options.Count() > 0;
301 options.enabled = enableOptions;
302 this->optionNames.enabled = enableOptions;
309 GoCfg::MinAttribute<T> min;
310 GoCfg::MaxAttribute<T> max;
314 GoCfg::Value<T>::RegisterAttribute(min,
"min");
315 GoCfg::Value<T>::RegisterAttribute(max,
"max");
318 void CopyValues(
const ExtParam& other)
override
322 auto& typedOther =
dynamic_cast<const ExtNumericParam<T>&
>(other);
323 min = typedOther.min.Get();
324 max = typedOther.max.Get();
330 void OnBeforeWrite()
override
350 struct ExtIntParam : ExtNumericParam<k32s>
354 optionNames.enabled =
true;
360 using ExtNumericParam<k32s>::operator=;
363 void OnBeforeWrite()
override
365 ExtNumericParam<k32s>::OnBeforeWrite();
373 struct ExtFloatParam : ExtNumericParam<k64f>
377 optionNames.enabled =
true;
383 using ExtNumericParam<k64f>::operator=;
386 void OnBeforeWrite()
override
388 ExtNumericParam<k64f>::OnBeforeWrite();
414 void CopyValues(
const ExtParam& other)
override
416 ExtCompositeParam::CopyValues(other);
421 struct ExtProfileRegionParam : ExtRegionParam
423 GoCfg::Value<k64f> x;
424 GoCfg::Value<k64f> z;
425 GoCfg::Value<k64f> width;
426 GoCfg::Value<k64f> height;
428 ExtProfileRegionParam()
432 Register(width,
"Width");
433 Register(height,
"Height");
436 GdkRegionXZ64f GdkRegion()
const
438 GdkRegionXZ64f gdkRegion;
442 gdkRegion.width = width;
443 gdkRegion.height = height;
448 const GdkRegionXZ64f* GdkRegionPtr()
450 gdkRegionStore = GdkRegion();
451 return &gdkRegionStore;
454 void SetGdkRegion(
const GdkRegionXZ64f& region)
458 width = region.width;
459 height = region.height;
462 void CopyValues(
const ExtParam& other)
override
464 ExtRegionParam::CopyValues(other);
466 auto& typedOther =
dynamic_cast<const ExtProfileRegionParam&
>(other);
467 SetGdkRegion(typedOther.GdkRegion());
471 GdkRegionXZ64f gdkRegionStore;
475 struct ExtSurfaceRegionParam : ExtRegionParam
477 GoCfg::Value<k64f> x;
478 GoCfg::Value<k64f> y;
479 GoCfg::Value<k64f> z;
480 GoCfg::Value<k64f> width;
481 GoCfg::Value<k64f> length;
482 GoCfg::Value<k64f> height;
483 GoCfg::Value<k64f> zAngle;
484 GoCfg::UsedAttribute zAngleUsed;
486 ExtSurfaceRegionParam()
491 Register(width,
"Width");
492 Register(length,
"Length");
493 Register(height,
"Height");
494 Register(zAngle,
"ZAngle");
495 zAngle.RegisterAttribute(zAngleUsed);
498 GdkRegion3d64f GdkRegion()
const
500 GdkRegion3d64f gdkRegion;
505 gdkRegion.width = width;
506 gdkRegion.length = length;
507 gdkRegion.height = height;
508 gdkRegion.zAngle = zAngle;
513 const GdkRegion3d64f* GdkRegionPtr()
515 gdkRegionStore = GdkRegion();
516 return &gdkRegionStore;
519 void SetGdkRegion(
const GdkRegion3d64f& region)
524 width = region.width;
525 length = region.length;
526 height = region.height;
527 zAngle = region.zAngle;
530 void CopyValues(
const ExtParam& other)
override
532 ExtRegionParam::CopyValues(other);
534 auto& typedOther =
dynamic_cast<const ExtSurfaceRegionParam&
>(other);
535 SetGdkRegion(typedOther.GdkRegion());
536 zAngleUsed = typedOther.zAngleUsed.Get();
540 GdkRegion3d64f gdkRegionStore;
544 struct ExtSurfaceRegion2dParam : ExtRegionParam
546 GoCfg::Value<k64f> x;
547 GoCfg::Value<k64f> y;
548 GoCfg::Value<k64f> width;
549 GoCfg::Value<k64f> length;
551 ExtSurfaceRegion2dParam()
555 Register(width,
"Width");
556 Register(length,
"Length");
559 GdkRegion2d64f GdkRegion()
const
561 GdkRegion2d64f gdkRegion;
565 gdkRegion.width = width;
566 gdkRegion.length = length;
571 const GdkRegion2d64f* GdkRegionPtr()
573 gdkRegionStore = GdkRegion();
574 return &gdkRegionStore;
577 void SetGdkRegion(
const GdkRegion2d64f& region)
581 width = region.width;
582 length = region.length;
585 void CopyValues(
const ExtParam& other)
override
587 ExtRegionParam::CopyValues(other);
589 auto& typedOther =
dynamic_cast<const ExtSurfaceRegion2dParam&
>(other);
590 SetGdkRegion(typedOther.GdkRegion());
594 GdkRegion2d64f gdkRegionStore;
600 ExtFeatureInputParam()
605 void OnBeforeWrite()
override
609 this->options.enabled =
true;
610 this->optionNames.enabled =
true;
614 struct PointSetRegionAxisValue : GoCfg::Value<k64f>
616 GoCfg::ValueAttribute<k64f> actualValue;
617 GoCfg::ValueAttribute<bool> readonly;
619 PointSetRegionAxisValue()
621 this->RegisterAttribute(actualValue,
"value");
622 this->RegisterAttribute(readonly,
"readonly");
625 using GoCfg::Value<k64f>::operator=;
628 struct PointSetRegionPoint : GoCfg::Container
630 PointSetRegionAxisValue x;
631 PointSetRegionAxisValue y;
632 PointSetRegionAxisValue z;
634 PointSetRegionPoint()
636 this->Register(x,
"X");
637 this->Register(y,
"Y");
638 this->Register(z,
"Z");
643 compatContainer.
x = x;
644 compatContainer.y = y;
645 compatContainer.z = z;
647 return &compatContainer;
655 struct ExtPointSetRegionParam :
ExtParamImpl<GoCfg::DynamicContainer<PointSetRegionPoint>>
659 GoCfg::ValueAttribute<k32u> maxPoints =
k32U_MAX;
660 GoCfg::ValueAttribute<k32u> minPoints = 0;
661 GoCfg::ValueAttribute<kMarkerShape> pointShape = -1;
662 GoCfg::ValueAttribute<k16u> pointSize = 0;
663 GoCfg::ValueAttribute<GdkPointSetRegionMode> mode = -1;
664 GoCfg::ValueAttribute<GdkPointSetRegionColor> pointColor =
k32U_MAX;
665 GoCfg::ValueAttribute<GdkPointSetRegionColor> lineColor =
k32U_MAX;
666 GoCfg::ValueAttribute<bool> showProjection =
true;
668 bool useShowProjection =
true;
671 ExtPointSetRegionParam()
674 this->RegisterAttribute(maxPoints,
"maxPointCount");
675 this->RegisterAttribute(minPoints,
"minPointCount");
676 this->RegisterAttribute(pointShape,
"pointShape");
677 this->RegisterAttribute(pointSize,
"pointSize");
678 this->RegisterAttribute(mode,
"mode");
679 this->RegisterAttribute(pointColor,
"pointColor");
680 this->RegisterAttribute(lineColor,
"lineColor");
681 this->RegisterAttribute(showProjection,
"showProjection");
683 this->RegisterType<PointSetRegionPoint>(
"Point");
686 void CopyValues(
const ExtParam& other)
override
688 BaseType::CopyValues(other);
690 auto& typedOther =
dynamic_cast<const ExtPointSetRegionParam&
>(other);
692 maxPoints = typedOther.maxPoints.Get();
693 minPoints = typedOther.minPoints.Get();
694 pointShape = typedOther.pointShape.Get();
695 pointSize = typedOther.pointSize.Get();
696 mode = typedOther.mode.Get();
697 pointColor = typedOther.pointColor.Get();
698 lineColor = typedOther.lineColor.Get();
699 showProjection = typedOther.showProjection.Get();
701 useShowProjection = typedOther.useShowProjection;
702 constantZ = typedOther.constantZ;
706 void OnBeforeWrite()
override
708 BaseType::OnBeforeWrite();
710 mode.enabled = mode.Get() != -1;
711 pointShape.enabled = pointShape.Get() != -1;
712 pointSize.enabled = pointSize.Get() != 0;
713 pointColor.enabled = pointColor.Get() !=
k32U_MAX;
714 lineColor.enabled = lineColor.Get() !=
k32U_MAX;
715 showProjection.enabled = useShowProjection;
716 maxPoints.enabled = maxPoints.Get() !=
k32U_MAX;
717 minPoints.enabled = minPoints.Get() != 0;
719 for (
size_t i = 0; i < this->Count(); ++i)
721 PointSetRegionPoint& point = this->At(i);
723 point.x.actualValue = point.x.Get();
724 point.x.readonly =
false;
726 point.y.actualValue = point.y.Get();
727 point.y.readonly =
false;
729 if (constantZ == k64F_NULL)
731 point.z.actualValue = point.z.Get();
732 point.z.readonly =
false;
736 point.z.actualValue = constantZ;
737 point.z.readonly =
true;
760 operator GdkStreamId()
const;
764 GdkCppFx(std::ostream&) operator<<(std::ostream& stream, const
ExtStreamId& source);
765 GdkCppFx(std::istream&) operator>>(std::istream& stream,
ExtStreamId& source);
774 GoCfg::OptionsAttribute<GdkDataType> dataTypes;
780 this->RegisterAttribute(dataTypes,
"dataTypes");
785 void ClearOptions()
override
788 this->options.Clear();
789 this->optionNames.Clear();
793 void OnBeforeWrite()
override
797 this->options.enabled =
true;
798 this->optionNames.enabled =
true;
810 using ParamType = std::unique_ptr<ExtParam>;
819 return dynamic_cast<ExtParam&
>(At(index));
822 ExtParam& Find(
const std::string& name)
824 size_t index = paramNameMap.at(name);
825 return *(parameters[index].get());
828 void Add(
const std::string& name, ParamType parameter)
830 Register(parameter->ModelNode(), name);
832 parameters.emplace_back(std::move(parameter));
833 paramNameMap[name] = parameters.size() - 1;
838 std::vector<ParamType> parameters;
839 std::map<std::string, size_t> paramNameMap;
842 GdkCppFx(std::unique_ptr<ExtParam>) ConstructExtParamFromInfo(
GdkParamInfo info,
bool copyDefaults = true);
Essential Gdk declarations.
Definition: GdkCfgInterfaces.h:14
Base composite value parameter that contain child properties.
Definition: ExtParams.h:342
Declares the GdkParamInfo class.
Represents a stream ID.
Definition: ExtParams.h:748
Shared common implementation of parameters. Extends a chosen model node type as template parameter "T...
Definition: ExtParams.h:102
Represents the schema of a configurable parameter.
#define GDK_PARAM_TYPE_UNKNOWN
Not yet set.
Definition: GdkParamInfo.h:31
Shared interface of all GDK parameters.
Definition: ExtParams.h:62
Represents the data of a configurable parameter.
Represents a set of properties.
Definition: ExtParams.h:808
Base simple value parameter.
Definition: ExtParams.h:251