Base hardware tree classes
Summary
This issue is about adding the base classes for the hardware tree. They will use the "mixin" design pattern: multiple inheritance from small classes will let one define a more advanced (and useful) class. The following base classes are foreseen:
-
node
: Any class that wants to be stored in the tree must inherit this one. -
parent
: Deriving from this class allows a node to have children. -
child_of<Parent>
: Allows a class to be stored as a child ofParent
. -
root
: A node-derived class that acts as the root of the tree. Whether it should be part of the base classes is questionable.
These classes will let one define the basic structure of a tree, but its usage will still be painful.
Intended usage
class optohybrid : public node,
public parent,
public child_of<amc> {
int _link;
public:
explicit optohybrid(const std::shared_ptr<amc>& parent = nullptr) noexcept
: child_of(parent)
, node("oh")
{
}
int link_number() const noexcept { return _link; }
void set_link_number(int link) noexcept { _link = link; }
};