2#ifndef __ASE_GADGET_HH__
3#define __ASE_GADGET_HH__
18 enum :
uint64_t { GADGET_DESTROYED = 0x1, DEVICE_ACTIVE = 0x2, MASTER_TRACK = 0x4 };
19 uint64_t gadget_flags ()
const {
return gadget_flags_; }
23 virtual String fallback_name ()
const;
25 virtual void create_properties ();
27 String get_name ()
const override;
31 String type_nick ()
const override;
35 template<
class O,
class M>
void _register_parameter (O*, M*,
const Param::ExtraVals&)
const;
37 using MemberInfosP =
const StringS& (*) ();
40 static bool requires_accessor (
const char *ot,
const char *mt, ptrdiff_t offset);
41 static void register_accessor (
const char *ot,
const char *mt, ptrdiff_t offset, MemberClassT,
45template<
class O,
class M>
void
46GadgetImpl::_register_parameter (O *obj, M *memb,
const Param::ExtraVals &ev)
const
48 static_assert (M::is_unique_per_member);
49 GadgetImpl *gadget = obj;
51 const auto object_typeid_name = typeid_name<O>();
52 const auto member_typeid_name = typeid_name<M>();
53 const ptrdiff_t offset = ptrdiff_t (memb) - ptrdiff_t (obj);
54 if (!requires_accessor (object_typeid_name, member_typeid_name, offset))
56 const MemberClassT classtest = [] (
const SharedBase &b) ->
bool {
return !!
dynamic_cast<const O*
> (&b); };
57 using value_type =
decltype (memb->get());
58 auto accessor = [offset] (GadgetImpl *g,
const Value *in, Value *out) {
59 O &o =
dynamic_cast<O&
> (*g);
60 const ptrdiff_t maddr = ptrdiff_t (&o) + offset;
61 M *m =
reinterpret_cast<M*
> (maddr);
76 static_assert (
sizeof (value_type) < 0,
"unhandled <value_type>");
80 *out = Value (m->get());
83 register_accessor (object_typeid_name, member_typeid_name, offset, classtest, ev, accessor, &memb->infos, memb->hints());
Base type for classes that have a Property.
GadgetImpl * _parent() const override
Retrieve parent container.
PropertyS access_properties() override
Retrieve handles for all properties.
Value get_data(const String &key) const override
Retrieve session data.
bool set_data(const String &key, const Value &v) override
Assign session data, prefix ephemerals with '_'.
void _set_parent(GadgetImpl *parent) override
Assign parent container.
void serialize(WritNode &xs) override
Serialize members and childern.
Base type for classes that have a Property.
Implementation type for classes with Property interfaces.
Interface for serializable objects with Reflink support.
Common base type for polymorphic classes managed by std::shared_ptr<>.
One entry in a Writ serialization document.
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
The Anklang C++ API namespace.
Value type used to interface with various property types.