17 BaseTestObject () =
default;
18 explicit BaseTestObject (Uuid
id)
19 : UuidIdentifiableObject<BaseTestObject> (
id)
22 ~BaseTestObject ()
override =
default;
23 BaseTestObject (
const BaseTestObject &) =
default;
24 BaseTestObject &operator= (
const BaseTestObject &) =
default;
25 BaseTestObject (BaseTestObject &&) =
default;
26 BaseTestObject &operator= (BaseTestObject &&) =
default;
28 friend void to_json (nlohmann::json &json_value,
const BaseTestObject &obj)
30 to_json (json_value,
static_cast<const UuidIdentifiableObject &
> (obj));
32 friend void from_json (
const nlohmann::json &json_value, BaseTestObject &obj)
34 from_json (json_value,
static_cast<UuidIdentifiableObject &
> (obj));
37 BOOST_DESCRIBE_CLASS (BaseTestObject, (UuidIdentifiableObject), (), (), ())
47class DerivedTestObject :
public QObject,
public BaseTestObject
53 explicit DerivedTestObject (
int some_dependency) { };
54 explicit DerivedTestObject (TestUuid
id, std::string name)
55 : BaseTestObject (
id), name_ (std::move (name))
59 [[nodiscard]] std::string name ()
const {
return name_; }
61 friend void init_from (
62 DerivedTestObject &obj,
63 const DerivedTestObject &other,
67 obj.name_ = other.name_;
70 NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE (DerivedTestObject, BaseTestObject, name_)
75 BOOST_DESCRIBE_CLASS (DerivedTestObject, (BaseTestObject), (), (), (name_))
104 using TestVariant = std::variant<DerivedTestObject *>;
108 void SetUp ()
override
114 registry_.register_object (obj1_);
115 registry_.register_object (obj2_);
116 registry_.register_object (obj3_);
119 TestRegistry registry_;
135class ContainerTestObject :
public QObject,
public BaseTestObject
140 using ContainerRegistry = utils::
141 OwningObjectRegistry<std::variant<ContainerTestObject *>, BaseTestObject>;
144 explicit ContainerTestObject (
int ) { }
145 explicit ContainerTestObject (TestUuid
id, std::string name)
146 : BaseTestObject (
id), name_ (std::move (name))
150 void set_contained_ref (UuidRef ref) { contained_ref_ = std::move (ref); }
152 [[nodiscard]] std::string name ()
const {
return name_; }
154 friend void init_from (
155 ContainerTestObject &obj,
156 const ContainerTestObject &other,
159 obj.name_ = other.name_;
162 NLOHMANN_DEFINE_DERIVED_TYPE_INTRUSIVE (
169 std::optional<UuidRef> contained_ref_;
171 BOOST_DESCRIBE_CLASS (ContainerTestObject, (BaseTestObject), (), (), (name_))