Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrAggregation.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
9#ifndef ROOT7_RAttrAggregation
10#define ROOT7_RAttrAggregation
11
12#include <ROOT/RAttrBase.hxx>
13
14namespace ROOT {
15namespace Experimental {
16
17/** \class RAttrAggregation
18\ingroup GpadROOT7
19\author Sergey Linev <s.linev@gsi.de>
20\date 2021-06-18
21\brief Base class for attributes aggregations like lines or fill attributes
22\warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
23*/
24
25
27
28protected:
29 virtual const RAttrMap &GetDefaults() const;
30
31 RAttrMap CollectDefaults() const override;
32
33 bool IsAggregation() const final { return true; }
34
35 void CopyTo(RAttrAggregation &tgt, bool use_style = true) const;
36
37 bool CopyValue(const std::string &name, const RAttrMap::Value_t &value, bool check_type = true);
38
39 bool IsSame(const RAttrAggregation &src, bool use_style = true) const;
40
41 bool IsValueEqual(const std::string &name, const RAttrMap::Value_t &value, bool use_style = false) const;
42
43public:
44 RAttrAggregation() = default;
45
46 RAttrAggregation(const RAttrAggregation &src) : RAttrBase() { src.CopyTo(*this); }
47
48 RAttrAggregation(RDrawable *drawable, const char *prefix = nullptr) : RAttrBase(drawable, prefix) {}
49 RAttrAggregation(RAttrBase *parent, const char *prefix = nullptr) : RAttrBase(parent, prefix) {}
50
52 {
53 Clear();
54 src.CopyTo(*this);
55 return *this;
56 }
57
58 void Clear() override;
59
60 friend bool operator==(const RAttrAggregation& lhs, const RAttrAggregation& rhs) { return lhs.IsSame(rhs) && rhs.IsSame(lhs); }
61 friend bool operator!=(const RAttrAggregation& lhs, const RAttrAggregation& rhs) { return !lhs.IsSame(rhs) || !rhs.IsSame(lhs); }
62};
63
64} // namespace Experimental
65} // namespace ROOT
66
67#define R__ATTR_CLASS_DERIVED(ClassName,dflt_prefix,BaseClass) \
68protected: \
69const RAttrMap &GetDefaults() const override \
70{ \
71 static auto dflts = CollectDefaults(); \
72 return dflts; \
73} \
74public: \
75 ClassName() = default; \
76 ClassName(RDrawable *drawable, const char *prefix = dflt_prefix) : BaseClass(drawable, prefix) {} \
77 ClassName(RAttrBase *parent, const char *prefix = dflt_prefix) : BaseClass(parent, prefix) {} \
78 ClassName(const ClassName &src) : ClassName() { src.CopyTo(*this); } \
79 ClassName &operator=(const ClassName &src) { Clear(); src.CopyTo(*this); return *this; }
80
81
82#define R__ATTR_CLASS(ClassName,dflt_prefix) R__ATTR_CLASS_DERIVED(ClassName,dflt_prefix,RAttrAggregation)
83
84#endif
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
char name[80]
Definition TGX11.cxx:110
Base class for attributes aggregations like lines or fill attributes.
friend bool operator==(const RAttrAggregation &lhs, const RAttrAggregation &rhs)
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.
friend bool operator!=(const RAttrAggregation &lhs, const RAttrAggregation &rhs)
RAttrAggregation & operator=(const RAttrAggregation &src)
void Clear() override
Clear all respective values from drawable. Only defaults can be used.
RAttrAggregation(const RAttrAggregation &src)
bool IsSame(const RAttrAggregation &src, bool use_style=true) const
Check if all values which are evaluated in this object are exactly the same as in tgt object.
bool CopyValue(const std::string &name, const RAttrMap::Value_t &value, bool check_type=true)
Copy attributes from other object.
virtual const RAttrMap & GetDefaults() const
Return default values for attributes, empty for base class.
RAttrAggregation(RDrawable *drawable, const char *prefix=nullptr)
RAttrAggregation(RAttrBase *parent, const char *prefix=nullptr)
RAttrMap CollectDefaults() const override
Collect all attributes in derived class Works only if such class has dictionary.
void CopyTo(RAttrAggregation &tgt, bool use_style=true) const
Copy attributes into target object.
Base class for all attributes, used with RDrawable.
Definition RAttrBase.hxx:31
Base class for drawable entities: objects that can be painted on a RPad.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.