10#define ROOT7_RAttrBase
17namespace Experimental {
61 std::string fullname =
name;
63 fullname.insert(0, prnt->
fPrefix);
67 return {prnt->
fOwnAttr.get(), fullname,
nullptr};
70 return {
nullptr, fullname,
nullptr};
83 if (
auto rec = access.attr->Find(access.fullname))
84 return {rec,
nullptr};
85 if (access.drawable && use_style)
86 if (
auto observe = access.drawable->fStyle.lock()) {
87 if (
auto rec = observe->Eval(access.fullname, *access.drawable))
88 return {rec, observe};
92 return {
nullptr,
nullptr};
100 std::string fullname =
name;
102 fullname.insert(0, prnt->fPrefix);
104 return {&(prnt->fDrawable->fAttr), fullname, prnt->fDrawable};
105 if (!prnt->fParent && !prnt->fOwnAttr)
106 prnt->fOwnAttr = std::make_unique<RAttrMap>();
108 return {prnt->fOwnAttr.get(), fullname,
nullptr};
109 prnt = prnt->fParent;
111 return {
nullptr, fullname,
nullptr};
116 template <
typename RET_TYPE,
typename MATCH_TYPE =
void>
117 auto Eval(
const std::string &
name,
bool use_dflts =
true)
const
120 return RAttrMap::Value_t::GetValue<RET_TYPE,MATCH_TYPE>(
v.value);
127 return RAttrMap::Value_t::GetValue<RET_TYPE,MATCH_TYPE>(rec);
153 void SetValue(
const std::string &
name,
const std::string &value);
162 template <
typename T =
void>
163 bool HasValue(
const std::string &
name,
bool check_defaults =
false)
const
165 auto res = Eval<const RAttrMap::Value_t *, T>(
name, check_defaults);
169 template <
typename T>
172 return Eval<T>(
name);
188#define R__ATTR_CLASS(ClassName,dflt_prefix,dflt_values) \
190const RAttrMap &GetDefaults() const override \
192 static auto dflts = RAttrMap().dflt_values; \
196 ClassName() = default; \
197 ClassName(RDrawable *drawable, const std::string &prefix = dflt_prefix) { AssignDrawable(drawable, prefix); } \
198 ClassName(RAttrBase *parent, const std::string &prefix = dflt_prefix) { AssignParent(parent, prefix); } \
199 ClassName(const ClassName &src) : ClassName() { src.CopyTo(*this); } \
200 ClassName(ClassName &&src) : ClassName() { src.MoveTo(*this); } \
201 ClassName &operator=(ClassName &&src) { src.MoveTo(*this); return *this; } \
202 ClassName &operator=(const ClassName &src) { Clear(); src.CopyTo(*this); return *this; } \
Base class for all attributes, used with RDrawable.
bool IsValueEqual(const std::string &name, const RAttrMap::Value_t &value, bool use_style=false) const
Check if provided value equal to attribute in the map.
const Rec_t AccessAttr(const std::string &name) const
Find attributes container and full-qualified name for value.
std::unique_ptr< RAttrMap > fOwnAttr
own instance when deep copy is created, persistent for RColor and similar classes
const Val_t AccessValue(const std::string &name, bool use_style=true) const
Search value with given name in attributes.
friend bool operator!=(const RAttrBase &lhs, const RAttrBase &rhs)
void Clear()
Clear all respective values from drawable. Only defaults can be used.
bool HasValue(const std::string &name, bool check_defaults=false) const
Rec_t EnsureAttr(const std::string &name)
Ensure attribute with give name exists - creates container for attributes if required.
RAttrBase & operator=(const RAttrBase &src)
void SetNoValue(const std::string &name)
Set <NoValue> for attribute.
bool CopyValue(const std::string &name, const RAttrMap::Value_t &value, bool check_type=true)
Copy attributes from other object.
void MoveTo(RAttrBase &tgt)
Move all fields into target object.
RDrawable * fDrawable
! drawable used to store attributes
void ClearValue(const std::string &name)
Clear value if any with specified name.
void AssignDrawable(RDrawable *drawable, const std::string &prefix)
Return value from attributes container - no style or defaults are used.
friend bool operator==(const RAttrBase &lhs, const RAttrBase &rhs)
RAttrBase * fParent
! parent attributes, prefix applied to it
RAttrBase(RAttrBase *parent, const std::string &prefix)
virtual ~RAttrBase()=default
void SetValue(const std::string &name, bool value)
Set boolean value.
const std::string & GetPrefix() const
bool IsSame(const RAttrBase &src, bool use_style=true) const
Check if all values which are evaluated in this object are exactly the same as in tgt object.
RAttrBase(RDrawable *drawable, const std::string &prefix)
void AssignParent(RAttrBase *parent, const std::string &prefix)
Assign parent object for this RAttrBase.
std::string fPrefix
! name prefix for all attributes values
T GetValue(const std::string &name) const
virtual const RAttrMap & GetDefaults() const
Return default values for attributes, empty for base class.
RAttrBase(const RAttrBase &src)
void CopyTo(RAttrBase &tgt, bool use_style=true) const
Copy attributes into target object.
auto Eval(const std::string &name, bool use_dflts=true) const
Evaluate attribute value.
const Value_t * Find(const std::string &name) const
Base class for drawable entities: objects that can be painted on a RPad.
RAttrMap fAttr
attributes values
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
const RAttrMap::Value_t * value
std::shared_ptr< RStyle > style