DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Loading...
Searching...
No Matches
Object.h
Go to the documentation of this file.
1// This file is part of DynExp.
2
9#pragma once
10
11#include "stdafx.h"
12#include "BusyDialog.h"
13#include "ParamsConfig.h"
14
15class DynExpManager;
16
17namespace DynExp
18{
19 class DynExpCore;
20 class Object;
21 class RunnableObject;
22 class LinkedObjectWrapperContainerBase;
23 class ObjectLinkBase;
24 class RunnableInstance;
25 class HardwareAdapterBase;
26 class InstrumentBase;
27 class ModuleBase;
28 class CommonResourceManagerBase;
29 class HardwareAdapterManager;
30 class InstrumentManager;
31 class ModuleManager;
32 class NetworkParamsExtension;
33
34 template <typename>
35 class ObjectLink;
36
40 using ItemIDListType = std::vector<ItemIDType>;
41
48 template <
49 typename ObjectType,
50 std::enable_if_t<
51 std::is_base_of_v<HardwareAdapterBase, ObjectType> || std::is_base_of_v<InstrumentBase, ObjectType>,
52 int> = 0
53 >
55 {
59 using type = std::conditional_t<
60 std::is_base_of_v<HardwareAdapterBase, ObjectType>,
63 >;
64 };
65
71 template <typename ObjectType>
73
80 {
81 public:
82 ObjectUserList() = default;
83 virtual ~ObjectUserList() = default;
84
90 [[nodiscard]] Util::ILockable::LockType AcquireLock(const std::chrono::milliseconds Timeout = DefaultTimeout) const;
91
97 void Register(const Object& User, const std::chrono::milliseconds Timeout = std::chrono::milliseconds(0));
98
105 LockType Register(const Object& User, LockType&& Lock);
106
112 void Deregister(const Object& User, const std::chrono::milliseconds Timeout = std::chrono::milliseconds(0));
113
119 size_t CountUsers(std::chrono::milliseconds Timeout = std::chrono::milliseconds(0)) const;
120
126 ItemIDListType GetUserIDs(std::chrono::milliseconds Timeout = std::chrono::milliseconds(0)) const;
127
134 std::string GetUserNamesString(std::chrono::milliseconds Timeout = std::chrono::milliseconds(0)) const;
135
140
143 void DeregisterAllUnsafe();
144
145 size_t CountUsersUnsafe() const;
147 std::string GetUserNamesStringUnsafe() const;
149
150 private:
155
161 void RegisterUnsafe(const Object& User);
162
169 void DeregisterUnsafe(const Object& User);
171
176 std::unordered_map<const Object*, size_t> UserList;
177 };
178
184 {
185 public:
193 LinkBase(std::string_view IconResourcePath = {}, bool Optional = false)
195
196 protected:
197 virtual ~LinkBase() {}
198
208 template <typename ResourceManagerType>
209 auto ShareResource(const ResourceManagerType& Manager, ItemIDType ID) { return Manager.LinkBaseOnly.ShareResourceAsNonConst(ID); }
210
221 template <typename ObjectType>
223 {
224 // template disambiguator (see ISO C++03 14.2/4)
225 auto FoundIDs = Manager.template Filter<ObjectType>();
226 if (FoundIDs.empty() && !IsOptional())
227 {
228 constexpr auto FilterTypeBaseName = std::is_base_of_v<HardwareAdapterBase, ObjectType> ? "hardware adapter" :
229 (std::is_base_of_v<InstrumentBase, ObjectType> ? "instrument" : "< error-type >");
230
231 throw Util::EmptyException("At least one " + std::string(FilterTypeBaseName) + " of type " +
232 ObjectType::CategoryAndNameToStr(ObjectType::Category(), ObjectType::Name()) + " is needed before this item can be created.");
233 }
234
235 std::sort(FoundIDs.begin(), FoundIDs.end(), [&Manager](const auto& a, const auto& b) {
236 return Manager.GetResource(a)->GetObjectName() < Manager.GetResource(b)->GetObjectName();
237 });
238
240 for (const auto& ID : FoundIDs)
241 {
242 const auto Resource = Manager.GetResource(ID);
243 std::string Label = Resource->GetObjectName() + " (" + Resource->GetCategoryAndName() + ")";
244
245 FoundIDsWithLabels.emplace_back(std::move(Label), ID);
246 }
247
248 return FoundIDsWithLabels;
249 }
250
251 public:
256 std::string_view GetIconResourcePath() const noexcept { return IconResourcePath; }
257 bool IsOptional() const noexcept { return Optional; }
259
265
270 bool IsReady() { return IsReadyChild(); }
271
276 std::string_view GetLinkTitle() const noexcept { return GetLinkTitleChild(); }
277
283
290
291 private:
296 virtual void EnsureReadyStateChild() = 0;
297 virtual bool IsReadyChild() = 0;
298
299 virtual std::string_view GetLinkTitleChild() const noexcept = 0;
300 virtual ItemIDListType GetLinkedIDsChild() const = 0;
301 virtual const CommonResourceManagerBase* GetCommonManagerChild() const noexcept = 0;
303
307 const std::string_view IconResourcePath;
308
312 const bool Optional;
313 };
314
325 class ParamsBase : public Util::ISynchronizedPointerLockable
326 {
327 private:
328 struct OwnedParamInfo;
329
333 using OwnedParamsType = std::vector<OwnedParamInfo>;
334
335 protected:
348 template <typename>
349 struct dispatch_tag {};
350
351 public:
352 using ObjectLinkParamsType = std::vector<std::reference_wrapper<LinkBase>>;
353 using EnumParamSignedIntegerType = intmax_t;
355
361 template <typename EnumType>
362 using LargestEnumUnderlyingType = std::conditional_t<
363 std::is_signed_v<std::underlying_type_t<EnumType>>,
366 >;
367
369 class TextList {};
371
378 {
379 private:
384 {
385 friend class ParamsBase;
386
391 constexpr ParamsBaseOnlyType(ParamBase& Parent) noexcept : Parent(Parent) {}
392
393 void DisableUserEditable() noexcept { Parent.DisableUserEditable(); }
394 void AddToDialog(ParamsConfigDialog& Dialog) { Parent.AddToDialog(Dialog); }
395
397 };
398
399 protected:
408 ParamBase(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange);
409
415 ParamBase(ParamsBase& Owner, std::string ParamName);
416
417 virtual ~ParamBase() = 0;
418
419 public:
420 ParamBase(const ParamBase&) = delete;
421 ParamBase& operator=(const ParamBase&) = delete;
422
427 bool IsUserEditable() const noexcept { return UserEditable; }
428 std::string_view GetParamName() const noexcept { return ParamName; }
429 std::string_view GetParamTitle() const noexcept { return ParamTitle; }
430 std::string_view GetParamDescription() const noexcept { return ParamDescription; }
431 bool GetNeedsResetToApplyChange() const noexcept { return NeedsResetToApplyChange; }
433
440 QDomElement ToXMLNode(QDomDocument& Document) const;
441
446 void FromXMLNode(const QDomElement& XMLElement);
447
453 bool Validate();
454
458 void Reset() { ResetChild(); }
459
461
462 protected:
463 const auto& GetOwner() const noexcept { return Owner; }
464 auto& GetOwner() noexcept { return Owner; }
465
466 private:
470 void DisableUserEditable() noexcept { UserEditable = false; }
471
476 void AddToDialog(ParamsConfigDialog& Dialog) { AddToDialogChild(Dialog); }
477
482
487 virtual void ToXMLNodeChild(QDomDocument& Document, QDomElement& XMLElement) const = 0;
488
489 virtual void FromXMLNodeChild(const QDomElement& XMLElement) = 0;
490 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) = 0;
491 virtual bool ValidateChild() const { return true; }
492 virtual void ResetChild() = 0;
494
499
505
506 const std::string ParamName;
507 const std::string_view ParamTitle;
508 const std::string_view ParamDescription;
509
514 };
515
521 class DummyParam : public ParamBase
522 {
523 public:
524 DummyParam(ParamsBase& Owner) : ParamBase(Owner, "") {}
525
526 private:
527 virtual void ToXMLNodeChild(QDomDocument& Document, QDomElement& XMLElement) const override {}
528 virtual void FromXMLNodeChild(const QDomElement& XMLElement) override {}
529 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override {}
530 virtual void ResetChild() override {}
531 };
532
537 template <typename ParamType>
539 {
540 public:
541 using UnderlyingType = ParamType;
542
543 protected:
548 TypedParamBase(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
549 bool NeedsResetToApplyChange = true, ParamType DefaultValue = ParamType())
550 : ParamBase(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange),
551 DefaultValue(std::move(DefaultValue)), Value(this->DefaultValue) {}
552
557 TypedParamBase(ParamsBase& Owner, std::string ParamName, ParamType DefaultValue = ParamType())
558 : ParamBase(Owner, ParamName),
559 DefaultValue(std::move(DefaultValue)), Value(this->DefaultValue) {}
560
561 public:
566 ParamType GetDefaultValue() const noexcept { return DefaultValue; }
567
571 operator ParamType() const noexcept { return Value; }
572
577 const ParamType& Get() const noexcept { return Value; }
578
587 const ParamType& operator=(const ParamType& NewValue)
588 {
589 if (!ValidateValue(NewValue))
591 "An assignment to a parameter cannot be executed since the given value is considered invalid.");
592
593 Value = NewValue;
594 return Get();
595 }
596
597 protected:
598 virtual void ToXMLNodeChild(QDomDocument& Document, QDomElement& XMLElement) const override
599 {
600 QDomText NodeValue = Document.createTextNode(QString::fromStdString(Util::ToStr(Value)));
601 XMLElement.appendChild(NodeValue);
602 }
603
604 virtual void FromXMLNodeChild(const QDomElement& XMLElement) override
605 {
606 Value = Util::GetTFromDOMElement<ParamType>(XMLElement, GetParamName().data());
607 }
608
609 private:
610 virtual bool ValidateChild() const override final { return ValidateValue(Value); }
611
618 virtual bool ValidateValue(const ParamType& NewValue) const { return true; }
619
620 virtual void ResetChild() override { Value = DefaultValue; }
621
622 const ParamType DefaultValue;
623 ParamType Value;
624 };
625
630 template <typename ParamType>
632 {
633 public:
637 using UnderlyingType = std::vector<ParamType>;
638
639 protected:
644 TypedListParamBase(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
645 bool NeedsResetToApplyChange = true, UnderlyingType DefaultValues = {})
646 : ParamBase(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange),
647 DefaultValues(std::move(DefaultValues)), Values(this->DefaultValues) {}
648
653 TypedListParamBase(ParamsBase& Owner, std::string ParamName, UnderlyingType DefaultValues = {})
654 : ParamBase(Owner, ParamName),
655 DefaultValues(std::move(DefaultValues)), Values(this->DefaultValues) {}
656
657 public:
662 const auto& GetDefaultValue() const noexcept { return DefaultValues; }
663
668 const auto& Get() const noexcept { return Values; }
669
678 auto& operator=(const UnderlyingType& NewValues)
679 {
680 if (!ValidateValues(NewValues))
682 "An assignment to a list parameter cannot be executed since the given value vector is considered invalid.");
683
684 Values = NewValues;
685 return Get();
686 }
687
688 protected:
689 virtual void ToXMLNodeChild(QDomDocument& Document, QDomElement& XMLElement) const override
690 {
691 QDomElement ValuesNode = Document.createElement("Values");
692
693 for (const auto& value : Values)
694 {
695 QDomElement ValueNode = Document.createElement("v");
696 QDomText NodeValue = Document.createTextNode(QString::fromStdString(Util::ToStr(value)));
697
698 ValueNode.appendChild(NodeValue);
699 ValuesNode.appendChild(ValueNode);
700 }
701
702 XMLElement.appendChild(ValuesNode);
703 }
704
705 virtual void FromXMLNodeChild(const QDomElement& XMLElement) override
706 {
707 QDomElement ValuesNode;
708
709 try
710 {
711 auto ParamNode = Util::GetSingleChildDOMElement(XMLElement, GetParamName().data());
712 ValuesNode = Util::GetSingleChildDOMElement(ParamNode, "Values");
713 }
714 catch ([[maybe_unused]] const Util::NotFoundException& e)
715 {
716 // Assume that a single value is assigned to the parameter (if it has been converted to a list parameter later on).
717 const auto Value = Util::GetTFromDOMElement<ParamType>(XMLElement, GetParamName().data());
718
719 Values.clear();
720 Values.push_back(Value);
721
722 return;
723 }
724
725 auto ValueNodes = Util::GetChildDOMNodes(ValuesNode, "v");
726
727 Values.clear();
728 for (const auto& value : ValueNodes)
729 Values.push_back(Util::StrToT<ParamType>(value.toElement().text().toStdString()));
730 }
731
732 private:
733 virtual bool ValidateChild() const override final { return ValidateValues(Values); }
734
741 virtual bool ValidateValues(const UnderlyingType& NewValues) const { return true; }
742
743 virtual void ResetChild() override { Values = DefaultValues; }
744
747 };
748
749 template <typename ParamType, typename = void>
750 class Param;
751
756 template <typename ParamType>
757 class Param<ParamType,
758 std::enable_if_t<
759 !std::is_arithmetic_v<ParamType> &&
760 !std::is_base_of_v<Text, ParamType> &&
761 !std::is_base_of_v<TextList, ParamType> &&
762 !std::is_base_of_v<IndexedTextList, ParamType> &&
763 !std::is_enum_v<ParamType> &&
764 !std::is_base_of_v<ObjectLinkBase, ParamType>
765 >>
766 : public TypedParamBase<ParamType>
767 {
768 public:
769 using TypedParamBase<ParamType>::operator=;
770
774 Param(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange = true,
775 ParamType DefaultValue = ParamType())
776 : TypedParamBase<ParamType>(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, std::move(DefaultValue)) {}
777
781 Param(ParamsBase& Owner, std::string ParamName, ParamType DefaultValue = ParamType())
782 : TypedParamBase<ParamType>(Owner, ParamName, std::move(DefaultValue)) {}
783
784 private:
785 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
786 {
788 "A general (unspecified) parameter cannot be added to a settings dialog.");
789 }
790 };
791
792 template <typename ArithmeticType>
794
800 template <typename ArithmeticType>
801 class Param<ArithmeticType, std::enable_if_t<std::is_arithmetic_v<ArithmeticType>>> : public UnderlyingArithmeticParamType<ArithmeticType>
802 {
803 public:
804 using PrecisionType = unsigned short;
805 using UnderlyingArithmeticParamType<ArithmeticType>::operator=;
806
814 Param(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange = true,
815 ArithmeticType DefaultValue = ArithmeticType(),
816 ArithmeticType MinValue = std::numeric_limits<ArithmeticType>::lowest(), ArithmeticType MaxValue = std::numeric_limits<ArithmeticType>::max(),
817 ArithmeticType Increment = 1, PrecisionType Precision = 0)
818 : UnderlyingArithmeticParamType<ArithmeticType>(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, std::move(DefaultValue)),
819 MinValue(MinValue), MaxValue(MaxValue), Increment(Increment), Precision(Precision) {}
820
828 Param(ParamsBase& Owner, std::string ParamName, ArithmeticType DefaultValue = ArithmeticType(),
829 ArithmeticType MinValue = std::numeric_limits<ArithmeticType>::lowest(), ArithmeticType MaxValue = std::numeric_limits<ArithmeticType>::max(),
830 ArithmeticType Increment = 1, PrecisionType Precision = 0)
831 : UnderlyingArithmeticParamType<ArithmeticType>(Owner, ParamName, std::move(DefaultValue)),
832 MinValue(MinValue), MaxValue(MaxValue), Increment(Increment), Precision(Precision) {}
833
838 ArithmeticType GetMinValue() const noexcept { return MinValue; }
839 ArithmeticType GetMaxValue() const noexcept { return MaxValue; }
840 ArithmeticType GetIncrement() const noexcept { return Increment; }
841 PrecisionType GetPrecision() const noexcept { return Precision; }
843
847 explicit operator bool() const { return UnderlyingArithmeticParamType<ArithmeticType>::Get() != 0; }
848
849 private:
850 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
851 {
852 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<UnderlyingArithmeticParamType<ArithmeticType>*>(this)),
853 UnderlyingArithmeticParamType<ArithmeticType>::Get(), MinValue, MaxValue, Precision, Increment);
854 }
855
856 virtual bool ValidateValue(const ArithmeticType& Value) const override
857 {
858 return Value >= MinValue && Value <= MaxValue;
859 }
860
861 const ArithmeticType MinValue;
862 const ArithmeticType MaxValue;
863 const ArithmeticType Increment;
865 };
866
868
874 template <typename ParamType>
875 class Param<ParamType, std::enable_if_t<std::is_base_of_v<Text, ParamType>>> : public UnderlyingTextParamType
876 {
877 public:
878 using UnderlyingTextParamType::operator=;
879
884 Param(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle,
885 std::string_view ParamDescription, bool NeedsResetToApplyChange = true, UnderlyingTextParamType::UnderlyingType DefaultValue = "",
886 TextUsageType TextUsage = TextUsageType::Standard)
887 : UnderlyingTextParamType(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, DefaultValue), TextUsage(TextUsage) {}
888
892 Param(ParamsBase& Owner, std::string ParamName, UnderlyingTextParamType::UnderlyingType DefaultValue = "")
893 : UnderlyingTextParamType(Owner, ParamName, DefaultValue), TextUsage(TextUsageType::Standard) {}
894
899 std::filesystem::path GetPath() const { return GetOwner().ToAbsolutePath(Get()); }
900
905 auto GetTextUsage() const noexcept { return TextUsage; }
907
908 private:
910
911 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
912 {
913 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<UnderlyingTextParamType*>(this)), Get(), TextUsage);
914 }
915 };
916
918
924 template <typename ParamType>
925 class Param<ParamType, std::enable_if_t<std::is_base_of_v<TextList, ParamType>>> : public UnderlyingTextListParamType
926 {
927 public:
928 using UnderlyingTextListParamType::operator=;
929
934 Param(ParamsBase& Owner, Util::TextListType&& TextList, std::string ParamName, std::string_view ParamTitle,
935 std::string_view ParamDescription, bool NeedsResetToApplyChange = true, UnderlyingTextListParamType::UnderlyingType DefaultValue = "")
936 : UnderlyingTextListParamType(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, DefaultValue),
937 TextList(std::move(TextList)) {}
938
943 Param(ParamsBase& Owner, Util::TextListType&& TextList, std::string ParamName,
945 : UnderlyingTextListParamType(Owner, ParamName, DefaultValue),
946 TextList(std::move(TextList)) {}
947
952 const auto& GetTextList() const noexcept { return TextList; }
954
960
964 void SetTextList(Util::TextListType&& NewTextList) { TextList = std::move(NewTextList); }
966
967 private:
968 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
969 {
970 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<UnderlyingTextListParamType*>(this)),
971 Get(), TextList, !GetDefaultValue().empty());
972 }
973
981 };
982
984
991 template <typename ParamType>
992 class Param<ParamType, std::enable_if_t<std::is_base_of_v<IndexedTextList, ParamType>>> : public UnderlyingIndexedTextListParamType
993 {
994 public:
995 using UnderlyingIndexedTextListParamType::operator=;
996
1001 Param(ParamsBase& Owner, Util::TextListType&& TextList, std::string ParamName, std::string_view ParamTitle,
1002 std::string_view ParamDescription, bool NeedsResetToApplyChange = true, UnderlyingIndexedTextListParamType::UnderlyingType DefaultValue = 0)
1003 : UnderlyingIndexedTextListParamType(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, DefaultValue),
1004 TextList(std::move(TextList)) {}
1005
1010 Param(ParamsBase& Owner, Util::TextListType&& TextList, std::string ParamName,
1012 : UnderlyingIndexedTextListParamType(Owner, ParamName, DefaultValue),
1013 TextList(std::move(TextList)) {}
1014
1019 const auto& GetTextList() const noexcept { return TextList; }
1021
1022 private:
1023 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1024 {
1025 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<UnderlyingIndexedTextListParamType*>(this)),
1026 Get(), GetDefaultValue(), TextList);
1027 }
1028
1029 virtual bool ValidateValue(const ParamType& Value) const override { return Value < TextList.size(); }
1030
1032 };
1033
1039 template <typename EnumType>
1041
1047 template <typename EnumType>
1048 class Param<EnumType, std::enable_if_t<std::is_enum_v<EnumType>>> : public UnderlyingEnumParamType<EnumType>
1049 {
1050 public:
1055 Param(ParamsBase& Owner, Util::TextValueListType<EnumType>&& TextValueList, std::string ParamName, std::string_view ParamTitle,
1056 std::string_view ParamDescription, bool NeedsResetToApplyChange = true, EnumType DefaultValue = EnumType())
1057 : UnderlyingEnumParamType<EnumType>(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, DefaultValue),
1058 TextValueList(std::move(TextValueList)) {}
1059
1063 Param(ParamsBase& Owner, std::string ParamName, EnumType DefaultValue = EnumType())
1064 : UnderlyingEnumParamType<EnumType>(Owner, ParamName, DefaultValue) {}
1065
1070
1075 EnumType GetDefaultValue() const noexcept { return static_cast<EnumType>(UnderlyingEnumParamType<EnumType>::GetDefaultValue()); }
1076
1077 const auto& GetTextValueList() const noexcept { return TextValueList; }
1079
1083 operator EnumType() const noexcept { return static_cast<EnumType>(UnderlyingEnumParamType<EnumType>::Get()); }
1084
1089 const EnumType Get() const noexcept { return static_cast<EnumType>(UnderlyingEnumParamType<EnumType>::Get()); }
1090
1097 const EnumType operator=(const EnumType& NewValue)
1098 {
1100
1101 return Get();
1102 }
1103
1104 private:
1105 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1106 {
1107 Dialog.AddParam<EnumType>({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<UnderlyingEnumParamType<EnumType>*>(this)),
1108 Get(), GetDefaultValue(), TextValueList);
1109 }
1110
1112 };
1113
1115
1122 {
1123 protected:
1129 LinkParamBase(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
1130 bool NeedsResetToApplyChange = true, std::string_view IconResourcePath = {}, bool Optional = false)
1131 : LinkBase(IconResourcePath, Optional),
1132 UnderlyingLinkParamType(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, ItemIDNotSet) {}
1133
1134 public:
1135 using UnderlyingLinkParamType::operator=;
1136
1137 private:
1138 virtual std::string_view GetLinkTitleChild() const noexcept override { return GetParamTitle(); }
1139 virtual ItemIDListType GetLinkedIDsChild() const override { return Get() != ItemIDNotSet ? ItemIDListType{ Get() } : ItemIDListType{}; }
1140 };
1141
1149 template <typename LinkType>
1150 class Param<LinkType, std::enable_if_t<std::is_base_of_v<ObjectLinkBase, LinkType>>> : public LinkParamBase
1151 {
1152 public:
1153 using ObjectType = typename LinkType::ObjectType;
1155 using LinkParamBase::operator=;
1156
1161 Param(ParamsBase& Owner, const ManagerType& Manager,
1162 std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
1163 std::string_view IconResourcePath = {}, bool Optional = false, bool NeedsResetToApplyChange = true)
1164 : LinkParamBase(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, IconResourcePath, Optional),
1165 Manager(Manager)
1166 {
1167 // Since classes derived from ParamBase are declared within the scope of class ParamsBase, this is allowed.
1168 // This is safe since ObjectLinkParams is declared before any Param<LinkType> within the inheritance hierarchy.
1169 GetOwner().ObjectLinkParams.emplace_back(std::ref(*this));
1170 }
1171
1176 const auto& GetManager() const noexcept { return Manager; }
1177
1182 bool ContainsID() const noexcept { return Get() != ItemIDNotSet; }
1183
1189 const LinkType& GetLink() const noexcept { return Link; }
1190
1199 {
1200 if (!ContainsID())
1201 Link.Reset();
1202 else
1203 {
1204 auto Resource = std::dynamic_pointer_cast<ObjectType>(ShareResource(Manager, Get()));
1205 if (!Resource)
1207 "A resource assigned to a param does not match the expected type.");
1208
1209 Link = Resource;
1210 }
1211 }
1212
1213 private:
1214 virtual const CommonResourceManagerBase* GetCommonManagerChild() const noexcept override { return &Manager; }
1215
1216 virtual void FromXMLNodeChild(const QDomElement& XMLElement) override
1217 {
1218 UnderlyingLinkParamType::FromXMLNodeChild(XMLElement);
1219 MakeLink();
1220 }
1221
1222 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1223 {
1224 // Call MakeLink() after "OK" (accept) has been clicked to really link the parameter to the chosen object by creating pointers.
1225 auto FunctionToCallIfAccepted = std::bind_front(&Param::MakeLink, this);
1226
1227 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<LinkParamBase*>(this)),
1228 Get(), IsOptional(), GetIconResourcePath(), FunctionToCallIfAccepted, MakeObjectIDsWithLabels<ObjectType>(GetManager()));
1229 }
1230
1234 void EnsureReadyStateChild() override final
1235 {
1236 if (!ContainsID())
1237 return;
1238
1239 auto LinkedObj = Link.TryLockDestinyRaw();
1240 if (LinkedObj)
1241 LinkedObj->EnsureReadyState(true);
1242 }
1243
1244 bool IsReadyChild() override final
1245 {
1246 if (!ContainsID())
1247 return true;
1248
1249 auto LinkedObj = Link.TryLockDestinyRaw();
1250 if (LinkedObj)
1251 {
1252 try
1253 {
1254 return LinkedObj->IsReady();
1255 }
1256 catch ([[maybe_unused]] const Util::TimeoutException& e)
1257 {
1258 // Swallow TimeoutException since this is thrown if IsReady() cannot check the object's exception state
1259 // because the object is busy and locked its data. This is considered not ready.
1260 return false;
1261 }
1262 }
1263 else
1264 return true;
1265 }
1266
1272
1277 LinkType Link;
1278 };
1279
1280 template <typename ParamType, typename = void>
1282
1287 template <typename ParamType>
1288 class ListParam<ParamType,
1289 std::enable_if_t<
1290 !std::is_arithmetic_v<ParamType> &&
1291 !std::is_base_of_v<ObjectLinkBase, ParamType>
1292 >>
1293 : public TypedListParamBase<ParamType>
1294 {
1295 public:
1296 using TypedListParamBase<ParamType>::operator=;
1297
1301 ListParam(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange = true,
1302 typename TypedListParamBase<ParamType>::UnderlyingType DefaultValues = {})
1303 : TypedListParamBase<ParamType>(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, std::move(DefaultValues)) {}
1304
1308 ListParam(ParamsBase& Owner, std::string ParamName, typename TypedListParamBase<ParamType>::UnderlyingType DefaultValues = {})
1309 : TypedListParamBase<ParamType>(Owner, ParamName, std::move(DefaultValues)) {}
1310
1311 private:
1312 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1313 {
1315 "A general (unspecified) list parameter cannot be added to a settings dialog.");
1316 }
1317 };
1318
1319 template <typename ArithmeticType>
1321
1327 template <typename ArithmeticType>
1328 class ListParam<ArithmeticType, std::enable_if_t<std::is_arithmetic_v<ArithmeticType>>> : public UnderlyingArithmeticListParamType<ArithmeticType>
1329 {
1330 public:
1331 using PrecisionType = unsigned short;
1332 using UnderlyingArithmeticListParamType<ArithmeticType>::operator=;
1333
1341 ListParam(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange = true,
1342 typename TypedListParamBase<ArithmeticType>::UnderlyingType DefaultValues = {},
1343 ArithmeticType MinValue = std::numeric_limits<ArithmeticType>::lowest(), ArithmeticType MaxValue = std::numeric_limits<ArithmeticType>::max(),
1344 ArithmeticType Increment = 1, PrecisionType Precision = 0)
1345 : UnderlyingArithmeticListParamType<ArithmeticType>(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, std::move(DefaultValues)),
1346 MinValue(MinValue), MaxValue(MaxValue), Increment(Increment), Precision(Precision) {}
1347
1355 ListParam(ParamsBase& Owner, std::string ParamName, typename TypedListParamBase<ArithmeticType>::UnderlyingType DefaultValues = {},
1356 ArithmeticType MinValue = std::numeric_limits<ArithmeticType>::lowest(), ArithmeticType MaxValue = std::numeric_limits<ArithmeticType>::max(),
1357 ArithmeticType Increment = 1, PrecisionType Precision = 0)
1358 : UnderlyingArithmeticListParamType<ArithmeticType>(Owner, ParamName, std::move(DefaultValues)),
1359 MinValue(MinValue), MaxValue(MaxValue), Increment(Increment), Precision(Precision) {}
1360
1365 ArithmeticType GetMinValue() const noexcept { return MinValue; }
1366 ArithmeticType GetMaxValue() const noexcept { return MaxValue; }
1367 ArithmeticType GetIncrement() const noexcept { return Increment; }
1368 PrecisionType GetPrecision() const noexcept { return Precision; }
1370
1371 private:
1372 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1373 {
1375 "An arithmetic list parameter cannot be added to a settings dialog currently.");
1376 }
1377
1378 bool ValidateValues(const typename TypedListParamBase<ArithmeticType>::UnderlyingType& NewValues) const override
1379 {
1380 for (const auto value : NewValues)
1381 if (value < MinValue || value > MaxValue)
1382 return false;
1383
1384 return true;
1385 }
1386
1387 const ArithmeticType MinValue;
1388 const ArithmeticType MaxValue;
1389 const ArithmeticType Increment;
1391 };
1392
1394
1401 {
1402 protected:
1408 LinkListParamBase(ParamsBase& Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
1409 bool NeedsResetToApplyChange = true, std::string_view IconResourcePath = {}, bool Optional = false)
1410 : LinkBase(IconResourcePath, Optional),
1411 UnderlyingLinkListParamType(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange) {}
1412
1413 public:
1414 using UnderlyingLinkListParamType::operator=;
1415
1416 private:
1417 virtual std::string_view GetLinkTitleChild() const noexcept override { return GetParamTitle(); }
1418 virtual ItemIDListType GetLinkedIDsChild() const override { return Get(); }
1419 };
1420
1428 template <typename LinkType>
1429 class ListParam<LinkType, std::enable_if_t<std::is_base_of_v<ObjectLinkBase, LinkType>>> : public LinkListParamBase
1430 {
1431 public:
1432 using ObjectType = typename LinkType::ObjectType;
1434 using LinkListParamBase::operator=;
1435
1440 ListParam(ParamsBase& Owner, const ManagerType& Manager,
1441 std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription,
1442 std::string_view IconResourcePath = {}, bool Optional = false, bool NeedsResetToApplyChange = true)
1443 : LinkListParamBase(Owner, ParamName, ParamTitle, ParamDescription, NeedsResetToApplyChange, IconResourcePath, Optional),
1444 Manager(Manager)
1445 {
1446 // Since classes derived from ParamBase are declared within the scope of class ParamsBase, this is allowed.
1447 // This is safe since ObjectLinkParams is declared before any Param<LinkType> within the inheritance hierarchy.
1448 GetOwner().ObjectLinkParams.emplace_back(std::ref(*this));
1449 }
1450
1455 const auto& GetManager() const noexcept { return Manager; }
1456
1462 bool ContainsID() const noexcept { return !Get().empty(); }
1463
1469 const auto& GetLinks() const noexcept { return Links; }
1470
1479 {
1480 Links.clear();
1481
1482 if (ContainsID())
1483 {
1484 for (auto ID : Get())
1485 {
1486 auto Resource = std::dynamic_pointer_cast<ObjectType>(ShareResource(Manager, ID));
1487 if (!Resource)
1489 "A resource assigned to a list parameter does not match the expected type.");
1490
1491 Links.emplace_back(Resource);
1492 }
1493 }
1494 }
1495
1496 private:
1497 virtual const CommonResourceManagerBase* GetCommonManagerChild() const noexcept override { return &Manager; }
1498
1499 virtual void FromXMLNodeChild(const QDomElement& XMLElement) override
1500 {
1501 UnderlyingLinkListParamType::FromXMLNodeChild(XMLElement);
1502 MakeLinks();
1503 }
1504
1505 virtual void AddToDialogChild(ParamsConfigDialog& Dialog) override final
1506 {
1507 // Call MakeLink() after "OK" (accept) has been clicked to really link the parameter to the chosen object by creating pointers.
1508 auto FunctionToCallIfAccepted = std::bind_front(&ListParam::MakeLinks, this);
1509
1510 Dialog.AddParam({ ParamBase::GetParamTitle(), ParamBase::GetParamDescription() }, std::ref(*static_cast<LinkListParamBase*>(this)),
1511 Get(), IsOptional(), GetIconResourcePath(), FunctionToCallIfAccepted, MakeObjectIDsWithLabels<ObjectType>(GetManager()));
1512 }
1513
1518 bool ValidateValues(const typename LinkListParamBase::UnderlyingType& NewValues) const override
1519 {
1520 for (const auto value : NewValues)
1521 if (value == ItemIDNotSet)
1522 return false;
1523
1524 return true;
1525 }
1526
1530 void EnsureReadyStateChild() override final
1531 {
1532 if (!ContainsID())
1533 return;
1534
1535 for (auto& Link : Links)
1536 {
1537 auto LinkedObj = Link.TryLockDestinyRaw();
1538 if (LinkedObj)
1539 LinkedObj->EnsureReadyState(true);
1540 }
1541 }
1542
1543 bool IsReadyChild() override final
1544 {
1545 if (!ContainsID())
1546 return true;
1547
1548 for (auto& Link : Links)
1549 {
1550 auto LinkedObj = Link.TryLockDestinyRaw();
1551 if (!LinkedObj)
1552 continue;
1553
1554 try
1555 {
1556 if (!LinkedObj->IsReady())
1557 return false;
1558 }
1559 catch ([[maybe_unused]] const Util::TimeoutException& e)
1560 {
1561 // Swallow TimeoutException since this is thrown if IsReady() cannot check the object's exception state
1562 // because the object is busy and locked its data. This is considered not ready.
1563 return false;
1564 }
1565 }
1566
1567 return true;
1568 }
1569
1575
1580 std::vector<LinkType> Links;
1581 };
1582
1589 {
1590 public:
1595 LinkParamStarter(const ParamsBase& Params) noexcept
1596 : Params(Params), CurrentParam(Params.ObjectLinkParams.cbegin()), EnsureReadyStateCalledForCurrentParam(false) {}
1597
1603 bool operator()();
1604
1605 private:
1607 ParamsBase::ObjectLinkParamsType::const_iterator CurrentParam;
1609 };
1610
1614 enum UsageType { Unique, Shared };
1629 ParamsBase(ItemIDType ID, const DynExpCore& Core) : ID(ID), Core(Core) {}
1630
1631 virtual ~ParamsBase() = 0;
1632
1643 virtual const char* GetParamClassTag() const noexcept { return "ParamsBase"; }
1644
1651 QDomElement ConfigToXML(QDomDocument& Document) const;
1652
1659 void ConfigFromXML(const QDomElement& XMLElement) const;
1660
1667 void ConfigFromDialog(ParamsConfigDialog& Dialog);
1668
1674 bool Validate() const;
1675
1676 ItemIDType GetID() const noexcept { return ID; }
1677 const auto& GetCore() const noexcept { return Core; }
1678 const auto& GetObjectLinkParams() const noexcept { return ObjectLinkParams; }
1679
1684 static Util::TextValueListType<UsageType> AvlblUsageTypeStrList();
1685
1686 private:
1691 {
1695 const char* const ClassTag;
1696
1700 const std::reference_wrapper<ParamBase> OwnedParam;
1701 };
1702
1715
1716 public:
1720 Param<ParamsConfigDialog::TextType> ObjectName = { *this, "ObjectName", "Name", "Name to identify this item", false };
1721
1725 Param<UsageType> Usage = { *this, AvlblUsageTypeStrList(), "Usage", "Usage type",
1726 "Determines how this item can be used by other items", false, UsageType::Shared };
1727
1733 bool ConfigureUsageType() const noexcept { return ConfigureUsageTypeChild(); }
1734
1741 const NetworkParamsExtension* GetNetworkAddressParams() const noexcept { return GetNetworkAddressParamsChild(); }
1742
1748 static void DisableUserEditable(ParamBase& Param) noexcept;
1749
1750 private:
1755 void ConfigureParams();
1756
1763
1767 virtual bool ConfigureUsageTypeChild() const noexcept { return true; }
1768
1772 virtual const NetworkParamsExtension* GetNetworkAddressParamsChild() const noexcept { return nullptr; }
1773
1777 std::filesystem::path ToAbsolutePath(const std::filesystem::path& Path) const;
1778
1781 };
1782
1791 template <typename ParamType>
1792 auto operator==(const ParamsBase::TypedParamBase<ParamType>& lhs, const ParamType& rhs) { return lhs.Get() == rhs; }
1793
1801 template <typename ParamType>
1802 auto operator<=>(const ParamsBase::TypedParamBase<ParamType>& lhs, const ParamType& rhs) { return lhs.Get() <=> rhs; }
1803
1807 using ParamsBasePtrType = std::unique_ptr<ParamsBase>;
1808
1817 template <typename ConfiguratorT>
1819 {
1820 auto Params = std::make_unique<typename ConfiguratorT::ParamsType>(ID, Core);
1821
1822 Params->ObjectName = ConfiguratorT::ObjectType::Name();
1823
1824 return Params;
1825 }
1826
1834 template <typename T>
1835 typename T::ParamsType* dynamic_Params_cast(ParamsBasePtrType::element_type* Params)
1836 {
1837 if (!Params)
1838 return nullptr;
1839
1840 auto DerivedParams = dynamic_cast<typename T::ParamsType*>(Params);
1841 if (!DerivedParams)
1843
1844 return DerivedParams;
1845 }
1846
1859 template <typename To, typename From, std::enable_if_t<
1860 std::is_same_v<ParamsBase, std::remove_cv_t<From>>, int> = 0
1861 >
1863 {
1864 if (!ParamsPtr)
1865 throw Util::InvalidArgException("ParamsPtr must not be nullptr.");
1866
1868 std::conditional_t<std::is_const_v<From>, std::add_const_t<typename To::ParamsType>, typename To::ParamsType>
1869 >(std::move(ParamsPtr));
1870 }
1871
1879 {
1880 public:
1883
1889 {
1895 constexpr UpdateConfigFromDialogResult(bool Accepted, bool ResetRequired) noexcept
1896 : Accepted(Accepted), ResetRequired(ResetRequired) {}
1897
1898 constexpr bool IsAccepted() const noexcept { return Accepted; }
1899
1904 constexpr bool IsResetRequired() const noexcept { return IsAccepted() && ResetRequired; }
1905
1906 private:
1907 const bool Accepted;
1908 const bool ResetRequired;
1909 };
1910
1911 ConfiguratorBase() = default;
1912 virtual ~ConfiguratorBase() = 0;
1913
1922 ParamsBasePtrType MakeConfigFromDialog(ItemIDType ID, const DynExpCore& Core, QWidget* const DialogParent) const;
1923
1932 ParamsBasePtrType MakeConfigFromXML(ItemIDType ID, const DynExpCore& Core, const QDomElement& XMLElement) const;
1933
1942 UpdateConfigFromDialogResult UpdateConfigFromDialog(Object* Obj, const DynExpCore& Core, QWidget* const DialogParent) const;
1943
1944 private:
1953 virtual ParamsBasePtrType MakeParams(ItemIDType ID, const DynExpCore& Core) const = 0;
1954 };
1955
1959 using ConfiguratorBasePtrType = std::shared_ptr<ConfiguratorBase>;
1960
1971 {
1972 public:
1978
1984
1990
1996
2004 static std::string CategoryAndNameToStr(const std::string& Category, const std::string& Name);
2005
2010 static constexpr std::chrono::milliseconds GetParamsTimeoutDefault = std::chrono::milliseconds(100);
2011
2012 protected:
2017 template <typename>
2018 struct dispatch_tag {};
2019
2027 Object(const std::thread::id OwnerThreadID, ParamsBasePtrType&& Params);
2028
2029 virtual ~Object() = 0;
2030
2031 private:
2036 {
2037 friend class Object;
2038
2039 template <typename>
2041
2046 constexpr LinkedObjectWrapperOnlyType(Object& Parent) noexcept : Parent(Parent) {}
2047
2053
2060 void RegisterUser(const Object& User, const std::chrono::milliseconds Timeout) const;
2061
2065 void DeregisterUser(const Object& User, const std::chrono::milliseconds Timeout) const;
2067
2069 };
2070
2071 public:
2078
2085 void Reset();
2086
2094 void BlockIfUnused(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout);
2096
2101
2108 ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const;
2109
2114 using ParamsGetterType = Util::CallableMemberWrapper<Object, decltype(&Object::GetParams)>;
2115
2121 ParamsTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault);
2122
2128 auto GetObjectName(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const { return GetParams(Timeout)->ObjectName.Get(); }
2129
2136 bool IsSharedUsageEnabled(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const { return GetParams(Timeout)->Usage == ParamsType::UsageType::Shared; }
2138
2143 ItemIDType GetID() const noexcept { return Params->GetID(); }
2144
2150 virtual std::string GetName() const = 0;
2151 virtual std::string GetCategory() const = 0;
2153
2158 std::string GetCategoryAndName() const { return CategoryAndNameToStr(GetCategory(), GetName()); }
2159
2167 void EnsureReadyState(bool IsAutomaticStartup);
2168
2173
2178 void SetWarning(std::string Description, int ErrorCode) const;
2179
2185 void SetWarning(const Util::Exception& e) const;
2186
2190 void ClearWarning() const { Warning.Reset(); }
2191
2196 auto GetWarning() const { return Warning.Get(); }
2197
2204 std::exception_ptr GetException(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return GetExceptionChild(Timeout); }
2205
2211 bool IsReady() const { return !IsBlocked && IsReadyChild(); }
2212
2216 auto GetUseCount(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.CountUsers(Timeout); }
2217
2223 bool IsUnused(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return GetUseCount(Timeout) == 0; }
2224
2228 auto GetUserIDs(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.GetUserIDs(Timeout); }
2229
2233 auto GetUserNamesString(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.GetUserNamesString(Timeout); }
2235
2240 void CheckLinkedObjectStates() const { CheckLinkedObjectStatesChild(); };
2241
2243
2244 protected:
2250 void EnsureCallFromOwningThread() const;
2251
2258 ParamsTypeSyncPtrType GetNonConstParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const;
2259
2264 auto LockUserList(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) { return UserList.AcquireLock(Timeout); }
2265 void DeregisterAllUnsafe() { UserList.DeregisterAllUnsafe(); }
2266 auto GetUseCountUnsafe() { return UserList.CountUsersUnsafe(); }
2267 auto GetUserNamesStringUnsafe() const { return UserList.GetUserNamesStringUnsafe(); }
2268
2273 bool IsUnusedUnsafe() { return GetUseCountUnsafe() == 0; }
2275
2276 private:
2281
2286
2287 virtual std::exception_ptr GetExceptionChild(const std::chrono::milliseconds Timeout) const = 0;
2288 virtual void EnsureReadyStateChild(bool IsAutomaticStartup) = 0;
2289 virtual bool IsReadyChild() const = 0;
2290
2294 virtual void CheckLinkedObjectStatesChild() const {};
2296
2300 void LogWarning() const;
2301
2302 const std::thread::id OwnerThreadID;
2304
2306
2313
2320 bool IsBlocked = false;
2321 };
2322
2330 template <typename To, typename From, std::enable_if_t<
2331 std::is_base_of_v<Object, To> && std::is_base_of_v<Object, From>, int> = 0
2332 >
2333 auto dynamic_Object_cast(From* Obj)
2334 {
2335 if (!Obj)
2336 throw Util::InvalidArgException("Obj must not be nullptr.");
2337
2338 auto DerivedObj = dynamic_cast<std::conditional_t<std::is_const_v<From>, std::add_const_t<To>*, To*>>(Obj);
2339 if (!DerivedObj)
2341
2342 return DerivedObj;
2343 }
2344
2349 {
2350 public:
2354 enum StartupType { OnCreation, Automatic, Manual };
2372
2373 virtual ~RunnableObjectParams() = 0;
2374
2375 virtual const char* GetParamClassTag() const noexcept override { return "RunnableObjectParams"; }
2376
2381 static Util::TextValueListType<StartupType> AvlblStartupTypeStrList();
2382
2386 Param<StartupType> Startup = { *this, AvlblStartupTypeStrList(), "Startup", "Startup type",
2387 "Determines when the item is started", false, StartupType::Automatic };
2388
2394 bool ConfigureStartupType() const noexcept { return ConfigureStartupTypeChild(); }
2395
2396 private:
2397 void ConfigureParamsImpl(dispatch_tag<ParamsBase>) override final;
2399
2404 virtual bool ConfigureStartupTypeChild() const noexcept { return true; }
2406 };
2407
2420
2426 {
2431 {
2432 friend class RunnableObject;
2433 friend class RunnableInstance;
2434
2439 constexpr RunnableInstanceOnlyType(RunnableObject& Parent) noexcept : Parent(Parent) {}
2440
2441 void OnThreadHasExited() const noexcept { Parent.OnThreadHasExited(); }
2442 bool IsLinkedObjStateCheckRequested() const noexcept { return Parent.LinkedObjStateCheckRequested; }
2443 void ResetLinkedObjStateCheckRequested() const noexcept { Parent.LinkedObjStateCheckRequested = false; }
2444
2446 };
2447
2448 public:
2454 {
2455 public:
2461 NotUnusedException(const RunnableObject& Parent) : UserNames(Parent.GetUserNamesStringUnsafe()) {}
2462
2467 std::string_view GetUserNames() const { return UserNames; }
2468
2473 std::string GetErrorMessage() const;
2474
2475 private:
2479 std::string UserNames;
2480 };
2481
2484
2489 static constexpr auto ShortTimeoutDefault = std::chrono::milliseconds(50);
2490
2494 static constexpr auto TerminateTimeoutDefault = std::chrono::milliseconds(3000);
2495
2496 RunnableObject(const std::thread::id OwnerThreadID, ParamsBasePtrType&& Params);
2497 virtual ~RunnableObject() = 0;
2498
2503
2514 bool Run(QWidget* ParentWidget = nullptr);
2515
2523 bool RunIfRunAutomatic();
2524
2530 bool RunIfRunOnCreation();
2531
2538 void Terminate(bool Force = false, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2540
2548 void SetPaused(bool Pause, std::string Description = "");
2549
2550 bool IsRunning() const noexcept { return Running; }
2551 bool IsPaused() const noexcept { return Paused; }
2552 bool IsExiting() const noexcept { return ShouldExit; }
2553
2554 auto GetStartupType() const noexcept { return Startup.load(); }
2555 auto GetReasonWhyPaused() const { return ReasonWhyPaused.Get(); }
2556
2558
2559 protected:
2560 void Init();
2561
2568 std::promise<void> MakeThreadExitedPromise();
2569
2575 void StoreThread(std::thread&& Thread) noexcept;
2576
2586 bool IsCallFromRunnableThread() const;
2587
2593 void EnsureCallFromRunnableThread() const;
2594
2599 void SetReasonWhyPaused(std::string Description) { ReasonWhyPaused = Util::Warning(std::move(Description)); }
2600
2605 void SetReasonWhyPaused(const Util::Exception& e) { ReasonWhyPaused = e; }
2606
2610 void ClearReasonWhyPaused() { ReasonWhyPaused.Reset(); }
2611
2612 private:
2613 void ResetImpl(dispatch_tag<Object>) override final;
2615
2616 void EnsureReadyStateChild(bool IsAutomaticStartup) override final;
2617 void CheckLinkedObjectStatesChild() const override final { LinkedObjStateCheckRequested = true; }
2618
2623 virtual void RunChild() = 0;
2624
2629 virtual void NotifyChild() {}
2630
2638 virtual void TerminateChild(const std::chrono::milliseconds Timeout) {}
2639
2646 virtual std::unique_ptr<BusyDialog> MakeStartupBusyDialogChild(QWidget* ParentWidget) const { return nullptr; }
2648
2656 void TerminateImpl(bool Force, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2657
2665 void TerminateUnsafe(bool Force, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2666
2674 void OnThreadHasExited() noexcept;
2675
2680 std::atomic<RunnableObjectParams::StartupType> Startup = RunnableObjectParams::StartupType::Automatic;
2681
2682 std::thread Thread;
2683 std::future<void> ThreadExitedSignal;
2684 std::atomic<bool> Running;
2685 std::atomic<bool> Paused;
2686 Util::Warning ReasonWhyPaused;
2687
2693 std::atomic<bool> ShouldExit;
2695
2700 mutable std::atomic<bool> LinkedObjStateCheckRequested = false;
2701 };
2702
2707 class LinkedObjectWrapperBase : public Util::INonCopyable
2708 {
2709 friend class RunnableInstance;
2710
2711 private:
2715 using LinkedObjectWrapperBasePtrType = std::unique_ptr<LinkedObjectWrapperBase>;
2716
2722 {
2729 LinkedObjectWrapperContainerBase& OwnedLinkedObjectWrapperContainer)
2730 : OwnedLinkedObjectWrapperPtr(std::move(OwnedLinkedObjectWrapperPtr)),
2731 OwnedLinkedObjectWrapperContainer(OwnedLinkedObjectWrapperContainer) {}
2732
2737
2743 };
2744
2750 using ListType = std::list<OwnedLinkedObjectWrapperType>;
2751
2752 public:
2757 LinkedObjectWrapperBase(const RunnableInstance& Owner) : Owner(Owner) {}
2758
2759 virtual ~LinkedObjectWrapperBase() = 0;
2760
2765
2770 virtual bool IsRegistered() const noexcept = 0;
2772
2777 const Object& GetOwner() const noexcept;
2778
2779 private:
2784
2789 virtual void Register(const std::chrono::milliseconds Timeout) = 0;
2790
2796 virtual void Deregister(const std::chrono::milliseconds Timeout) = 0;
2797
2803 ListType::const_iterator ListPos;
2805
2809 const RunnableInstance& Owner;
2810 };
2811
2821 template <typename ObjectT>
2823 {
2824 public:
2825 using ObjectType = std::add_const_t<ObjectT>;
2826
2833 LinkedObjectWrapper(const RunnableInstance& Owner, std::shared_ptr<ObjectType>&& DestinyResource, const std::chrono::milliseconds Timeout)
2834 : LinkedObjectWrapperBase(Owner),
2835 DestinyResource(std::move(DestinyResource)), IsRegisteredFlag(false)
2836 {
2837 // Checks for nullptr.
2838 LinkedObjectWrapper::Register(Timeout);
2839 }
2840
2845 {
2846 try
2847 {
2848 LinkedObjectWrapper::Deregister(std::chrono::milliseconds(1000));
2849 }
2850 catch (const Util::TimeoutException& e)
2851 {
2852 Util::EventLog().Log(e);
2853 Util::EventLog().Log("Could not deregister a linked object wrapper. Timeout occurred. Execution cannot continue.",
2855
2856 std::terminate();
2857 }
2858 catch (const Util::Exception& e)
2859 {
2860 Util::EventLog().Log("Could not deregister a linked object wrapper. The error listed below occurred. Execution cannot continue.",
2862 Util::EventLog().Log(e);
2863
2864 std::terminate();
2865 }
2866 catch (const std::exception& e)
2867 {
2868 Util::EventLog().Log("Could not deregister a linked object wrapper. The error listed below occurred. Execution cannot continue.",
2870 Util::EventLog().Log(e.what());
2871
2872 std::terminate();
2873 }
2874 catch (...)
2875 {
2876 Util::EventLog().Log("Could not deregister a linked object wrapper. An unknown error occurred. Execution cannot continue.",
2878
2879 std::terminate();
2880 }
2881 }
2882
2883 virtual bool IsRegistered() const noexcept override { return IsRegisteredFlag; }
2884
2892 std::string GetLinkedObjectDesc() const { return DestinyResource->GetObjectName() + " (" + DestinyResource->GetCategoryAndName() + ")"; }
2893
2900 decltype(auto) get() const { return &this->operator*(); }
2901
2902 decltype(auto) get() { return &this->operator*(); }
2905 const auto& operator*() const
2906 {
2907 // ->
2908 // Checking for errors with
2909
2910 /* if (!DestinyResource->IsReady())
2911 throw Util::InvalidCallException("The requested object is in an invalid state or in an error state."); */
2912
2913 // does not work here, because the OnError() handlers of instruments or modules might call
2914 // functions through a LinkedObjectWrapper to perform shutdown operations. This would not be
2915 // possible with a respective error check taking place here. This is not considered a problem,
2916 // since DestinyResource exists in any case and modifying its underlying Object simply does
2917 // not have an effect or throws an exception itself if Object is not ready. Instead, just
2918 // indiate errors by setting LinkedObjectWrapperContainerBase's LinkedObjectState to NotReady
2919 // (see LinkedObjectWrapperContainer<...>::get()).
2920 // <-
2921
2922 if (!IsRegisteredFlag)
2924 "This linked object wrapper instance is deregistered from the requested object.");
2925
2926 return *DestinyResource.get();
2927 }
2930 auto& operator*()
2931 {
2932 // Call const version of operator*
2933 return const_cast<typename std::shared_ptr<ObjectType>::element_type&>(
2934 static_cast<const LinkedObjectWrapper<ObjectT>&>(*this).operator*());
2937 const auto operator->() const { return &this->operator*(); }
2938 auto operator->() { return &this->operator*(); }
2940 private:
2941 virtual void Register(const std::chrono::milliseconds Timeout) override
2942 {
2943 if (!DestinyResource)
2944 throw Util::InvalidArgException("DestinyResource must not be nullptr.");
2945 if (IsRegisteredFlag)
2946 return;
2947
2948 // Could throw Util::TimeoutException if resource is currently modified (e.g. call to Object::Reset()).
2949 DestinyResource->LinkedObjectWrapperOnly.RegisterUser(GetOwner(), Timeout);
2950
2951 IsRegisteredFlag = true;
2953
2954 virtual void Deregister(const std::chrono::milliseconds Timeout) override
2955 {
2956 if (!IsRegisteredFlag)
2957 return;
2958
2959 DestinyResource->LinkedObjectWrapperOnly.DeregisterUser(GetOwner(), Timeout);
2960
2961 IsRegisteredFlag = false;
2962 }
2963
2968 const std::shared_ptr<ObjectType> DestinyResource;
2969
2974 bool IsRegisteredFlag;
2975 };
2976
2983 template <typename ObjectT>
2985 {
2986 public:
2991
2996
3000 LinkedObjectWrapperPointer() noexcept : LinkedObjectWrapperPtr(nullptr) {}
3001
3007 : LinkedObjectWrapperPtr(LinkedObjectWrapperPtr) {}
3008
3014 LinkedObjectWrapperPtrType get() const noexcept { return LinkedObjectWrapperPtr; }
3015
3021 bool operator==(const LinkedObjectWrapperPtrType rhs) const noexcept { return LinkedObjectWrapperPtr == rhs; }
3022
3028 bool operator!=(const LinkedObjectWrapperPtrType rhs) const noexcept { return LinkedObjectWrapperPtr != rhs; }
3029
3035 bool operator==(const LinkedObjectWrapperPointer& rhs) const noexcept { return LinkedObjectWrapperPtr == rhs.get(); }
3036
3042 bool operator!=(const LinkedObjectWrapperPointer& rhs) const noexcept { return LinkedObjectWrapperPtr != rhs.get(); }
3043
3048 explicit operator bool() const noexcept { return LinkedObjectWrapperPtr != nullptr; }
3049
3055 LinkedObjectWrapperPtrType operator->() const noexcept { return LinkedObjectWrapperPtr; }
3056
3062 LinkedObjectWrapperType& operator*() const noexcept { return *LinkedObjectWrapperPtr; }
3063
3064 private:
3069 };
3070
3076 {
3077 friend class RunnableInstance;
3078
3079 public:
3083 enum class LinkedObjectStateType { NotLinked, Ready, NotReady };
3098 protected:
3103 LinkedObjectWrapperContainerBase() noexcept : LinkedObjectState(LinkedObjectStateType::NotLinked) {}
3104
3106
3110 void Reset() noexcept;
3111
3117 mutable LinkedObjectStateType LinkedObjectState;
3118
3119 public:
3120 auto GetState() const noexcept { return LinkedObjectState; }
3121
3128 std::string GetLinkedObjectDesc() const { return GetLinkedObjectDescChild(); }
3129
3136 bool CheckIfReady() { return CheckIfReadyChild(); }
3137
3138 private:
3143 virtual void ResetChild() noexcept = 0;
3144 virtual std::string GetLinkedObjectDescChild() const = 0;
3145 virtual bool CheckIfReadyChild() = 0;
3147 };
3148
3158 template <typename ObjectT>
3160 {
3161 friend class RunnableInstance;
3162
3163 public:
3168 LinkedObjectWrapperContainer(bool PerformReadyCheck = true) noexcept
3169 : PerformReadyCheck(PerformReadyCheck) {}
3170
3172
3177
3185 auto get() const
3186 {
3187 const auto Destiny = GetLinkedObjWrapperPtr()->get();
3188
3189 if (PerformReadyCheck)
3190 {
3191 try
3192 {
3193 // This flag is reset either by SetLinkedObjWrapperPtr() or by
3194 // RunnableInstance::CareAboutWrappers().
3195 if (!Destiny->IsReady())
3196 LinkedObjectState = LinkedObjectStateType::NotReady;
3197 }
3198 // ForwardedException signals that the underlying exception arose in the destiny resource.
3199 // All other exceptions are not to be handled here.
3200 catch ([[maybe_unused]] const Util::ForwardedException& e)
3201 {
3202 LinkedObjectState = LinkedObjectStateType::NotReady;
3203 }
3204 }
3205
3206 return Destiny;
3207 }
3208
3209 auto& operator*() const { return *get(); }
3210 auto operator->() const { return get(); }
3211
3216 bool valid() const noexcept { return static_cast<bool>(LinkedObjWrapperPtr); }
3218
3219 private:
3220 virtual void ResetChild() noexcept override { LinkedObjWrapperPtr = nullptr; }
3221
3222 virtual std::string GetLinkedObjectDescChild() const override
3223 {
3224 if (!LinkedObjWrapperPtr)
3225 return "< unknown >";
3226
3227 return GetLinkedObjWrapperPtr()->GetLinkedObjectDesc();
3228 }
3229
3230 virtual bool CheckIfReadyChild() override
3231 {
3232 if (LinkedObjectState != LinkedObjectStateType::Ready)
3233 return false;
3234
3235 const auto Destiny = GetLinkedObjWrapperPtr()->get();
3236
3237 bool IsReady = Destiny->IsReady();
3238 if (!IsReady)
3239 LinkedObjectState = LinkedObjectStateType::NotReady;
3240
3241 return IsReady;
3242 }
3243
3248 void CheckIfNullptr() const
3249 {
3250 if (!LinkedObjWrapperPtr)
3252 }
3253
3259 {
3260 CheckIfNullptr();
3261
3262 return LinkedObjWrapperPtr;
3263 }
3264
3271 {
3272 LinkedObjWrapperPtr = NewLinkedObjWrapperPtr;
3273 LinkedObjectState = LinkedObjWrapperPtr ? LinkedObjectStateType::Ready : LinkedObjectStateType::NotLinked;
3274
3275 CheckIfReady();
3276 }
3277
3283
3289 };
3290
3301 template <typename ObjectT>
3303 {
3304 friend class RunnableInstance;
3305
3310
3311 public:
3314
3315 const auto& GetList() const noexcept { return Containers; }
3316 const auto& GetLabels() const noexcept { return ObjectLabels; }
3317 std::string_view GetIconPath() const { return IconPath; }
3318
3326 template <typename IndexType>
3327 auto& operator[](IndexType Index)
3328 {
3329 auto i = Util::NumToT<size_t>(Index);
3330
3331 if (i >= Containers.size())
3332 throw Util::OutOfRangeException("The specified object index is higher than the amount of linked objects.");
3333
3334 return *Containers[i];
3335 }
3336
3337 private:
3342 std::vector<std::unique_ptr<ContainerType>> Containers;
3343
3345 std::string IconPath;
3346 };
3347
3353 {
3354 public:
3359 static constexpr std::chrono::milliseconds LockObjectTimeoutDefault = std::chrono::milliseconds(100);
3360
3361 protected:
3362 ObjectLinkBase() = default;
3363 virtual ~ObjectLinkBase() = 0;
3364 };
3365
3381 template <typename ObjectT>
3383 {
3384 public:
3385 using ObjectType = ObjectT;
3386 using ConstObjectType = std::add_const_t<ObjectT>;
3387
3388 friend class RunnableInstance;
3389
3393 ObjectLink() : DestinyResource() {}
3394
3399 ObjectLink(const std::shared_ptr<ObjectType>& DestinyResource) : DestinyResource(DestinyResource) {}
3400
3401 virtual ~ObjectLink() {}
3402
3406 void Reset() { DestinyResource.reset(); }
3407
3413 auto& operator=(const std::shared_ptr<ObjectType>& NewDestinyResource)
3414 {
3415 // Throwing an exception here could lead to only partially loaded Param possessing an
3416 // invalid ObjectLink. Additionally, ParamsConfigDialog::accept() calls
3417 // ParamsBase::Param<LinkType>::MakeLink() which calls this. ParamsConfigDialog::accept()
3418 // should not face exceptions. So, do not throw anything here.
3419 DestinyResource = NewDestinyResource;
3420
3421 return *this;
3422 }
3423
3431 {
3432 // See above.
3433 return DestinyResource.lock();
3434 }
3435
3436 private:
3447 std::unique_ptr<LinkedObjectWrapper<ConstObjectType>> TryLockObject(const RunnableInstance& WrapperOwner,
3448 std::chrono::milliseconds Timeout = LockObjectTimeoutDefault) const
3449 {
3450 std::shared_ptr<ConstObjectType> DestinyShared;
3451
3452 // While object where DestinyResource points to is being destroyed, DestinyResource
3453 // should already be marked as expired, so this is thread-safe.
3454 DestinyShared = DestinyResource.lock();
3455
3456 if (!DestinyShared)
3457 return nullptr;
3458
3459 return std::make_unique<LinkedObjectWrapper<ConstObjectType>>(WrapperOwner, std::move(DestinyShared), Timeout);
3460 }
3461
3471 auto LockObject(const RunnableInstance& WrapperOwner, std::chrono::milliseconds Timeout = LockObjectTimeoutDefault) const
3472 {
3473 auto ObjectWrapperPtr = TryLockObject(WrapperOwner, Timeout);
3474
3475 if (!ObjectWrapperPtr)
3477
3478 return ObjectWrapperPtr;
3479 }
3480
3486 std::weak_ptr<ObjectType> DestinyResource;
3487 };
3488
3505 {
3506 protected:
3512 RunnableInstance(RunnableObject& Owner, std::promise<void>&& ThreadExitedPromise);
3513
3520
3522
3523 public:
3524 const auto& GetOwner() const noexcept { return Owner; }
3525
3536 template <typename ObjectT>
3538 LinkedObjectWrapperContainer<ObjectT>& ObjectWrapperContainer,
3539 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3540 {
3541 ObjectWrapperContainer.SetLinkedObjWrapperPtr(StoreLockedObject(LinkParam.GetLink().TryLockObject(*this, Timeout), ObjectWrapperContainer));
3542 }
3543
3553 template <typename ObjectT>
3555 LinkedObjectWrapperContainer<ObjectT>& ObjectWrapperContainer,
3556 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3557 {
3558 ObjectWrapperContainer.SetLinkedObjWrapperPtr(StoreLockedObject(LinkParam.GetLink().LockObject(*this, Timeout), ObjectWrapperContainer));
3559 }
3560
3569 template <typename ObjectT>
3571 {
3572 // Destroys corresponding LinkedObjectWrapperBase and thereby deregisters from
3573 // LinkedObjectWrapper::DestinyResource.
3574 if (ObjectWrapperContainer.LinkedObjWrapperPtr)
3575 OwnedLinkedObjectWrappers.erase(ObjectWrapperContainer.LinkedObjWrapperPtr->ListPos);
3576
3577 ObjectWrapperContainer.Reset();
3578 }
3579
3580 // TryLockObject() is not overloaded for object link list parameters since it is not clear what
3581 // to do with already locked objects when trying to lock another list of objects fails. If
3582 // the previously locked objects were unlocked before, then the state after a failed call to
3583 // TryLockObject() would not be the same as before.
3584
3597 template <typename ObjectT>
3599 LinkedObjectWrapperContainerList<ObjectT>& ObjectWrapperContainerList,
3600 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3601 {
3602 // Ensure that ObjectWrapperContainerList is empty before locking.
3603 UnlockObject(ObjectWrapperContainerList);
3604
3605 for (const auto& Link : LinkListParam.GetLinks())
3606 {
3607 // Create new container in place since StoreLockedObject() stores a reference to it...
3608 ObjectWrapperContainerList.Containers.emplace_back(std::make_unique<LinkedObjectWrapperContainer<ObjectT>>());
3609 const auto& Container = ObjectWrapperContainerList.Containers.back(); // noexcept
3610
3611 try
3612 {
3613 // ... and fill it.
3614 Container->SetLinkedObjWrapperPtr(StoreLockedObject(Link.LockObject(*this, Timeout), *Container));
3615
3616 ObjectWrapperContainerList.ObjectLabels.emplace_back((*Container)->GetObjectName() + " (" + (*Container)->GetCategoryAndName() + ")");
3617 }
3618 catch (...)
3619 {
3620 // In case locking object or storing label fails, remove the container again.
3621 UnlockObject(*Container);
3622 ObjectWrapperContainerList.Containers.pop_back();
3623
3624 throw;
3625 }
3626 }
3627
3628 if (!LinkListParam.IsOptional() && ObjectWrapperContainerList.Containers.empty())
3629 throw Util::EmptyException("A non-optional object link list parameter is empty.");
3630
3631 ObjectWrapperContainerList.IconPath = LinkListParam.GetIconResourcePath();
3632 }
3633
3641 template <typename ObjectT>
3643 {
3644 for (const auto& Container : ObjectWrapperContainerList.Containers)
3645 UnlockObject(*Container);
3646
3647 ObjectWrapperContainerList.Containers.clear();
3648 ObjectWrapperContainerList.ObjectLabels.clear();
3649 ObjectWrapperContainerList.IconPath.clear();
3650 }
3651
3659 bool CareAboutWrappers();
3660
3666 std::string GetNotReadyObjectNamesString() const;
3667
3672
3673 private:
3677 void SetThreadExited();
3678
3688 template <typename ObjectT>
3689 decltype(auto) StoreLockedObject(std::unique_ptr<LinkedObjectWrapper<ObjectT>>&& ObjectWrapperPtr,
3690 LinkedObjectWrapperContainerBase& ObjectWrapperContainer)
3691 {
3692 OwnedLinkedObjectWrappers.emplace_back(std::move(ObjectWrapperPtr), ObjectWrapperContainer);
3693
3694 auto ObjectWrapperIterator = --OwnedLinkedObjectWrappers.end();
3695 ObjectWrapperIterator->OwnedLinkedObjectWrapperPtr.get()->ListPos = ObjectWrapperIterator;
3696
3697 // Cast should never fail. Reference version since this would throw if it failed.
3698 return &dynamic_cast<typename LinkedObjectWrapperPointer<ObjectT>::LinkedObjectWrapperType&>(*ObjectWrapperIterator->OwnedLinkedObjectWrapperPtr.get());
3699 }
3700
3706
3712 std::promise<void> ThreadExitedPromise;
3713
3718 bool Empty = false;
3719
3727 };
3728}
Implements a dialog with a progress bar, which shows the user that DynExp is busy.
Implements a configuration dialog which allows users to set values of parameters derived from DynExp:...
Implements DynExp's main window as a Qt-based user interface (UI).
Common base class for all derived ResourceManagerBase classes. Logical const-ness: Only const functio...
Definition Managers.h:57
The configurator classes have the task to generate parameter objects (refer to DynExp::ParamsBase) of...
Definition Object.h:1879
virtual ParamsBasePtrType MakeParams(ItemIDType ID, const DynExpCore &Core) const =0
Override to make derived classes call DynExp::MakeParams with the correct configurator type derived f...
DynExp's core class acts as the interface between the user interface and DynExp's internal data like ...
Definition DynExpCore.h:127
Resource manager for HardwareAdapterBase resources deriving from a specialized ResourceManagerBase cl...
Definition Managers.h:631
Resource manager for InstrumentBase resources deriving from a specialized ResourceManagerBase class.
Definition Managers.h:657
Abstract base class of link parameters (to be saved in project files) describing relations between mu...
Definition Object.h:184
const CommonResourceManagerBase * GetCommonManager() const noexcept
This function can be used to determine the object type the parameter is expecting by comparing the re...
Definition Object.h:289
virtual ~LinkBase()
Definition Object.h:197
std::string_view GetIconResourcePath() const noexcept
Definition Object.h:256
auto ShareResource(const ResourceManagerType &Manager, ItemIDType ID)
Returns a shared_ptr pointing to the resource with the given ID contained in the given resource manag...
Definition Object.h:209
auto MakeObjectIDsWithLabels(const ManagerTypeOfObjectType_t< ObjectType > &Manager) const
Finds all resources managed by the given resource manager matching type ObjectTpye and returns a list...
Definition Object.h:222
virtual bool IsReadyChild()=0
Returns whether the object where this link parameter points to is in a ready state.
virtual void EnsureReadyStateChild()=0
Makes sure that the object where this link parameter points to is in a ready state....
const bool Optional
Determines whether this parameter is optional. Optional parameters do not have to point to valid obje...
Definition Object.h:312
virtual std::string_view GetLinkTitleChild() const noexcept=0
Returns a reference to this link parameter's title.
std::string_view GetLinkTitle() const noexcept
Returns a reference to this link parameter's title.
Definition Object.h:276
virtual const CommonResourceManagerBase * GetCommonManagerChild() const noexcept=0
This function can be used to determine the object type the parameter is expecting by comparing the re...
bool IsReady()
Returns whether the object where this link parameter points to is in a ready state.
Definition Object.h:270
ItemIDListType GetLinkedIDs() const
Returns a list of all object IDs assigned to this parameter.
Definition Object.h:282
const std::string_view IconResourcePath
Qt resource path describing an icon being displayed along with this parameter in user interface dialo...
Definition Object.h:307
virtual ItemIDListType GetLinkedIDsChild() const =0
Returns a list of all object IDs assigned to this parameter.
LinkBase(std::string_view IconResourcePath={}, bool Optional=false)
Constructs a LinkBase object.
Definition Object.h:193
void EnsureReadyState()
Makes sure that the object where this link parameter points to is in a ready state....
Definition Object.h:264
bool IsOptional() const noexcept
Definition Object.h:257
Polymorphic base class to allow storing LinkedObjectWrapper of any type in a single list.
Definition Object.h:2708
std::list< OwnedLinkedObjectWrapperType > ListType
Type of a list hold by RunnableInstance (RunnableInstance::OwnedLinkedObjectWrappers) that contains p...
Definition Object.h:2750
std::unique_ptr< LinkedObjectWrapperBase > LinkedObjectWrapperBasePtrType
Alias for a smart pointer owning instances of this class.
Definition Object.h:2715
virtual bool IsRegistered() const noexcept=0
Returns whether the wrapper has registered its owning Object instance (through Owner) as a user of th...
LinkedObjectWrapperBase(const RunnableInstance &Owner)
Constructs a LinkedObjectWrapperBase instance.
Definition Object.h:2757
Polymorphic base class to allow storing LinkedObjectWrapperContainer of any type in a single list.
Definition Object.h:3076
void Reset() noexcept
Removes any linked LinkedObjectWrapper and updates LinkedObjectState.
Definition Object.cpp:742
LinkedObjectWrapperContainerBase() noexcept
Constructs a LinkedObjectWrapperContainerBase instance which is not linked to any LinkedObjectWrapper...
Definition Object.h:3103
bool CheckIfReady()
Returns whether the Object instance which is wrapped by the linked LinkedObjectWrapper is in a ready ...
Definition Object.h:3136
LinkedObjectStateType
Indicates the current state of the Object referenced by the linked LinkedObjectWrapper.
Definition Object.h:3083
virtual void ResetChild() noexcept=0
Removes any linked LinkedObjectWrapper and updates LinkedObjectState.
std::string GetLinkedObjectDesc() const
Builds and returns a human-readable string uniquely identifying the Object instance which is wrapped ...
Definition Object.h:3128
This class defines a list of LinkedObjectWrapperContainer instances. The list owns the contained Link...
Definition Object.h:3303
Util::TextListType ObjectLabels
Holds a human-readable identifier for each linked object.
Definition Object.h:3344
const auto & GetLabels() const noexcept
Returns ObjectLabels.
Definition Object.h:3316
std::string IconPath
Holds the path to the icon of the linked objects' base type (e.g. hardware adapter,...
Definition Object.h:3345
std::vector< std::unique_ptr< ContainerType > > Containers
List of the owned LinkedObjectWrapperContainer instances. std::vector of pointers since insertion and...
Definition Object.h:3342
auto & operator[](IndexType Index)
Returns a stored LinkedObjectWrapperContainer instance selected by its list index.
Definition Object.h:3327
std::string_view GetIconPath() const
Returns IconPath.
Definition Object.h:3317
const auto & GetList() const noexcept
Returns Containers.
Definition Object.h:3315
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Definition Object.h:3160
LinkedObjectWrapperPointer< ObjectT > LinkedObjWrapperPtr
Pointer to a LinkedObjectWrapper instance holding a pointer to the destiny object instance of type co...
Definition Object.h:3282
const bool PerformReadyCheck
Determines whether a call to get() checks the return value of Object::IsReady() before returning Link...
Definition Object.h:3288
virtual std::string GetLinkedObjectDescChild() const override
Builds and returns a human-readable string uniquely identifying the Object instance which is wrapped ...
Definition Object.h:3222
auto get() const
Returns the LinkedObjWrapperPtr and checks (depending on PerformReadyCheck) whether the Object Linked...
Definition Object.h:3185
bool valid() const noexcept
Checks whether LinkedObjWrapperPtr points to a valid distination.
Definition Object.h:3216
auto & GetLinkedObjWrapperPtr() const
Returns LinkedObjWrapperPtr after checking whether LinkedObjWrapperPtr is nullptr.
Definition Object.h:3258
LinkedObjectWrapperContainer(bool PerformReadyCheck=true) noexcept
Constructs a LinkedObjectWrapperContainer instance.
Definition Object.h:3168
virtual bool CheckIfReadyChild() override
Returns whether the Object instance which is wrapped by the linked LinkedObjectWrapper is in a ready ...
Definition Object.h:3230
virtual void ResetChild() noexcept override
Removes any linked LinkedObjectWrapper and updates LinkedObjectState.
Definition Object.h:3220
auto operator->() const
Returns the result of a call to get().
Definition Object.h:3210
auto & operator*() const
Dereferences and returns the result of a call to get().
Definition Object.h:3209
virtual ~LinkedObjectWrapperContainer()=default
void CheckIfNullptr() const
Checks whether LinkedObjWrapperPtr is nullptr. Does nothing if this is not the case.
Definition Object.h:3248
void SetLinkedObjWrapperPtr(LinkedObjectWrapperPointer< ObjectT > NewLinkedObjWrapperPtr) noexcept
Sets LinkedObjWrapperPtr to a new destination and updates LinkedObjectWrapperContainerBase::LinkedObj...
Definition Object.h:3270
This class describes a pointer to a LinkedObjectWrapper instance. It is a simple wrapper class which ...
Definition Object.h:2985
bool operator!=(const LinkedObjectWrapperPtrType rhs) const noexcept
Checks whether LinkedObjectWrapperPtr does not equal another pointer to a LinkedObjectWrapper instanc...
Definition Object.h:3028
LinkedObjectWrapperPtrType LinkedObjectWrapperPtr
LinkedObjectWrapper instance this pointer points to
Definition Object.h:3068
bool operator!=(const LinkedObjectWrapperPointer &rhs) const noexcept
Checks whether this LinkedObjectWrapperPointer instance does not equal another instance.
Definition Object.h:3042
LinkedObjectWrapperPtrType get() const noexcept
Always returns a const pointer so that Object instances using another linked Object instance are only...
Definition Object.h:3014
bool operator==(const LinkedObjectWrapperPtrType rhs) const noexcept
Checks whether LinkedObjectWrapperPtr equals another pointer to a LinkedObjectWrapper instance.
Definition Object.h:3021
LinkedObjectWrapperPointer() noexcept
Constructs an empty pointer.
Definition Object.h:3000
LinkedObjectWrapperPointer(LinkedObjectWrapperPtrType LinkedObjectWrapperPtr) noexcept
Constructs a pointer pointing to LinkedObjectWrapperPtr.
Definition Object.h:3006
LinkedObjectWrapperType & operator*() const noexcept
Always returns a const reference so that Object instances using another linked Object instance are on...
Definition Object.h:3062
bool operator==(const LinkedObjectWrapperPointer &rhs) const noexcept
Checks whether this LinkedObjectWrapperPointer instance equals another instance.
Definition Object.h:3035
LinkedObjectWrapperPtrType operator->() const noexcept
Always returns a const pointer so that Object instances using another linked Object instance are only...
Definition Object.h:3055
Holds a shared_ptr to a resource (instance of class Object) and lets the resource keep track of its u...
Definition Object.h:2823
virtual bool IsRegistered() const noexcept override
Returns whether the wrapper has registered its owning Object instance (through Owner) as a user of th...
Definition Object.h:2883
decltype(auto) get()
Getter for the target resource which is used by the owning Object instance.
Definition Object.h:2902
decltype(auto) get() const
Getter for the target resource which is used by the owning Object instance.
Definition Object.h:2900
std::add_const_t< ObjectT > ObjectType
Const type of the managed Object.
Definition Object.h:2825
virtual ~LinkedObjectWrapper()
Destructor calls LinkedObjectWrapper::Deregister().
Definition Object.h:2844
std::string GetLinkedObjectDesc() const
Builds and returns a human-readable string uniquely identifying the Object instance DestinyResource....
Definition Object.h:2892
LinkedObjectWrapper(const RunnableInstance &Owner, std::shared_ptr< ObjectType > &&DestinyResource, const std::chrono::milliseconds Timeout)
Constructs a LinkedObjectWrapper instance and calls LinkedObjectWrapper::Register().
Definition Object.h:2833
Bundles several parameters to describe a network connection. Use in parameter classes.
Base class for object link parameter types to allow SFINAE in ParamsBase::Param for ObjectLink of any...
Definition Object.h:3353
Helper class to enable keeping track of instances of class Object making use of the owner of the resp...
Definition Object.h:80
std::string GetUserNamesString(std::chrono::milliseconds Timeout=std::chrono::milliseconds(0)) const
Builds a string describing which users are registered containing their object names,...
Definition Object.cpp:49
void Deregister(const Object &User, const std::chrono::milliseconds Timeout=std::chrono::milliseconds(0))
Deregisters a user in a thread-safe way.
Definition Object.cpp:28
std::string GetUserNamesStringUnsafe() const
Definition Object.cpp:82
void Register(const Object &User, const std::chrono::milliseconds Timeout=std::chrono::milliseconds(0))
Registers a user in a thread-safe way.
Definition Object.cpp:14
std::unordered_map< const Object *, size_t > UserList
Map containing pointers to all users making use of this ObjectUserList instance's owner as keys and t...
Definition Object.h:176
void DeregisterAllUnsafe()
Deregisters all users and notifies them that they need to check the states of their used linked objec...
Definition Object.cpp:56
virtual ~ObjectUserList()=default
size_t CountUsersUnsafe() const
Definition Object.cpp:64
size_t CountUsers(std::chrono::milliseconds Timeout=std::chrono::milliseconds(0)) const
Counts the registered useres in a thread-safe way.
Definition Object.cpp:35
ItemIDListType GetUserIDsUnsafe() const
Definition Object.cpp:72
void DeregisterUnsafe(const Object &User)
Deregisters a user.
Definition Object.cpp:101
void RegisterUnsafe(const Object &User)
Registers a user.
Definition Object.cpp:91
Util::ILockable::LockType AcquireLock(const std::chrono::milliseconds Timeout=DefaultTimeout) const
Locks the user list for thread-safe manipulation.
Definition Object.cpp:9
ItemIDListType GetUserIDs(std::chrono::milliseconds Timeout=std::chrono::milliseconds(0)) const
Returns a list of the IDs of the registered users in a thread-safe way.
Definition Object.cpp:42
Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>.
Definition Object.h:2036
constexpr LinkedObjectWrapperOnlyType(Object &Parent) noexcept
Construcs an instance - one for each Object instance.
Definition Object.h:2046
Object & Parent
Owning Object instance.
Definition Object.h:2068
Base class for all DynExp Objects like hardware adapters (DynExp::HardwareAdapterBase),...
Definition Object.h:1971
virtual std::string GetName() const =0
Returns the name of this Object type.
std::string GetCategoryAndName() const
Builds a string from an Object's category and name to allow the user to identify an Object's type.
Definition Object.h:2158
Util::Warning Warning
Last warning which occurred within this Object instance. (Logical const-ness: see above....
Definition Object.h:2305
virtual std::string GetCategory() const =0
Returns the category of this Object type.
auto GetUserIDs(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Returns a list of the IDs of the registered users in a thread-safe way.
Definition Object.h:2228
virtual void EnsureReadyStateChild(bool IsAutomaticStartup)=0
Ensures that this Object instance is ready by possibly starting its worker thread or by opening conne...
ItemIDType GetID() const noexcept
Returns the ID of this Object instance. Thread-safe since ID is const.
Definition Object.h:2143
auto GetUseCount(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Counts the registered useres in a thread-safe way.
Definition Object.h:2216
LinkedObjectWrapperOnlyType LinkedObjectWrapperOnly
Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>.
Definition Object.h:2242
virtual bool IsReadyChild() const =0
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) a...
const std::thread::id OwnerThreadID
Thread id of the thread which has constructed (and owns) this Object instance.
Definition Object.h:2302
virtual void ResetImpl(dispatch_tag< Object >)=0
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
auto GetUserNamesString(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Builds a string describing which users are registered containing their object names,...
Definition Object.h:2233
bool IsUnusedUnsafe()
Returns whether this Object instance is used by other instances (not thread-safe).
Definition Object.h:2273
bool IsUnused(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Returns whether this Object instance is used by other instances.
Definition Object.h:2223
void ClearWarning() const
Resets Object::Warning.
Definition Object.h:2190
auto GetUserNamesStringUnsafe() const
Definition Object.h:2267
virtual void CheckLinkedObjectStatesChild() const
Override to implement a check whether linked objects are in a ready state.
Definition Object.h:2294
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2303
ObjectUserList UserList
List of Object instances making use of this Object instance. Other Object instances making use of thi...
Definition Object.h:2312
virtual std::exception_ptr GetExceptionChild(const std::chrono::milliseconds Timeout) const =0
Returns a pointer to the exception which has caused this Object instance to fail.
auto GetWarning() const
Returns Object::Warning in a thread-safe way by copying its internal data.
Definition Object.h:2196
bool IsReady() const
Returns wheter this Object instance is ready (e.g. it is running or connected to a hardware device) a...
Definition Object.h:2211
auto GetUseCountUnsafe()
Definition Object.h:2266
std::exception_ptr GetException(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Returns a pointer to the exception which has caused this Object instance to fail.
Definition Object.h:2204
void DeregisterAllUnsafe()
Deregisters all users and notifies them that they need to check the states of their used linked objec...
Definition Object.h:2265
bool IsSharedUsageEnabled(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Returns whether shared usage has been enabled for this Object instance. Refer to ParamsBase::UsageTyp...
Definition Object.h:2136
auto GetObjectName(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Returns the name of this Object instance.
Definition Object.h:2128
auto LockUserList(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout)
Locks the user list for thread-safe manipulation.
Definition Object.h:2264
void CheckLinkedObjectStates() const
Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectSt...
Definition Object.h:2240
Refer to ParamsBase::dispatch_tag.
Definition Object.h:2018
Dummy parameter which is to be owned once by parameter classes that do not contain any other paramete...
Definition Object.h:522
DummyParam(ParamsBase &Owner)
Definition Object.h:524
virtual void ResetChild() override
Resets this parameter to its default value.
Definition Object.h:530
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:529
virtual void ToXMLNodeChild(QDomDocument &Document, QDomElement &XMLElement) const override
Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name ...
Definition Object.h:527
virtual void FromXMLNodeChild(const QDomElement &XMLElement) override
Restores this parameter's value from the given Qt dom element (describing an XML node)
Definition Object.h:528
Base class for link list parameters to multiple Object of any (but all the same) type specifying the ...
Definition Object.h:1401
LinkListParamBase(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, std::string_view IconResourcePath={}, bool Optional=false)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1408
virtual ItemIDListType GetLinkedIDsChild() const override
Returns a list of all object IDs assigned to this parameter.
Definition Object.h:1418
virtual std::string_view GetLinkTitleChild() const noexcept override
Returns a reference to this link parameter's title.
Definition Object.h:1417
Base class for link parameters to a single Object of any type specifying the underlying parameter typ...
Definition Object.h:1122
LinkParamBase(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, std::string_view IconResourcePath={}, bool Optional=false)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1129
virtual std::string_view GetLinkTitleChild() const noexcept override
Returns a reference to this link parameter's title.
Definition Object.h:1138
virtual ItemIDListType GetLinkedIDsChild() const override
Returns a list of all object IDs assigned to this parameter.
Definition Object.h:1139
Makes sure the object link parameters of the associated ParamsBase instance are in a ready state by p...
Definition Object.h:1589
bool EnsureReadyStateCalledForCurrentParam
Waiting for the current parameter to become ready or moving on to the next parameter?
Definition Object.h:1608
ParamsBase::ObjectLinkParamsType::const_iterator CurrentParam
Iterator to the parameter which is currently being made ready.
Definition Object.h:1607
LinkParamStarter(const ParamsBase &Params) noexcept
Constructs a LinkParamStarter instance for single use.
Definition Object.h:1595
const ParamsBase & Params
Reference to a parameter class whose object link parameters have to be ready.
Definition Object.h:1606
PrecisionType GetPrecision() const noexcept
Returns the value precision of the list items.
Definition Object.h:1368
ArithmeticType GetIncrement() const noexcept
Returns the value increment of the list items.
Definition Object.h:1367
ArithmeticType GetMinValue() const noexcept
Returns the minimal allowed value of the list items.
Definition Object.h:1365
const ArithmeticType Increment
List item value increment (used in the settings dialog for manual parameter adjustment)
Definition Object.h:1389
ArithmeticType GetMaxValue() const noexcept
Returns the maximal allowed value of the list items.
Definition Object.h:1366
const PrecisionType Precision
List item value precision (used in the settings dialog for manual parameter adjustment)
Definition Object.h:1390
ListParam(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, typename TypedListParamBase< ArithmeticType >::UnderlyingType DefaultValues={}, ArithmeticType MinValue=std::numeric_limits< ArithmeticType >::lowest(), ArithmeticType MaxValue=std::numeric_limits< ArithmeticType >::max(), ArithmeticType Increment=1, PrecisionType Precision=0)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1341
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1372
bool ValidateValues(const typename TypedListParamBase< ArithmeticType >::UnderlyingType &NewValues) const override
Definition Object.h:1378
ListParam(ParamsBase &Owner, std::string ParamName, typename TypedListParamBase< ArithmeticType >::UnderlyingType DefaultValues={}, ArithmeticType MinValue=std::numeric_limits< ArithmeticType >::lowest(), ArithmeticType MaxValue=std::numeric_limits< ArithmeticType >::max(), ArithmeticType Increment=1, PrecisionType Precision=0)
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:1355
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1505
bool IsReadyChild() override final
Returns whether the object where this link parameter points to is in a ready state.
Definition Object.h:1543
void EnsureReadyStateChild() override final
Thread-safe since only main thread is allowed to change parameters and to call this funtion.
Definition Object.h:1530
virtual const CommonResourceManagerBase * GetCommonManagerChild() const noexcept override
This function can be used to determine the object type the parameter is expecting by comparing the re...
Definition Object.h:1497
virtual void FromXMLNodeChild(const QDomElement &XMLElement) override
Restores this parameter's value from the given Qt dom element (describing an XML node)
Definition Object.h:1499
ListParam(ParamsBase &Owner, const ManagerType &Manager, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, std::string_view IconResourcePath={}, bool Optional=false, bool NeedsResetToApplyChange=true)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1440
void MakeLinks()
Retrives the linked resource using its ID stored in the parameter and establishes a link to the resou...
Definition Object.h:1478
ManagerTypeOfObjectType_t< ObjectType > ManagerType
Type of the manager managing the linked Object.
Definition Object.h:1433
const auto & GetManager() const noexcept
Returns the manager instance containing the Object the link refers to.
Definition Object.h:1455
const auto & GetLinks() const noexcept
Returns a list of links of type LinkType derived from ObjectLinkBase to the Object this parameter ref...
Definition Object.h:1469
bool ValidateValues(const typename LinkListParamBase::UnderlyingType &NewValues) const override
Ensures that list entries do not have the ItemIDNotSet value.
Definition Object.h:1518
std::vector< LinkType > Links
List of links of type LinkType derived from ObjectLinkBase referring to the linked Object....
Definition Object.h:1580
bool ContainsID() const noexcept
Checks whether at least one item has been assigned to this parameter. Assigned items are not allowed ...
Definition Object.h:1462
const ManagerType & Manager
Reference to the manager instance containing the Object the link refers to. Managers live longer than...
Definition Object.h:1574
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1312
ListParam(ParamsBase &Owner, std::string ParamName, typename TypedListParamBase< ParamType >::UnderlyingType DefaultValues={})
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:1308
ListParam(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, typename TypedListParamBase< ParamType >::UnderlyingType DefaultValues={})
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1301
Provides the class ParamsBase access to some private members of class ParamBase.
Definition Object.h:384
constexpr ParamsBaseOnlyType(ParamBase &Parent) noexcept
Construcs an instance - one for each ParamBase instance.
Definition Object.h:391
void AddToDialog(ParamsConfigDialog &Dialog)
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:394
ParamBase & Parent
Owning ParamBase instance.
Definition Object.h:396
void DisableUserEditable() noexcept
Sets the UserEditable property to false.
Definition Object.h:393
Abstract base class for a single object parameter. Parameters derived from this class are automatical...
Definition Object.h:378
bool IsUserEditable() const noexcept
Returns ParamBase::UserEditable.
Definition Object.h:427
ParamsBaseOnlyType ParamsBaseOnly
Provides the class ParamsBase access to some private members of class ParamBase.
Definition Object.h:460
const bool NeedsResetToApplyChange
Indicates whether the object owning this parameter needs to be reset to apply changes to this paramet...
Definition Object.h:513
auto & GetOwner() noexcept
Returns the ParamsBase instance owning this ParamBase instance.
Definition Object.h:464
const std::string_view ParamTitle
String which is displayed as a label when editing the parameter using ParamsConfigDialog.
Definition Object.h:507
const auto & GetOwner() const noexcept
Returns the ParamsBase instance owning this ParamBase instance.
Definition Object.h:463
bool GetNeedsResetToApplyChange() const noexcept
Returns ParamBase::NeedsResetToApplyChange.
Definition Object.h:431
std::string_view GetParamTitle() const noexcept
Returns ParamBase::ParamTitle.
Definition Object.h:429
std::string_view GetParamName() const noexcept
Returns ParamBase::ParamName.
Definition Object.h:428
const std::string_view ParamDescription
String which describes the parameter as a tooltip when using ParamsConfigDialog.
Definition Object.h:508
virtual void ResetChild()=0
Resets this parameter to its default value.
void DisableUserEditable() noexcept
Sets the UserEditable property to false.
Definition Object.h:470
virtual void AddToDialogChild(ParamsConfigDialog &Dialog)=0
Appends this parameter to a settings dialog making it configurable by the user.
virtual void FromXMLNodeChild(const QDomElement &XMLElement)=0
Restores this parameter's value from the given Qt dom element (describing an XML node)
ParamBase(const ParamBase &)=delete
ParamsBase & Owner
Owner of this parameter. Owner always lives longer than this object.
Definition Object.h:498
bool UserEditable
Is this parameter displayed in a settings dialog und thus editable by the user directly?...
Definition Object.h:504
void Reset()
Resets this parameter to its default value.
Definition Object.h:458
virtual bool ValidateChild() const
Checks whether a valid value is assigned to this parameter. This function is not const since it is al...
Definition Object.h:491
std::string_view GetParamDescription() const noexcept
Returns ParamBase::ParamDescription.
Definition Object.h:430
virtual void ToXMLNodeChild(QDomDocument &Document, QDomElement &XMLElement) const =0
Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name ...
void AddToDialog(ParamsConfigDialog &Dialog)
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:476
ParamBase & operator=(const ParamBase &)=delete
const std::string ParamName
Identifier which is stored in project file.
Definition Object.h:506
Param(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, ArithmeticType DefaultValue=ArithmeticType(), ArithmeticType MinValue=std::numeric_limits< ArithmeticType >::lowest(), ArithmeticType MaxValue=std::numeric_limits< ArithmeticType >::max(), ArithmeticType Increment=1, PrecisionType Precision=0)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:814
const PrecisionType Precision
Value precision (used in the settings dialog for manual parameter adjustment)
Definition Object.h:864
Param(ParamsBase &Owner, std::string ParamName, ArithmeticType DefaultValue=ArithmeticType(), ArithmeticType MinValue=std::numeric_limits< ArithmeticType >::lowest(), ArithmeticType MaxValue=std::numeric_limits< ArithmeticType >::max(), ArithmeticType Increment=1, PrecisionType Precision=0)
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:828
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:850
ArithmeticType GetMinValue() const noexcept
Returns the minimal allowed value.
Definition Object.h:838
ArithmeticType GetMaxValue() const noexcept
Returns the maximal allowed value.
Definition Object.h:839
const ArithmeticType Increment
Value increment (used in the settings dialog for manual parameter adjustment)
Definition Object.h:863
const EnumType operator=(const EnumType &NewValue)
Assigns a new value to this parameter. Attention: operator= can change the parameter to a value which...
Definition Object.h:1097
EnumType GetDefaultValue() const noexcept
Returns the default value of this parameter.
Definition Object.h:1075
Param(ParamsBase &Owner, Util::TextValueListType< EnumType > &&TextValueList, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, EnumType DefaultValue=EnumType())
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1055
const auto & GetTextValueList() const noexcept
Returns the selection options as a mapping between strings and corresponding EnumType's items.
Definition Object.h:1077
const Util::TextValueListType< EnumType > TextValueList
Predefined selection options.
Definition Object.h:1111
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1105
const EnumType Get() const noexcept
Returns the selected EnumType's item of this parameter.
Definition Object.h:1089
Param(ParamsBase &Owner, std::string ParamName, EnumType DefaultValue=EnumType())
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:1063
LinkType Link
Link of type LinkType derived from ObjectLinkBase referring to the linked Object. The link can be loc...
Definition Object.h:1277
const ManagerType & Manager
Reference to the manager instance containing the Object the link refers to. Managers live longer than...
Definition Object.h:1271
void EnsureReadyStateChild() override final
Thread-safe since only main thread is allowed to change parameters and to call this funtion.
Definition Object.h:1234
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1222
Param(ParamsBase &Owner, const ManagerType &Manager, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, std::string_view IconResourcePath={}, bool Optional=false, bool NeedsResetToApplyChange=true)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1161
bool IsReadyChild() override final
Returns whether the object where this link parameter points to is in a ready state.
Definition Object.h:1244
const LinkType & GetLink() const noexcept
Returns the link of type LinkType derived from ObjectLinkBase to the Object the parameter refers to.
Definition Object.h:1189
const auto & GetManager() const noexcept
Returns the manager instance containing the Object the link refers to.
Definition Object.h:1176
ManagerTypeOfObjectType_t< ObjectType > ManagerType
Type of the manager managing the linked Object.
Definition Object.h:1154
virtual void FromXMLNodeChild(const QDomElement &XMLElement) override
Restores this parameter's value from the given Qt dom element (describing an XML node)
Definition Object.h:1216
bool ContainsID() const noexcept
Checks whether an item has been assigned to this parameter.
Definition Object.h:1182
virtual const CommonResourceManagerBase * GetCommonManagerChild() const noexcept override
This function can be used to determine the object type the parameter is expecting by comparing the re...
Definition Object.h:1214
void MakeLink()
Retrives the linked resource using its ID stored in the parameter and establishes a link to the resou...
Definition Object.h:1198
Param(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, ParamType DefaultValue=ParamType())
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:774
Param(ParamsBase &Owner, std::string ParamName, UnderlyingTextParamType::UnderlyingType DefaultValue="")
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:892
std::filesystem::path GetPath() const
Returns the parameter's value as a path. Relative paths are resolved using ParamsBase::ToAbsolutePath...
Definition Object.h:899
auto GetTextUsage() const noexcept
Returns the purpose of this parameter's text.
Definition Object.h:905
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:911
Param(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, UnderlyingTextParamType::UnderlyingType DefaultValue="", TextUsageType TextUsage=TextUsageType::Standard)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:884
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:968
Param(ParamsBase &Owner, Util::TextListType &&TextList, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, UnderlyingTextListParamType::UnderlyingType DefaultValue="")
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:934
Util::TextListType TextList
Predefined selection options. Not constant because this should be changeable dynamically (e....
Definition Object.h:980
const auto & GetTextList() const noexcept
Returns the predefined selection options as a list of strings.
Definition Object.h:952
void SetTextList(Util::TextListType &&NewTextList)
Resets the predefined list of strings to select a string from.
Definition Object.h:964
Param(ParamsBase &Owner, Util::TextListType &&TextList, std::string ParamName, UnderlyingTextListParamType::UnderlyingType DefaultValue="")
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:943
const auto & GetTextList() const noexcept
Returns the predefined selection options as a list of strings.
Definition Object.h:1019
Param(ParamsBase &Owner, Util::TextListType &&TextList, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, UnderlyingIndexedTextListParamType::UnderlyingType DefaultValue=0)
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:1001
virtual bool ValidateValue(const ParamType &Value) const override
Called by ValidateChild(). Validates a single value. Override to validate the value which is about to...
Definition Object.h:1029
virtual void AddToDialogChild(ParamsConfigDialog &Dialog) override final
Appends this parameter to a settings dialog making it configurable by the user.
Definition Object.h:1023
Param(ParamsBase &Owner, Util::TextListType &&TextList, std::string ParamName, UnderlyingIndexedTextListParamType::UnderlyingType DefaultValue=0)
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:1010
Base class of parameters containing lists of values.
Definition Object.h:632
const auto & GetDefaultValue() const noexcept
Returns this parameter's default value list. Thread-safe since a reference to a const member variable...
Definition Object.h:662
auto & operator=(const UnderlyingType &NewValues)
Assigns new values to this parameter. The operator cannot be accessed by Object because this function...
Definition Object.h:678
const UnderlyingType DefaultValues
Values to assign to the parameter upon construction and reset.
Definition Object.h:745
UnderlyingType Values
Current parameter values.
Definition Object.h:746
std::vector< ParamType > UnderlyingType
List type to be used for the parameter.
Definition Object.h:637
TypedListParamBase(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, UnderlyingType DefaultValues={})
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:644
virtual void ResetChild() override
Resets this parameter to its default value.
Definition Object.h:743
TypedListParamBase(ParamsBase &Owner, std::string ParamName, UnderlyingType DefaultValues={})
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:653
virtual void ToXMLNodeChild(QDomDocument &Document, QDomElement &XMLElement) const override
Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name ...
Definition Object.h:689
virtual bool ValidateValues(const UnderlyingType &NewValues) const
Called by ValidateChild(). Validates a list of values. Override to validate the vector which is about...
Definition Object.h:741
const auto & Get() const noexcept
Returns the parameter's values.
Definition Object.h:668
virtual void FromXMLNodeChild(const QDomElement &XMLElement) override
Restores this parameter's value from the given Qt dom element (describing an XML node)
Definition Object.h:705
virtual bool ValidateChild() const override final
Checks whether a valid value is assigned to this parameter. This function is not const since it is al...
Definition Object.h:733
Base class of parameters containing a single value.
Definition Object.h:539
const ParamType DefaultValue
Value to assign to the parameter upon construction and reset.
Definition Object.h:622
ParamType Value
Current parameter value.
Definition Object.h:623
TypedParamBase(ParamsBase &Owner, std::string ParamName, std::string_view ParamTitle, std::string_view ParamDescription, bool NeedsResetToApplyChange=true, ParamType DefaultValue=ParamType())
Base constructor of any parameter to be used if a parameter should be displayed in a settings dialog ...
Definition Object.h:548
const ParamType & Get() const noexcept
Returns the parameter's value.
Definition Object.h:577
virtual void FromXMLNodeChild(const QDomElement &XMLElement) override
Restores this parameter's value from the given Qt dom element (describing an XML node)
Definition Object.h:604
virtual void ResetChild() override
Resets this parameter to its default value.
Definition Object.h:620
virtual bool ValidateValue(const ParamType &NewValue) const
Called by ValidateChild(). Validates a single value. Override to validate the value which is about to...
Definition Object.h:618
const ParamType & operator=(const ParamType &NewValue)
Assigns a new value to this parameter. The operator cannot be accessed by Object because this functio...
Definition Object.h:587
virtual bool ValidateChild() const override final
Checks whether a valid value is assigned to this parameter. This function is not const since it is al...
Definition Object.h:610
ParamType GetDefaultValue() const noexcept
Returns this parameter's default value. Thread-safe since a const member variable is returned.
Definition Object.h:566
virtual void ToXMLNodeChild(QDomDocument &Document, QDomElement &XMLElement) const override
Converts this parameter to a Qt dom element (describing an XML node containing this parameter's name ...
Definition Object.h:598
TypedParamBase(ParamsBase &Owner, std::string ParamName, ParamType DefaultValue=ParamType())
Base constructor of any parameter to be used if a parameter should not be displayed in a settings dia...
Definition Object.h:557
Abstract base class for object parameter classes. Each class derived from class Object must be accomp...
Definition Object.h:326
const auto & GetObjectLinkParams() const noexcept
Returns a list of all object link parameters owned by this parameter class instance.
Definition Object.h:1678
virtual const char * GetParamClassTag() const noexcept
This function is intended to be overridden once in each derived class returning the name of the respe...
Definition Object.h:1643
const char *const ClassTag
Denotes the result of GetParamClassTag() of the class where the respective OwnedParam was declared in...
Definition Object.h:1695
std::conditional_t< std::is_signed_v< std::underlying_type_t< EnumType > >, EnumParamSignedIntegerType, EnumParamUnsignedIntegerType > LargestEnumUnderlyingType
Type trait providing an integer type for enumeration types which allows to store the value of enumera...
Definition Object.h:366
std::vector< std::reference_wrapper< LinkBase > > ObjectLinkParamsType
Type of a list of all owned object link parameters.
Definition Object.h:352
bool ConfigureUsageType() const noexcept
Determines whether the Usage parameter should be configurable in the settings dialog....
Definition Object.h:1733
virtual void ConfigureParamsImpl(dispatch_tag< ParamsBase >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition Object.h:1762
const auto & GetCore() const noexcept
Returns a reference to DynExp's core.
Definition Object.h:1677
ItemIDType GetID() const noexcept
Returns the ID of the Object this parameter class instance belongs to.
Definition Object.h:1676
const NetworkParamsExtension * GetNetworkAddressParams() const noexcept
Returns the network address parameters of a derived gRPC instrument. Override GetNetworkAddressParams...
Definition Object.h:1741
OwnedParamsType OwnedParams
List of all parameters owned by this parameter class instance.
Definition Object.h:1712
virtual const NetworkParamsExtension * GetNetworkAddressParamsChild() const noexcept
Returns the network address parameters of a derived gRPC instrument. Override GetNetworkAddressParams...
Definition Object.h:1772
std::vector< OwnedParamInfo > OwnedParamsType
List type of information on parameters owned by this ParamsBase instance (and its derived classes)
Definition Object.h:333
uintmax_t EnumParamUnsignedIntegerType
Parameter type to convert unsigned eumeration parameters to.
Definition Object.h:354
intmax_t EnumParamSignedIntegerType
Parameter type to convert signed eumeration parameters to.
Definition Object.h:353
ParamsBase(ItemIDType ID, const DynExpCore &Core)
Constructs the base class of an object parameter class.
Definition Object.h:1629
UsageType
Determines whether an Object can be linked to only one (unique) or multiple (shared) other objects.
Definition Object.h:1614
ObjectLinkParamsType ObjectLinkParams
List of all object link parameters owned by this parameter class instance.
Definition Object.h:1713
const ItemIDType ID
ID of the Object this parameter class instance belongs to.
Definition Object.h:1779
virtual bool ConfigureUsageTypeChild() const noexcept
Determines whether the Usage parameter should be configurable in the settings dialog....
Definition Object.h:1767
Util::TextType Text
" String type of text-type parameters (DynExp::ParamsBase::Param) "
Definition Object.h:368
const DynExpCore & Core
Reference to DynExp's core.
Definition Object.h:1780
const std::reference_wrapper< ParamBase > OwnedParam
Reference to the parameter.
Definition Object.h:1700
Type to identify an indexed text list parameter (one number selected from a list of numbers associate...
Definition Object.h:370
Type to identify a text list parameter (one string selected from a list of strings)
Definition Object.h:369
Helper type owning a reference to a parameter and its class tag.
Definition Object.h:1691
Tag for function dispatching mechanism within this class used when derived classes are not intended t...
Definition Object.h:349
Defines data for a thread belonging to a RunnableObject instance. This data is only accessed by the R...
Definition Object.h:3505
LinkedObjectWrapperBase::ListType OwnedLinkedObjectWrappers
List of all LinkedObjectWrapper instances owned by this RunnableInstance instance (thus belonging to ...
Definition Object.h:3726
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
Definition Object.h:3671
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
Definition Object.h:3570
void LockObject(const ParamsBase::ListParam< ObjectLink< ObjectT > > &LinkListParam, LinkedObjectWrapperContainerList< ObjectT > &ObjectWrapperContainerList, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks Object instances referenced by a list parameter LinkListParam of type ParamsBase::ListParam< Ob...
Definition Object.h:3598
void TryLockObject(const ParamsBase::Param< ObjectLink< ObjectT > > &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
Definition Object.h:3537
decltype(auto) StoreLockedObject(std::unique_ptr< LinkedObjectWrapper< ObjectT > > &&ObjectWrapperPtr, LinkedObjectWrapperContainerBase &ObjectWrapperContainer)
Stores a newly created LinkedObjectWrapper instance in OwnedLinkedObjectWrappers.
Definition Object.h:3689
void UnlockObject(LinkedObjectWrapperContainerList< ObjectT > &ObjectWrapperContainerList)
Unlocks Object instances stored in the LinkedObjectWrapperContainerList ObjectWrapperContainerList.
Definition Object.h:3642
const RunnableObject & Owner
RunnableObject instance which operates on this RunnableInstance (by its thread). The RunnableObject i...
Definition Object.h:3705
std::promise< void > ThreadExitedPromise
Signals the RunnableObject instance owning the thread that its thread has terminated....
Definition Object.h:3712
void LockObject(const ParamsBase::Param< ObjectLink< ObjectT > > &LinkParam, LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer, std::chrono::milliseconds Timeout=ObjectLinkBase::LockObjectTimeoutDefault)
Locks an Object instance referenced by a parameter LinkParam of type ParamsBase::Param< ObjectLink< O...
Definition Object.h:3554
const auto & GetOwner() const noexcept
Returns Owner.
Definition Object.h:3524
Configurator class for RunnableObject.
Definition Object.h:2412
Parameter class for RunnableObject.
Definition Object.h:2349
virtual void ConfigureParamsImpl(dispatch_tag< RunnableObjectParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition Object.h:2398
bool ConfigureStartupType() const noexcept
Determines whether the Startup parameter should be user-configurable in settings dialogs....
Definition Object.h:2394
StartupType
Determines when a RunnableObject instance is started.
Definition Object.h:2354
virtual bool ConfigureStartupTypeChild() const noexcept
Determines whether the Startup parameter should be user-configurable in settings dialogs....
Definition Object.h:2404
RunnableObjectParams(ItemIDType ID, const DynExpCore &Core)
Constructs the base class of an object parameter class.
Definition Object.h:2371
virtual const char * GetParamClassTag() const noexcept override
This function is intended to be overridden once in each derived class returning the name of the respe...
Definition Object.h:2375
Exception type thrown by TerminateImpl() if the RunnableObject cannot be terminated for being used by...
Definition Object.h:2454
NotUnusedException(const RunnableObject &Parent)
Constructs an exception instance. Initializes UserNames with the content of ObjectUserList::GetUserNa...
Definition Object.h:2461
std::string_view GetUserNames() const
Getter for UserNames.
Definition Object.h:2467
std::string UserNames
String with identifiers of the Object instances making use of the throwing RunnableObject instance.
Definition Object.h:2479
Allow exclusive access to some of RunnableObject's private methods to class RunnableInstance.
Definition Object.h:2431
void OnThreadHasExited() const noexcept
This function is called when the RunnableObject instance's thread terminates. The thread receives a R...
Definition Object.h:2441
bool IsLinkedObjStateCheckRequested() const noexcept
Indicates whether the RunnableInstance instance belonging to this RunnableObject instance's thread sh...
Definition Object.h:2442
RunnableObject & Parent
Owning RunnableObject instance.
Definition Object.h:2445
constexpr RunnableInstanceOnlyType(RunnableObject &Parent) noexcept
Construcs an instance - one for each RunnableObject instance.
Definition Object.h:2439
void ResetLinkedObjStateCheckRequested() const noexcept
Sets RunnableObject::LinkedObjStateCheckRequested to false.
Definition Object.h:2443
Defines an Object which possesses a thread it runs in. The RunnableObject can be started and stopped ...
Definition Object.h:2426
virtual std::unique_ptr< BusyDialog > MakeStartupBusyDialogChild(QWidget *ParentWidget) const
Override to make this function return a pointer to a BusyDialog instance. Refer to Run().
Definition Object.h:2646
auto GetStartupType() const noexcept
Returns Startup.
Definition Object.h:2554
virtual void NotifyChild()
Notify derived classes that some state has changed (e.g. the termination of Thread is requested) and ...
Definition Object.h:2629
virtual void RunChild()=0
Refer to Run().
void SetReasonWhyPaused(const Util::Exception &e)
Sets the reason why this RunnableObject instance has been paused.
Definition Object.h:2605
void CheckLinkedObjectStatesChild() const override final
Override to implement a check whether linked objects are in a ready state.
Definition Object.h:2617
bool IsExiting() const noexcept
Returns ShouldExit.
Definition Object.h:2552
bool IsPaused() const noexcept
Returns Paused.
Definition Object.h:2551
virtual void ResetImpl(dispatch_tag< RunnableObject >)=0
Refer to DynExp::Object::Reset(). Using tag dispatch mechanism to ensure that ResetImpl() of every de...
RunnableInstanceOnlyType RunnableInstanceOnly
Allow exclusive access to some of RunnableObject's private methods to class RunnableInstance.
Definition Object.h:2557
auto GetReasonWhyPaused() const
Returns ReasonWhyPaused.
Definition Object.h:2555
void ClearReasonWhyPaused()
Removes the reason why this RunnableObject instance has been paused (since it is resumed).
Definition Object.h:2610
void SetReasonWhyPaused(std::string Description)
Sets the reason why this RunnableObject instance has been paused.
Definition Object.h:2599
bool IsRunning() const noexcept
Returns Running.
Definition Object.h:2550
virtual void TerminateChild(const std::chrono::milliseconds Timeout)
Signals derived classes that terminating the RunnableObject instance's thread is about to be requeste...
Definition Object.h:2638
Defines the configuration dialog. The dialog must be displayed by calling ParamsConfigDialog::Display...
Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWr...
Definition Util.h:448
Thrown when a list is expected to contain entries and when a query results in an empty answer or an e...
Definition Exception.h:224
void Log(const std::string &Message, const ErrorType Type=ErrorType::Info, const size_t Line=0, const std::string &Function="", const std::string &File="", const int ErrorCode=0, const std::stacktrace &Trace={}) noexcept
Logs an event from information specified manually.
Definition Util.cpp:309
DynExp exceptions are derived from this class. It contains basic information about the cause of the e...
Definition Exception.h:51
Class to forward an Exception instance from one DynExp::Object instance to another DynExp::Object ins...
Definition Exception.h:126
Interface to allow synchronizing the access to derived classes between different threads by providing...
Definition Util.h:56
std::unique_lock< MutexType > LockType
Definition Util.h:66
static constexpr std::chrono::milliseconds DefaultTimeout
Duration which is used as a default timeout within all methods of this class if no different duration...
Definition Util.h:62
Interface to delete copy constructor and copy assignment operator and thus make derived classes non-c...
Definition Util.h:23
An invalid argument like a null pointer has been passed to a function.
Definition Exception.h:137
Thrown when RunnableInstance cannot lock an object to be used by another object due to an invalid lin...
Definition Exception.h:344
An operation cannot be performed currently since the related object is in an invalid state like an er...
Definition Exception.h:150
Thrown when RunnableInstance::LockObject() has not been called on an object link parameter to establi...
Definition Exception.h:329
Thrown when a requested ressource does not exist.
Definition Exception.h:236
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Definition Exception.h:299
Thrown when an argument passed to a function exceeds the valid range.
Definition Exception.h:211
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:170
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
Definition Exception.h:261
Thrown when an attempt was made to convert two incompatible types into each other.
Definition Exception.h:248
Class to store information about warnings in a thread-safe manner (deriving from ILockable)....
Definition Util.h:966
DynExp's main namespace contains the implementation of DynExp including classes to manage resources (...
std::conditional_t< std::is_base_of_v< HardwareAdapterBase, ObjectType >, HardwareAdapterManager, InstrumentManager > type
Resource manager type managing instances of type ObjectType.
Definition Object.h:63
TextUsageType
Specifies the usage of a text-type parameter. Setting the right usage allows the ParamsConfigDialog t...
ParamsBasePtrType MakeParams(ItemIDType ID, const DynExpCore &Core)
Factory function to generate an Object's parameters.
Definition Object.h:1818
auto operator<=>(const ParamsBase::TypedParamBase< ParamType > &lhs, const ParamType &rhs)
Provides three-way comparison for two parameters.
Definition Object.h:1802
std::vector< ItemIDType > ItemIDListType
Type of a list of IDs belonging to objects managed by DynExp.
Definition Object.h:40
auto operator==(const ParamsBase::TypedParamBase< ParamType > &lhs, const ParamType &rhs)
Provides (in)equality comparison operators for two parameters. Since C++20, inequality operators (ope...
Definition Object.h:1792
std::unique_ptr< ParamsBase > ParamsBasePtrType
Alias for a pointer to the parameter system base class ParamsBase.
Definition Object.h:1807
size_t ItemIDType
ID type of objects/items managed by DynExp.
typename ManagerTypeOfObjectType< ObjectType >::type ManagerTypeOfObjectType_t
Alias for a resource manager type (derived from DynExp::CommonResourceManagerBase) managing resources...
Definition Object.h:72
auto dynamic_Object_cast(From *Obj)
Casts an Object to a derived type.
Definition Object.h:2333
std::shared_ptr< ConfiguratorBase > ConfiguratorBasePtrType
Alias for a pointer to the configurator base class ConfiguratorBase.
Definition Object.h:1959
T::ParamsType * dynamic_Params_cast(ParamsBasePtrType::element_type *Params)
Casts the parameter base class to a derived Object's parameter class.
Definition Object.h:1835
Type trait relating a type ObjectType derived from either class HardwareAdapterBase or class Instrume...
Definition Object.h:55
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
Definition Util.h:625
std::vector< TextType > TextListType
List type of text-type parameters.
Definition QtUtil.h:29
QDomElement GetSingleChildDOMElement(const QDomElement &Parent, const QString &ChildTagName)
Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element.
Definition QtUtil.cpp:62
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
Definition Util.cpp:509
std::vector< QDomNode > GetChildDOMNodes(const QDomElement &Parent, const QString &ChildTagName)
Finds child nodes with a certain tag name.
Definition QtUtil.cpp:19
std::string TextType
String type of text-type parameters (DynExp::ParamsBase::Param)
Definition QtUtil.h:27
std::vector< std::pair< TextType, ValueType > > TextValueListType
Type of a list containing key-value pairs where key is a text of type Util::TextType.
Definition QtUtil.h:37
Accumulates include statements to provide a precompiled header.
Return type of ConfiguratorBase::UpdateConfigFromDialog() indicating the result of the configurator d...
Definition Object.h:1889
constexpr bool IsResetRequired() const noexcept
Checks whether the corresponding Object has to be reset to apply changed parameters.
Definition Object.h:1904
constexpr UpdateConfigFromDialogResult(bool Accepted, bool ResetRequired) noexcept
Constructs an UpdateConfigFromDialogResult instance.
Definition Object.h:1895
const bool Accepted
Has the dialog been accepted clicking 'OK'?
Definition Object.h:1907
constexpr bool IsAccepted() const noexcept
Returns UpdateConfigFromDialogResult::Accepted.
Definition Object.h:1898
const bool ResetRequired
Has the user changed settings which require resetting the corresponding Object?
Definition Object.h:1908
Helper type linking a LinkedObjectWrapperBasePtrType to the corresponding LinkedObjectWrapperContaine...
Definition Object.h:2722
LinkedObjectWrapperBasePtrType OwnedLinkedObjectWrapperPtr
Pointer owning an instance of LinkedObjectWrapperBase.
Definition Object.h:2736
LinkedObjectWrapperContainerBase & OwnedLinkedObjectWrapperContainer
Reference to a LinkedObjectWrapperContainerBase instance holding a non-owning pointer to the instance...
Definition Object.h:2742
OwnedLinkedObjectWrapperType(LinkedObjectWrapperBasePtrType &&OwnedLinkedObjectWrapperPtr, LinkedObjectWrapperContainerBase &OwnedLinkedObjectWrapperContainer)
Constructs a OwnedLinkedObjectWrapperType instance.
Definition Object.h:2728
Defines a DynExp resource, which mainly owns a DynExp::Object instance wrapping a pointer to it.
Definition Managers.h:24