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
2012 static std::string RemoveCategoryAndName(const std::string& ObjectDesc);
2013
2018 static constexpr std::chrono::milliseconds GetParamsTimeoutDefault = std::chrono::milliseconds(100);
2019
2020 protected:
2025 template <typename>
2026 struct dispatch_tag {};
2027
2035 Object(const std::thread::id OwnerThreadID, ParamsBasePtrType&& Params);
2036
2037 virtual ~Object() = 0;
2038
2039 private:
2044 {
2045 friend class Object;
2046
2047 template <typename>
2049
2054 constexpr LinkedObjectWrapperOnlyType(Object& Parent) noexcept : Parent(Parent) {}
2055
2061
2068 void RegisterUser(const Object& User, const std::chrono::milliseconds Timeout) const;
2069
2073 void DeregisterUser(const Object& User, const std::chrono::milliseconds Timeout) const;
2075
2077 };
2078
2079 public:
2086
2093 void Reset();
2094
2102 void BlockIfUnused(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout);
2104
2109
2116 ParamsConstTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const;
2117
2122 using ParamsGetterType = Util::CallableMemberWrapper<Object, decltype(&Object::GetParams)>;
2123
2129 ParamsTypeSyncPtrType GetParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault);
2130
2136 auto GetObjectName(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const { return GetParams(Timeout)->ObjectName.Get(); }
2137
2144 bool IsSharedUsageEnabled(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const { return GetParams(Timeout)->Usage == ParamsType::UsageType::Shared; }
2146
2151 ItemIDType GetID() const noexcept { return Params->GetID(); }
2152
2158 virtual std::string GetName() const = 0;
2159 virtual std::string GetCategory() const = 0;
2161
2166 std::string GetCategoryAndName() const { return CategoryAndNameToStr(GetCategory(), GetName()); }
2167
2175 void EnsureReadyState(bool IsAutomaticStartup);
2176
2181
2186 void SetWarning(std::string Description, int ErrorCode) const;
2187
2193 void SetWarning(const Util::Exception& e) const;
2194
2198 void ClearWarning() const { Warning.Reset(); }
2199
2204 auto GetWarning() const { return Warning.Get(); }
2205
2212 std::exception_ptr GetException(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return GetExceptionChild(Timeout); }
2213
2219 bool IsReady() const { return !IsBlocked && IsReadyChild(); }
2220
2224 auto GetUseCount(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.CountUsers(Timeout); }
2225
2231 bool IsUnused(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return GetUseCount(Timeout) == 0; }
2232
2236 auto GetUserIDs(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.GetUserIDs(Timeout); }
2237
2241 auto GetUserNamesString(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) const { return UserList.GetUserNamesString(Timeout); }
2243
2248 void CheckLinkedObjectStates() const { CheckLinkedObjectStatesChild(); };
2249
2251
2252 protected:
2258 void EnsureCallFromOwningThread() const;
2259
2266 ParamsTypeSyncPtrType GetNonConstParams(const std::chrono::milliseconds Timeout = GetParamsTimeoutDefault) const;
2267
2272 auto LockUserList(const std::chrono::milliseconds Timeout = Util::ILockable::DefaultTimeout) { return UserList.AcquireLock(Timeout); }
2273 void DeregisterAllUnsafe() { UserList.DeregisterAllUnsafe(); }
2274 auto GetUseCountUnsafe() { return UserList.CountUsersUnsafe(); }
2275 auto GetUserNamesStringUnsafe() const { return UserList.GetUserNamesStringUnsafe(); }
2276
2281 bool IsUnusedUnsafe() { return GetUseCountUnsafe() == 0; }
2283
2284 private:
2289
2294
2295 virtual std::exception_ptr GetExceptionChild(const std::chrono::milliseconds Timeout) const = 0;
2296 virtual void EnsureReadyStateChild(bool IsAutomaticStartup) = 0;
2297 virtual bool IsReadyChild() const = 0;
2298
2302 virtual void CheckLinkedObjectStatesChild() const {};
2304
2308 void LogWarning() const;
2309
2310 const std::thread::id OwnerThreadID;
2312
2314
2321
2328 bool IsBlocked = false;
2329 };
2330
2338 template <typename To, typename From, std::enable_if_t<
2339 std::is_base_of_v<Object, To> && std::is_base_of_v<Object, From>, int> = 0
2340 >
2341 auto dynamic_Object_cast(From* Obj)
2342 {
2343 if (!Obj)
2344 throw Util::InvalidArgException("Obj must not be nullptr.");
2345
2346 auto DerivedObj = dynamic_cast<std::conditional_t<std::is_const_v<From>, std::add_const_t<To>*, To*>>(Obj);
2347 if (!DerivedObj)
2349
2350 return DerivedObj;
2351 }
2352
2357 {
2358 public:
2362 enum StartupType { OnCreation, Automatic, Manual };
2380
2381 virtual ~RunnableObjectParams() = 0;
2382
2383 virtual const char* GetParamClassTag() const noexcept override { return "RunnableObjectParams"; }
2384
2389 static Util::TextValueListType<StartupType> AvlblStartupTypeStrList();
2390
2394 Param<StartupType> Startup = { *this, AvlblStartupTypeStrList(), "Startup", "Startup type",
2395 "Determines when the item is started", false, StartupType::Automatic };
2396
2402 bool ConfigureStartupType() const noexcept { return ConfigureStartupTypeChild(); }
2403
2404 private:
2405 void ConfigureParamsImpl(dispatch_tag<ParamsBase>) override final;
2407
2412 virtual bool ConfigureStartupTypeChild() const noexcept { return true; }
2414 };
2415
2428
2434 {
2439 {
2440 friend class RunnableObject;
2441 friend class RunnableInstance;
2442
2447 constexpr RunnableInstanceOnlyType(RunnableObject& Parent) noexcept : Parent(Parent) {}
2448
2449 void OnThreadHasExited() const noexcept { Parent.OnThreadHasExited(); }
2450 bool IsLinkedObjStateCheckRequested() const noexcept { return Parent.LinkedObjStateCheckRequested; }
2451 void ResetLinkedObjStateCheckRequested() const noexcept { Parent.LinkedObjStateCheckRequested = false; }
2452
2454 };
2455
2456 public:
2462 {
2463 public:
2469 NotUnusedException(const RunnableObject& Parent) : UserNames(Parent.GetUserNamesStringUnsafe()) {}
2470
2475 std::string_view GetUserNames() const { return UserNames; }
2476
2481 std::string GetErrorMessage() const;
2482
2483 private:
2487 std::string UserNames;
2488 };
2489
2492
2497 static constexpr auto ShortTimeoutDefault = std::chrono::milliseconds(50);
2498
2502 static constexpr auto TerminateTimeoutDefault = std::chrono::milliseconds(3000);
2503
2504 RunnableObject(const std::thread::id OwnerThreadID, ParamsBasePtrType&& Params);
2505 virtual ~RunnableObject() = 0;
2506
2511
2522 bool Run(QWidget* ParentWidget = nullptr);
2523
2531 bool RunIfRunAutomatic();
2532
2538 bool RunIfRunOnCreation();
2539
2546 void Terminate(bool Force = false, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2548
2556 void SetPaused(bool Pause, std::string Description = "");
2557
2558 bool IsRunning() const noexcept { return Running; }
2559 bool IsPaused() const noexcept { return Paused; }
2560 bool IsExiting() const noexcept { return ShouldExit; }
2561
2562 auto GetStartupType() const noexcept { return Startup.load(); }
2563 auto GetReasonWhyPaused() const { return ReasonWhyPaused.Get(); }
2564
2566
2567 protected:
2571 using ThreadFuncType = std::function<int(std::unique_ptr<RunnableInstance>&&, RunnableObject*)>;
2572
2573 void Init();
2574
2581 std::promise<void> MakeThreadExitedPromise();
2582
2591 void MakeThread(ThreadFuncType ThreadFunc, std::unique_ptr<RunnableInstance>&& InstancePtr);
2592
2602 bool IsCallFromRunnableThread() const;
2603
2609 void EnsureCallFromRunnableThread() const;
2610
2615 void SetReasonWhyPaused(std::string Description) { ReasonWhyPaused = Util::Warning(std::move(Description)); }
2616
2621 void SetReasonWhyPaused(const Util::Exception& e) { ReasonWhyPaused = e; }
2622
2626 void ClearReasonWhyPaused() { ReasonWhyPaused.Reset(); }
2627
2628 private:
2629 void ResetImpl(dispatch_tag<Object>) override final;
2631
2632 void EnsureReadyStateChild(bool IsAutomaticStartup) override final;
2633 void CheckLinkedObjectStatesChild() const override final { LinkedObjStateCheckRequested = true; }
2634
2639 virtual void RunChild() = 0;
2640
2645 virtual void NotifyChild() {}
2646
2654 virtual void TerminateChild(const std::chrono::milliseconds Timeout) {}
2655
2662 virtual std::unique_ptr<BusyDialog> MakeStartupBusyDialogChild(QWidget* ParentWidget) const { return nullptr; }
2664
2672 void TerminateImpl(bool Force, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2673
2681 void TerminateUnsafe(bool Force, const std::chrono::milliseconds Timeout = TerminateTimeoutDefault);
2682
2690 void OnThreadHasExited() noexcept;
2691
2696 std::atomic<RunnableObjectParams::StartupType> Startup = RunnableObjectParams::StartupType::Automatic;
2697
2698 std::thread Thread;
2699 std::future<void> ThreadExitedSignal;
2700 std::atomic<bool> Running;
2701 std::atomic<bool> Paused;
2702 Util::Warning ReasonWhyPaused;
2703
2709 std::atomic<bool> ShouldExit;
2711
2716 mutable std::atomic<bool> LinkedObjStateCheckRequested = false;
2717 };
2718
2723 class LinkedObjectWrapperBase : public Util::INonCopyable
2724 {
2725 friend class RunnableInstance;
2726
2727 private:
2731 using LinkedObjectWrapperBasePtrType = std::unique_ptr<LinkedObjectWrapperBase>;
2732
2738 {
2745 LinkedObjectWrapperContainerBase& OwnedLinkedObjectWrapperContainer)
2746 : OwnedLinkedObjectWrapperPtr(std::move(OwnedLinkedObjectWrapperPtr)),
2747 OwnedLinkedObjectWrapperContainer(OwnedLinkedObjectWrapperContainer) {}
2748
2753
2759 };
2760
2766 using ListType = std::list<OwnedLinkedObjectWrapperType>;
2767
2768 public:
2773 LinkedObjectWrapperBase(const RunnableInstance& Owner) : Owner(Owner) {}
2774
2775 virtual ~LinkedObjectWrapperBase() = 0;
2776
2781
2786 virtual bool IsRegistered() const noexcept = 0;
2788
2793 const Object& GetOwner() const noexcept;
2794
2795 private:
2800
2805 virtual void Register(const std::chrono::milliseconds Timeout) = 0;
2806
2812 virtual void Deregister(const std::chrono::milliseconds Timeout) = 0;
2813
2819 ListType::const_iterator ListPos;
2821
2825 const RunnableInstance& Owner;
2826 };
2827
2837 template <typename ObjectT>
2839 {
2840 public:
2841 using ObjectType = std::add_const_t<ObjectT>;
2842
2849 LinkedObjectWrapper(const RunnableInstance& Owner, std::shared_ptr<ObjectType>&& DestinyResource, const std::chrono::milliseconds Timeout)
2850 : LinkedObjectWrapperBase(Owner),
2851 DestinyResource(std::move(DestinyResource)), IsRegisteredFlag(false)
2852 {
2853 // Checks for nullptr.
2854 LinkedObjectWrapper::Register(Timeout);
2855 }
2856
2861 {
2862 try
2863 {
2864 LinkedObjectWrapper::Deregister(std::chrono::milliseconds(1000));
2865 }
2866 catch (const Util::TimeoutException& e)
2867 {
2868 Util::EventLog().Log(e);
2869 Util::EventLog().Log("Could not deregister a linked object wrapper. Timeout occurred. Execution cannot continue.",
2871
2872 std::terminate();
2873 }
2874 catch (const Util::Exception& e)
2875 {
2876 Util::EventLog().Log("Could not deregister a linked object wrapper. The error listed below occurred. Execution cannot continue.",
2878 Util::EventLog().Log(e);
2879
2880 std::terminate();
2881 }
2882 catch (const std::exception& e)
2883 {
2884 Util::EventLog().Log("Could not deregister a linked object wrapper. The error listed below occurred. Execution cannot continue.",
2886 Util::EventLog().Log(e.what());
2887
2888 std::terminate();
2889 }
2890 catch (...)
2891 {
2892 Util::EventLog().Log("Could not deregister a linked object wrapper. An unknown error occurred. Execution cannot continue.",
2894
2895 std::terminate();
2896 }
2897 }
2898
2899 virtual bool IsRegistered() const noexcept override { return IsRegisteredFlag; }
2900
2908 std::string GetLinkedObjectDesc() const { return DestinyResource->GetObjectName() + " (" + DestinyResource->GetCategoryAndName() + ")"; }
2909
2916 decltype(auto) get() const { return &this->operator*(); }
2917
2918 decltype(auto) get() { return &this->operator*(); }
2921 const auto& operator*() const
2922 {
2923 // ->
2924 // Checking for errors with
2925
2926 /* if (!DestinyResource->IsReady())
2927 throw Util::InvalidCallException("The requested object is in an invalid state or in an error state."); */
2928
2929 // does not work here, because the OnError() handlers of instruments or modules might call
2930 // functions through a LinkedObjectWrapper to perform shutdown operations. This would not be
2931 // possible with a respective error check taking place here. This is not considered a problem,
2932 // since DestinyResource exists in any case and modifying its underlying Object simply does
2933 // not have an effect or throws an exception itself if Object is not ready. Instead, just
2934 // indiate errors by setting LinkedObjectWrapperContainerBase's LinkedObjectState to NotReady
2935 // (see LinkedObjectWrapperContainer<...>::get()).
2936 // <-
2937
2938 if (!IsRegisteredFlag)
2940 "This linked object wrapper instance is deregistered from the requested object.");
2941
2942 return *DestinyResource.get();
2943 }
2946 auto& operator*()
2947 {
2948 // Call const version of operator*
2949 return const_cast<typename std::shared_ptr<ObjectType>::element_type&>(
2950 static_cast<const LinkedObjectWrapper<ObjectT>&>(*this).operator*());
2953 const auto operator->() const { return &this->operator*(); }
2954 auto operator->() { return &this->operator*(); }
2956 private:
2957 virtual void Register(const std::chrono::milliseconds Timeout) override
2958 {
2959 if (!DestinyResource)
2960 throw Util::InvalidArgException("DestinyResource must not be nullptr.");
2961 if (IsRegisteredFlag)
2962 return;
2963
2964 // Could throw Util::TimeoutException if resource is currently modified (e.g. call to Object::Reset()).
2965 DestinyResource->LinkedObjectWrapperOnly.RegisterUser(GetOwner(), Timeout);
2966
2967 IsRegisteredFlag = true;
2969
2970 virtual void Deregister(const std::chrono::milliseconds Timeout) override
2971 {
2972 if (!IsRegisteredFlag)
2973 return;
2974
2975 DestinyResource->LinkedObjectWrapperOnly.DeregisterUser(GetOwner(), Timeout);
2976
2977 IsRegisteredFlag = false;
2978 }
2979
2984 const std::shared_ptr<ObjectType> DestinyResource;
2985
2990 bool IsRegisteredFlag;
2991 };
2992
2999 template <typename ObjectT>
3001 {
3002 public:
3007
3012
3016 LinkedObjectWrapperPointer() noexcept : LinkedObjectWrapperPtr(nullptr) {}
3017
3023 : LinkedObjectWrapperPtr(LinkedObjectWrapperPtr) {}
3024
3030 LinkedObjectWrapperPtrType get() const noexcept { return LinkedObjectWrapperPtr; }
3031
3037 bool operator==(const LinkedObjectWrapperPtrType rhs) const noexcept { return LinkedObjectWrapperPtr == rhs; }
3038
3044 bool operator!=(const LinkedObjectWrapperPtrType rhs) const noexcept { return LinkedObjectWrapperPtr != rhs; }
3045
3051 bool operator==(const LinkedObjectWrapperPointer& rhs) const noexcept { return LinkedObjectWrapperPtr == rhs.get(); }
3052
3058 bool operator!=(const LinkedObjectWrapperPointer& rhs) const noexcept { return LinkedObjectWrapperPtr != rhs.get(); }
3059
3064 explicit operator bool() const noexcept { return LinkedObjectWrapperPtr != nullptr; }
3065
3071 LinkedObjectWrapperPtrType operator->() const noexcept { return LinkedObjectWrapperPtr; }
3072
3078 LinkedObjectWrapperType& operator*() const noexcept { return *LinkedObjectWrapperPtr; }
3079
3080 private:
3085 };
3086
3092 {
3093 friend class RunnableInstance;
3094
3095 public:
3099 enum class LinkedObjectStateType { NotLinked, Ready, NotReady };
3114 protected:
3119 LinkedObjectWrapperContainerBase() noexcept : LinkedObjectState(LinkedObjectStateType::NotLinked) {}
3120
3122
3126 void Reset() noexcept;
3127
3133 mutable LinkedObjectStateType LinkedObjectState;
3134
3135 public:
3136 auto GetState() const noexcept { return LinkedObjectState; }
3137
3144 std::string GetLinkedObjectDesc() const { return GetLinkedObjectDescChild(); }
3145
3152 bool CheckIfReady() { return CheckIfReadyChild(); }
3153
3154 private:
3159 virtual void ResetChild() noexcept = 0;
3160 virtual std::string GetLinkedObjectDescChild() const = 0;
3161 virtual bool CheckIfReadyChild() = 0;
3163 };
3164
3174 template <typename ObjectT>
3176 {
3177 friend class RunnableInstance;
3178
3179 public:
3184 LinkedObjectWrapperContainer(bool PerformReadyCheck = true) noexcept
3185 : PerformReadyCheck(PerformReadyCheck) {}
3186
3188
3193
3201 auto get() const
3202 {
3203 const auto Destiny = GetLinkedObjWrapperPtr()->get();
3204
3205 if (PerformReadyCheck)
3206 {
3207 try
3208 {
3209 // This flag is reset either by SetLinkedObjWrapperPtr() or by
3210 // RunnableInstance::CareAboutWrappers().
3211 if (!Destiny->IsReady())
3212 LinkedObjectState = LinkedObjectStateType::NotReady;
3213 }
3214 // ForwardedException signals that the underlying exception arose in the destiny resource.
3215 // All other exceptions are not to be handled here.
3216 catch ([[maybe_unused]] const Util::ForwardedException& e)
3217 {
3218 LinkedObjectState = LinkedObjectStateType::NotReady;
3219 }
3220 }
3221
3222 return Destiny;
3223 }
3224
3225 auto& operator*() const { return *get(); }
3226 auto operator->() const { return get(); }
3227
3232 bool valid() const noexcept { return static_cast<bool>(LinkedObjWrapperPtr); }
3234
3235 private:
3236 virtual void ResetChild() noexcept override { LinkedObjWrapperPtr = nullptr; }
3237
3238 virtual std::string GetLinkedObjectDescChild() const override
3239 {
3240 if (!LinkedObjWrapperPtr)
3241 return "< unknown >";
3242
3243 return GetLinkedObjWrapperPtr()->GetLinkedObjectDesc();
3244 }
3245
3246 virtual bool CheckIfReadyChild() override
3247 {
3248 if (LinkedObjectState != LinkedObjectStateType::Ready)
3249 return false;
3250
3251 const auto Destiny = GetLinkedObjWrapperPtr()->get();
3252
3253 bool IsReady = Destiny->IsReady();
3254 if (!IsReady)
3255 LinkedObjectState = LinkedObjectStateType::NotReady;
3256
3257 return IsReady;
3258 }
3259
3264 void CheckIfNullptr() const
3265 {
3266 if (!LinkedObjWrapperPtr)
3268 }
3269
3275 {
3276 CheckIfNullptr();
3277
3278 return LinkedObjWrapperPtr;
3279 }
3280
3287 {
3288 LinkedObjWrapperPtr = NewLinkedObjWrapperPtr;
3289 LinkedObjectState = LinkedObjWrapperPtr ? LinkedObjectStateType::Ready : LinkedObjectStateType::NotLinked;
3290
3291 CheckIfReady();
3292 }
3293
3299
3305 };
3306
3317 template <typename ObjectT>
3319 {
3320 friend class RunnableInstance;
3321
3326
3327 public:
3330
3331 const auto& GetList() const noexcept { return Containers; }
3332 const auto& GetLabels() const noexcept { return ObjectLabels; }
3333 std::string_view GetIconPath() const { return IconPath; }
3334
3342 template <typename IndexType>
3343 auto& operator[](IndexType Index)
3344 {
3345 auto i = Util::NumToT<size_t>(Index);
3346
3347 if (i >= Containers.size())
3348 throw Util::OutOfRangeException("The specified object index is higher than the number of linked objects.");
3349
3350 return *Containers[i];
3351 }
3352
3353 private:
3358 std::vector<std::unique_ptr<ContainerType>> Containers;
3359
3361 std::string IconPath;
3362 };
3363
3369 {
3370 public:
3375 static constexpr std::chrono::milliseconds LockObjectTimeoutDefault = std::chrono::milliseconds(100);
3376
3377 protected:
3378 ObjectLinkBase() = default;
3379 virtual ~ObjectLinkBase() = 0;
3380 };
3381
3397 template <typename ObjectT>
3399 {
3400 public:
3401 using ObjectType = ObjectT;
3402 using ConstObjectType = std::add_const_t<ObjectT>;
3403
3404 friend class RunnableInstance;
3405
3409 ObjectLink() : DestinyResource() {}
3410
3415 ObjectLink(const std::shared_ptr<ObjectType>& DestinyResource) : DestinyResource(DestinyResource) {}
3416
3417 virtual ~ObjectLink() {}
3418
3422 void Reset() { DestinyResource.reset(); }
3423
3429 auto& operator=(const std::shared_ptr<ObjectType>& NewDestinyResource)
3430 {
3431 // Throwing an exception here could lead to only partially loaded Param possessing an
3432 // invalid ObjectLink. Additionally, ParamsConfigDialog::accept() calls
3433 // ParamsBase::Param<LinkType>::MakeLink() which calls this. ParamsConfigDialog::accept()
3434 // should not face exceptions. So, do not throw anything here.
3435 DestinyResource = NewDestinyResource;
3436
3437 return *this;
3438 }
3439
3447 {
3448 // See above.
3449 return DestinyResource.lock();
3450 }
3451
3452 private:
3463 std::unique_ptr<LinkedObjectWrapper<ConstObjectType>> TryLockObject(const RunnableInstance& WrapperOwner,
3464 std::chrono::milliseconds Timeout = LockObjectTimeoutDefault) const
3465 {
3466 std::shared_ptr<ConstObjectType> DestinyShared;
3467
3468 // While object where DestinyResource points to is being destroyed, DestinyResource
3469 // should already be marked as expired, so this is thread-safe.
3470 DestinyShared = DestinyResource.lock();
3471
3472 if (!DestinyShared)
3473 return nullptr;
3474
3475 return std::make_unique<LinkedObjectWrapper<ConstObjectType>>(WrapperOwner, std::move(DestinyShared), Timeout);
3476 }
3477
3487 auto LockObject(const RunnableInstance& WrapperOwner, std::chrono::milliseconds Timeout = LockObjectTimeoutDefault) const
3488 {
3489 auto ObjectWrapperPtr = TryLockObject(WrapperOwner, Timeout);
3490
3491 if (!ObjectWrapperPtr)
3493
3494 return ObjectWrapperPtr;
3495 }
3496
3502 std::weak_ptr<ObjectType> DestinyResource;
3503 };
3504
3521 {
3522 public:
3527 {
3528 friend class RunnableInstance;
3529 friend class RunnableObject;
3530
3535 constexpr RunnableObjectOnlyType(RunnableInstance& Parent) noexcept : Parent(Parent) {}
3536
3541 void SetThreadMayStart() { Parent.ThreadMayStart = true; }
3542
3544 };
3545
3546 protected:
3552 RunnableInstance(RunnableObject& Owner, std::promise<void>&& ThreadExitedPromise);
3553
3560
3561 public:
3563
3564 const auto& GetOwner() const noexcept { return Owner; }
3565
3571 void BlockUntilReadyToStart() const noexcept;
3572
3583 template <typename ObjectT>
3584 void TryLockObject(const ParamsBase::Param<ObjectLink<ObjectT>>& LinkParam,
3585 LinkedObjectWrapperContainer<ObjectT>& ObjectWrapperContainer,
3586 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3587 {
3588 ObjectWrapperContainer.SetLinkedObjWrapperPtr(StoreLockedObject(LinkParam.GetLink().TryLockObject(*this, Timeout), ObjectWrapperContainer));
3589 }
3590
3600 template <typename ObjectT>
3602 LinkedObjectWrapperContainer<ObjectT>& ObjectWrapperContainer,
3603 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3604 {
3605 ObjectWrapperContainer.SetLinkedObjWrapperPtr(StoreLockedObject(LinkParam.GetLink().LockObject(*this, Timeout), ObjectWrapperContainer));
3606 }
3607
3616 template <typename ObjectT>
3618 {
3619 // Destroys corresponding LinkedObjectWrapperBase and thereby deregisters from
3620 // LinkedObjectWrapper::DestinyResource.
3621 if (ObjectWrapperContainer.LinkedObjWrapperPtr)
3622 OwnedLinkedObjectWrappers.erase(ObjectWrapperContainer.LinkedObjWrapperPtr->ListPos);
3623
3624 ObjectWrapperContainer.Reset();
3625 }
3626
3627 // TryLockObject() is not overloaded for object link list parameters since it is not clear what
3628 // to do with already locked objects when trying to lock another list of objects fails. If
3629 // the previously locked objects were unlocked before, then the state after a failed call to
3630 // TryLockObject() would not be the same as before.
3631
3644 template <typename ObjectT>
3646 LinkedObjectWrapperContainerList<ObjectT>& ObjectWrapperContainerList,
3647 std::chrono::milliseconds Timeout = ObjectLinkBase::LockObjectTimeoutDefault)
3648 {
3649 // Ensure that ObjectWrapperContainerList is empty before locking.
3650 UnlockObject(ObjectWrapperContainerList);
3651
3652 for (const auto& Link : LinkListParam.GetLinks())
3653 {
3654 // Create new container in place since StoreLockedObject() stores a reference to it...
3655 ObjectWrapperContainerList.Containers.emplace_back(std::make_unique<LinkedObjectWrapperContainer<ObjectT>>());
3656 const auto& Container = ObjectWrapperContainerList.Containers.back(); // noexcept
3657
3658 try
3659 {
3660 // ... and fill it.
3661 Container->SetLinkedObjWrapperPtr(StoreLockedObject(Link.LockObject(*this, Timeout), *Container));
3662
3663 ObjectWrapperContainerList.ObjectLabels.emplace_back((*Container)->GetObjectName() + " (" + (*Container)->GetCategoryAndName() + ")");
3664 }
3665 catch (...)
3666 {
3667 // In case locking object or storing label fails, remove the container again.
3668 UnlockObject(*Container);
3669 ObjectWrapperContainerList.Containers.pop_back();
3670
3671 throw;
3672 }
3673 }
3674
3675 if (!LinkListParam.IsOptional() && ObjectWrapperContainerList.Containers.empty())
3676 throw Util::EmptyException("A non-optional object link list parameter is empty.");
3677
3678 ObjectWrapperContainerList.IconPath = LinkListParam.GetIconResourcePath();
3679 }
3680
3688 template <typename ObjectT>
3690 {
3691 for (const auto& Container : ObjectWrapperContainerList.Containers)
3692 UnlockObject(*Container);
3693
3694 ObjectWrapperContainerList.Containers.clear();
3695 ObjectWrapperContainerList.ObjectLabels.clear();
3696 ObjectWrapperContainerList.IconPath.clear();
3697 }
3698
3706 bool CareAboutWrappers();
3707
3713 std::string GetNotReadyObjectNamesString() const;
3714
3719
3721
3722 private:
3726 void SetThreadExited();
3727
3737 template <typename ObjectT>
3738 decltype(auto) StoreLockedObject(std::unique_ptr<LinkedObjectWrapper<ObjectT>>&& ObjectWrapperPtr,
3739 LinkedObjectWrapperContainerBase& ObjectWrapperContainer)
3740 {
3741 OwnedLinkedObjectWrappers.emplace_back(std::move(ObjectWrapperPtr), ObjectWrapperContainer);
3742
3743 auto ObjectWrapperIterator = --OwnedLinkedObjectWrappers.end();
3744 ObjectWrapperIterator->OwnedLinkedObjectWrapperPtr.get()->ListPos = ObjectWrapperIterator;
3745
3746 // Cast should never fail. Reference version since this would throw if it failed.
3747 return &dynamic_cast<typename LinkedObjectWrapperPointer<ObjectT>::LinkedObjectWrapperType&>(*ObjectWrapperIterator->OwnedLinkedObjectWrapperPtr.get());
3748 }
3749
3755
3761 std::atomic<bool> ThreadMayStart = false;
3762
3768 std::promise<void> ThreadExitedPromise;
3769
3774 bool Empty = false;
3775
3783 };
3784}
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:2724
std::list< OwnedLinkedObjectWrapperType > ListType
Type of a list hold by RunnableInstance (RunnableInstance::OwnedLinkedObjectWrappers) that contains p...
Definition Object.h:2766
std::unique_ptr< LinkedObjectWrapperBase > LinkedObjectWrapperBasePtrType
Alias for a smart pointer owning instances of this class.
Definition Object.h:2731
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:2773
Polymorphic base class to allow storing LinkedObjectWrapperContainer of any type in a single list.
Definition Object.h:3092
void Reset() noexcept
Removes any linked LinkedObjectWrapper and updates LinkedObjectState.
Definition Object.cpp:749
LinkedObjectWrapperContainerBase() noexcept
Constructs a LinkedObjectWrapperContainerBase instance which is not linked to any LinkedObjectWrapper...
Definition Object.h:3119
bool CheckIfReady()
Returns whether the Object instance which is wrapped by the linked LinkedObjectWrapper is in a ready ...
Definition Object.h:3152
LinkedObjectStateType
Indicates the current state of the Object referenced by the linked LinkedObjectWrapper.
Definition Object.h:3099
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:3144
This class defines a list of LinkedObjectWrapperContainer instances. The list owns the contained Link...
Definition Object.h:3319
Util::TextListType ObjectLabels
Holds a human-readable identifier for each linked object.
Definition Object.h:3360
const auto & GetLabels() const noexcept
Returns ObjectLabels.
Definition Object.h:3332
std::string IconPath
Holds the path to the icon of the linked objects' base type (e.g. hardware adapter,...
Definition Object.h:3361
std::vector< std::unique_ptr< ContainerType > > Containers
List of the owned LinkedObjectWrapperContainer instances. std::vector of pointers since insertion and...
Definition Object.h:3358
auto & operator[](IndexType Index)
Returns a stored LinkedObjectWrapperContainer instance selected by its list index.
Definition Object.h:3343
std::string_view GetIconPath() const
Returns IconPath.
Definition Object.h:3333
const auto & GetList() const noexcept
Returns Containers.
Definition Object.h:3331
This class holds a pointer (LinkedObjectWrapperPointer) to a LinkedObjectWrapper. Intances of this cl...
Definition Object.h:3176
LinkedObjectWrapperPointer< ObjectT > LinkedObjWrapperPtr
Pointer to a LinkedObjectWrapper instance holding a pointer to the destiny object instance of type co...
Definition Object.h:3298
const bool PerformReadyCheck
Determines whether a call to get() checks the return value of Object::IsReady() before returning Link...
Definition Object.h:3304
virtual std::string GetLinkedObjectDescChild() const override
Builds and returns a human-readable string uniquely identifying the Object instance which is wrapped ...
Definition Object.h:3238
auto get() const
Returns the LinkedObjWrapperPtr and checks (depending on PerformReadyCheck) whether the Object Linked...
Definition Object.h:3201
bool valid() const noexcept
Checks whether LinkedObjWrapperPtr points to a valid distination.
Definition Object.h:3232
auto & GetLinkedObjWrapperPtr() const
Returns LinkedObjWrapperPtr after checking whether LinkedObjWrapperPtr is nullptr.
Definition Object.h:3274
LinkedObjectWrapperContainer(bool PerformReadyCheck=true) noexcept
Constructs a LinkedObjectWrapperContainer instance.
Definition Object.h:3184
virtual bool CheckIfReadyChild() override
Returns whether the Object instance which is wrapped by the linked LinkedObjectWrapper is in a ready ...
Definition Object.h:3246
virtual void ResetChild() noexcept override
Removes any linked LinkedObjectWrapper and updates LinkedObjectState.
Definition Object.h:3236
auto operator->() const
Returns the result of a call to get().
Definition Object.h:3226
auto & operator*() const
Dereferences and returns the result of a call to get().
Definition Object.h:3225
virtual ~LinkedObjectWrapperContainer()=default
void CheckIfNullptr() const
Checks whether LinkedObjWrapperPtr is nullptr. Does nothing if this is not the case.
Definition Object.h:3264
void SetLinkedObjWrapperPtr(LinkedObjectWrapperPointer< ObjectT > NewLinkedObjWrapperPtr) noexcept
Sets LinkedObjWrapperPtr to a new destination and updates LinkedObjectWrapperContainerBase::LinkedObj...
Definition Object.h:3286
This class describes a pointer to a LinkedObjectWrapper instance. It is a simple wrapper class which ...
Definition Object.h:3001
bool operator!=(const LinkedObjectWrapperPtrType rhs) const noexcept
Checks whether LinkedObjectWrapperPtr does not equal another pointer to a LinkedObjectWrapper instanc...
Definition Object.h:3044
LinkedObjectWrapperPtrType LinkedObjectWrapperPtr
LinkedObjectWrapper instance this pointer points to
Definition Object.h:3084
bool operator!=(const LinkedObjectWrapperPointer &rhs) const noexcept
Checks whether this LinkedObjectWrapperPointer instance does not equal another instance.
Definition Object.h:3058
LinkedObjectWrapperPtrType get() const noexcept
Always returns a const pointer so that Object instances using another linked Object instance are only...
Definition Object.h:3030
bool operator==(const LinkedObjectWrapperPtrType rhs) const noexcept
Checks whether LinkedObjectWrapperPtr equals another pointer to a LinkedObjectWrapper instance.
Definition Object.h:3037
LinkedObjectWrapperPointer() noexcept
Constructs an empty pointer.
Definition Object.h:3016
LinkedObjectWrapperPointer(LinkedObjectWrapperPtrType LinkedObjectWrapperPtr) noexcept
Constructs a pointer pointing to LinkedObjectWrapperPtr.
Definition Object.h:3022
LinkedObjectWrapperType & operator*() const noexcept
Always returns a const reference so that Object instances using another linked Object instance are on...
Definition Object.h:3078
bool operator==(const LinkedObjectWrapperPointer &rhs) const noexcept
Checks whether this LinkedObjectWrapperPointer instance equals another instance.
Definition Object.h:3051
LinkedObjectWrapperPtrType operator->() const noexcept
Always returns a const pointer so that Object instances using another linked Object instance are only...
Definition Object.h:3071
Holds a shared_ptr to a resource (instance of class Object) and lets the resource keep track of its u...
Definition Object.h:2839
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:2899
decltype(auto) get()
Getter for the target resource which is used by the owning Object instance.
Definition Object.h:2918
decltype(auto) get() const
Getter for the target resource which is used by the owning Object instance.
Definition Object.h:2916
std::add_const_t< ObjectT > ObjectType
Const type of the managed Object.
Definition Object.h:2841
virtual ~LinkedObjectWrapper()
Destructor calls LinkedObjectWrapper::Deregister().
Definition Object.h:2860
std::string GetLinkedObjectDesc() const
Builds and returns a human-readable string uniquely identifying the Object instance DestinyResource....
Definition Object.h:2908
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:2849
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:3369
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:2044
constexpr LinkedObjectWrapperOnlyType(Object &Parent) noexcept
Construcs an instance - one for each Object instance.
Definition Object.h:2054
Object & Parent
Owning Object instance.
Definition Object.h:2076
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:2166
Util::Warning Warning
Last warning which occurred within this Object instance. (Logical const-ness: see above....
Definition Object.h:2313
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:2236
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:2151
auto GetUseCount(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Counts the registered useres in a thread-safe way.
Definition Object.h:2224
LinkedObjectWrapperOnlyType LinkedObjectWrapperOnly
Allow exclusive access to some of Object's private methods to any LinkedObjectWrapper<T>.
Definition Object.h:2250
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:2310
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:2241
bool IsUnusedUnsafe()
Returns whether this Object instance is used by other instances (not thread-safe).
Definition Object.h:2281
bool IsUnused(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout) const
Returns whether this Object instance is used by other instances.
Definition Object.h:2231
void ClearWarning() const
Resets Object::Warning.
Definition Object.h:2198
auto GetUserNamesStringUnsafe() const
Definition Object.h:2275
virtual void CheckLinkedObjectStatesChild() const
Override to implement a check whether linked objects are in a ready state.
Definition Object.h:2302
const ParamsBasePtrType Params
Pointer to the parameter class instance belonging to this Object instance.
Definition Object.h:2311
ObjectUserList UserList
List of Object instances making use of this Object instance. Other Object instances making use of thi...
Definition Object.h:2320
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:2204
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:2219
auto GetUseCountUnsafe()
Definition Object.h:2274
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:2212
void DeregisterAllUnsafe()
Deregisters all users and notifies them that they need to check the states of their used linked objec...
Definition Object.h:2273
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:2144
auto GetObjectName(const std::chrono::milliseconds Timeout=GetParamsTimeoutDefault) const
Returns the name of this Object instance.
Definition Object.h:2136
auto LockUserList(const std::chrono::milliseconds Timeout=Util::ILockable::DefaultTimeout)
Locks the user list for thread-safe manipulation.
Definition Object.h:2272
void CheckLinkedObjectStates() const
Checks whether Object instances this instance uses are in a ready state. Override CheckLinkedObjectSt...
Definition Object.h:2248
Refer to ParamsBase::dispatch_tag.
Definition Object.h:2026
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
Allow exclusive access to some of RunnableInstance's private variables to RunnableObject.
Definition Object.h:3527
RunnableInstance & Parent
Owning RunnableInstance instance.
Definition Object.h:3543
constexpr RunnableObjectOnlyType(RunnableInstance &Parent) noexcept
Construcs an instance - one for each RunnableInstance instance.
Definition Object.h:3535
void SetThreadMayStart()
Sets RunnableInstance::ThreadMayStart to true, indicating that the thread Parent belongs to may start...
Definition Object.h:3541
Defines data for a thread belonging to a RunnableObject instance. This data is only accessed by the R...
Definition Object.h:3521
LinkedObjectWrapperBase::ListType OwnedLinkedObjectWrappers
List of all LinkedObjectWrapper instances owned by this RunnableInstance instance (thus belonging to ...
Definition Object.h:3782
const Object::ParamsGetterType ParamsGetter
Invoke to obtain the parameters (derived from ParamsBase) of Owner.
Definition Object.h:3718
void UnlockObject(LinkedObjectWrapperContainer< ObjectT > &ObjectWrapperContainer)
Unlocks an Object instance stored in the LinkedObjectWrapperContainer ObjectWrapperContainer....
Definition Object.h:3617
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:3645
decltype(auto) StoreLockedObject(std::unique_ptr< LinkedObjectWrapper< ObjectT > > &&ObjectWrapperPtr, LinkedObjectWrapperContainerBase &ObjectWrapperContainer)
Stores a newly created LinkedObjectWrapper instance in OwnedLinkedObjectWrappers.
Definition Object.h:3738
void UnlockObject(LinkedObjectWrapperContainerList< ObjectT > &ObjectWrapperContainerList)
Unlocks Object instances stored in the LinkedObjectWrapperContainerList ObjectWrapperContainerList.
Definition Object.h:3689
const RunnableObject & Owner
RunnableObject instance which operates on this RunnableInstance (by its thread). The RunnableObject i...
Definition Object.h:3754
std::promise< void > ThreadExitedPromise
Signals the RunnableObject instance owning the thread that its thread has terminated....
Definition Object.h:3768
RunnableObjectOnlyType RunnableObjectOnly
Allow exclusive access to some of RunnableInstance's private variables to RunnableObject.
Definition Object.h:3720
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:3601
const auto & GetOwner() const noexcept
Returns Owner.
Definition Object.h:3564
Configurator class for RunnableObject.
Definition Object.h:2420
Parameter class for RunnableObject.
Definition Object.h:2357
virtual void ConfigureParamsImpl(dispatch_tag< RunnableObjectParams >)
Called by DynExp::ParamsBase::ConfigureParams() as a starting point for the tag dispatch mechanism to...
Definition Object.h:2406
bool ConfigureStartupType() const noexcept
Determines whether the Startup parameter should be user-configurable in settings dialogs....
Definition Object.h:2402
StartupType
Determines when a RunnableObject instance is started.
Definition Object.h:2362
virtual bool ConfigureStartupTypeChild() const noexcept
Determines whether the Startup parameter should be user-configurable in settings dialogs....
Definition Object.h:2412
RunnableObjectParams(ItemIDType ID, const DynExpCore &Core)
Constructs the base class of an object parameter class.
Definition Object.h:2379
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:2383
Exception type thrown by TerminateImpl() if the RunnableObject cannot be terminated for being used by...
Definition Object.h:2462
NotUnusedException(const RunnableObject &Parent)
Constructs an exception instance. Initializes UserNames with the content of ObjectUserList::GetUserNa...
Definition Object.h:2469
std::string_view GetUserNames() const
Getter for UserNames.
Definition Object.h:2475
std::string UserNames
String with identifiers of the Object instances making use of the throwing RunnableObject instance.
Definition Object.h:2487
Allow exclusive access to some of RunnableObject's private methods to class RunnableInstance.
Definition Object.h:2439
void OnThreadHasExited() const noexcept
This function is called when the RunnableObject instance's thread terminates. The thread receives a R...
Definition Object.h:2449
bool IsLinkedObjStateCheckRequested() const noexcept
Indicates whether the RunnableInstance instance belonging to this RunnableObject instance's thread sh...
Definition Object.h:2450
RunnableObject & Parent
Owning RunnableObject instance.
Definition Object.h:2453
constexpr RunnableInstanceOnlyType(RunnableObject &Parent) noexcept
Construcs an instance - one for each RunnableObject instance.
Definition Object.h:2447
void ResetLinkedObjStateCheckRequested() const noexcept
Sets RunnableObject::LinkedObjStateCheckRequested to false.
Definition Object.h:2451
Defines an Object which possesses a thread it runs in. The RunnableObject can be started and stopped ...
Definition Object.h:2434
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:2662
auto GetStartupType() const noexcept
Returns Startup.
Definition Object.h:2562
virtual void NotifyChild()
Notify derived classes that some state has changed (e.g. the termination of Thread is requested) and ...
Definition Object.h:2645
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:2621
void CheckLinkedObjectStatesChild() const override final
Override to implement a check whether linked objects are in a ready state.
Definition Object.h:2633
bool IsExiting() const noexcept
Returns ShouldExit.
Definition Object.h:2560
bool IsPaused() const noexcept
Returns Paused.
Definition Object.h:2559
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:2565
auto GetReasonWhyPaused() const
Returns ReasonWhyPaused.
Definition Object.h:2563
std::function< int(std::unique_ptr< RunnableInstance > &&, RunnableObject *)> ThreadFuncType
Type of the thread function executed by RunnableObject instances.
Definition Object.h:2571
void ClearReasonWhyPaused()
Removes the reason why this RunnableObject instance has been paused (since it is resumed).
Definition Object.h:2626
void SetReasonWhyPaused(std::string Description)
Sets the reason why this RunnableObject instance has been paused.
Definition Object.h:2615
bool IsRunning() const noexcept
Returns Running.
Definition Object.h:2558
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:2654
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:449
Thrown when a list is expected to contain entries and when a query results in an empty answer or an e...
Definition Exception.h:225
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:317
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:127
Interface to allow synchronizing the access to derived classes between different threads by providing...
Definition Util.h:57
std::unique_lock< MutexType > LockType
Definition Util.h:67
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:63
Interface to delete copy constructor and copy assignment operator and thus make derived classes non-c...
Definition Util.h:24
An invalid argument like a null pointer has been passed to a function.
Definition Exception.h:138
Thrown when RunnableInstance cannot lock an object to be used by another object due to an invalid lin...
Definition Exception.h:345
An operation cannot be performed currently since the related object is in an invalid state like an er...
Definition Exception.h:151
Thrown when RunnableInstance::LockObject() has not been called on an object link parameter to establi...
Definition Exception.h:330
Thrown when a requested ressource does not exist.
Definition Exception.h:237
Thrown when a requested feature is either under development and thus not implemented yet or when a sp...
Definition Exception.h:300
Thrown when an argument passed to a function exceeds the valid range.
Definition Exception.h:212
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
Definition Util.h:171
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
Definition Exception.h:262
Thrown when an attempt was made to convert two incompatible types into each other.
Definition Exception.h:249
Class to store information about warnings in a thread-safe manner (deriving from ILockable)....
Definition Util.h:1022
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:2341
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:684
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:517
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:2738
LinkedObjectWrapperBasePtrType OwnedLinkedObjectWrapperPtr
Pointer owning an instance of LinkedObjectWrapperBase.
Definition Object.h:2752
LinkedObjectWrapperContainerBase & OwnedLinkedObjectWrapperContainer
Reference to a LinkedObjectWrapperContainerBase instance holding a non-owning pointer to the instance...
Definition Object.h:2758
OwnedLinkedObjectWrapperType(LinkedObjectWrapperBasePtrType &&OwnedLinkedObjectWrapperPtr, LinkedObjectWrapperContainerBase &OwnedLinkedObjectWrapperContainer)
Constructs a OwnedLinkedObjectWrapperType instance.
Definition Object.h:2744
Defines a DynExp resource, which mainly owns a DynExp::Object instance wrapping a pointer to it.
Definition Managers.h:24