10#define ROOT7_RAttrBase
17namespace Experimental {
65 std::string fullname =
name;
67 fullname.insert(0, prnt->
fPrefix);
71 return {prnt->
fOwnAttr.get(), fullname,
nullptr};
74 return {
nullptr, fullname,
nullptr};
87 if (
auto rec = access.attr->Find(access.fullname))
88 return {rec,
nullptr};
89 if (access.drawable && use_style)
90 if (
auto observe = access.drawable->fStyle.lock()) {
91 if (
auto rec = observe->Eval(access.fullname, *access.drawable))
92 return {rec, observe};
96 return {
nullptr,
nullptr};
104 std::string fullname =
name;
106 fullname.insert(0, prnt->fPrefix);
108 return {&(prnt->fDrawable->fAttr), fullname, prnt->fDrawable};
109 if (!prnt->fParent && !prnt->fOwnAttr)
110 prnt->fOwnAttr = std::make_unique<RAttrMap>();
112 return {prnt->fOwnAttr.get(), fullname,
nullptr};
113 prnt = prnt->fParent;
115 return {
nullptr, fullname,
nullptr};
120 template <
typename RET_TYPE,
typename MATCH_TYPE =
void>
121 auto Eval(
const std::string &
name,
bool use_dflts =
true)
const
124 return RAttrMap::Value_t::GetValue<RET_TYPE,MATCH_TYPE>(
v.value);
131 return RAttrMap::Value_t::GetValue<RET_TYPE,MATCH_TYPE>(rec);
157 void SetValue(
const std::string &
name,
const std::string &value);
166 template <
typename T =
void>
167 bool HasValue(
const std::string &
name,
bool check_defaults =
false)
const
169 auto res = Eval<const RAttrMap::Value_t *, T>(
name, check_defaults);
173 template <
typename T>
176 return Eval<T>(
name);
181 virtual bool IsValue()
const {
return false; }
197#define R__ATTR_CLASS(ClassName,dflt_prefix) \
199const RAttrMap &GetDefaults() const override \
201 static auto dflts = CollectDefaults(); \
205 ClassName() = default; \
206 ClassName(RDrawable *drawable, const std::string &prefix = dflt_prefix) { AssignDrawable(drawable, prefix); } \
207 ClassName(RAttrBase *parent, const std::string &prefix = dflt_prefix) { AssignParent(parent, prefix); } \
208 ClassName(const ClassName &src) : ClassName() { src.CopyTo(*this); } \
209 ClassName(ClassName &&src) : ClassName() { src.MoveTo(*this); } \
210 ClassName &operator=(ClassName &&src) { src.MoveTo(*this); return *this; } \
211 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.
virtual bool IsValue() const
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)
virtual RAttrMap CollectDefaults() const
Collect all attributes in derived class Works only if such class has dictionary.
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
RLogChannel & GPadLog()
Log channel for GPad diagnostics.
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