Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:35

0001 /*************************************************************************
0002  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 #ifndef ROOT7_RAttrAggregation
0010 #define ROOT7_RAttrAggregation
0011 
0012 #include <ROOT/RAttrBase.hxx>
0013 
0014 namespace ROOT {
0015 namespace Experimental {
0016 
0017 /** \class RAttrAggregation
0018 \ingroup GpadROOT7
0019 \author Sergey Linev <s.linev@gsi.de>
0020 \date 2021-06-18
0021 \brief Base class for attributes aggregations like lines or fill attributes
0022 \warning This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
0023 */
0024 
0025 
0026 class RAttrAggregation : public RAttrBase {
0027 
0028 protected:
0029    virtual const RAttrMap &GetDefaults() const;
0030 
0031    RAttrMap CollectDefaults() const override;
0032 
0033    bool IsAggregation() const final { return true; }
0034 
0035    void CopyTo(RAttrAggregation &tgt, bool use_style = true) const;
0036 
0037    bool CopyValue(const std::string &name, const RAttrMap::Value_t &value, bool check_type = true);
0038 
0039    bool IsSame(const RAttrAggregation &src, bool use_style = true) const;
0040 
0041    bool IsValueEqual(const std::string &name, const RAttrMap::Value_t &value, bool use_style = false) const;
0042 
0043 public:
0044    RAttrAggregation() = default;
0045 
0046    RAttrAggregation(const RAttrAggregation &src) : RAttrBase() { src.CopyTo(*this); }
0047 
0048    RAttrAggregation(RDrawable *drawable, const char *prefix = nullptr) : RAttrBase(drawable, prefix) {}
0049    RAttrAggregation(RAttrBase *parent, const char *prefix = nullptr) : RAttrBase(parent, prefix) {}
0050 
0051    RAttrAggregation &operator=(const RAttrAggregation &src)
0052    {
0053       Clear();
0054       src.CopyTo(*this);
0055       return *this;
0056    }
0057 
0058    void Clear() override;
0059 
0060    friend bool operator==(const RAttrAggregation& lhs, const RAttrAggregation& rhs) { return lhs.IsSame(rhs) && rhs.IsSame(lhs); }
0061    friend bool operator!=(const RAttrAggregation& lhs, const RAttrAggregation& rhs) { return !lhs.IsSame(rhs) || !rhs.IsSame(lhs); }
0062 };
0063 
0064 } // namespace Experimental
0065 } // namespace ROOT
0066 
0067 #define R__ATTR_CLASS_DERIVED(ClassName,dflt_prefix,BaseClass) \
0068 protected: \
0069 const RAttrMap &GetDefaults() const override \
0070 { \
0071    static auto dflts = CollectDefaults(); \
0072    return dflts; \
0073 } \
0074 public: \
0075    ClassName() = default; \
0076    ClassName(RDrawable *drawable, const char *prefix = dflt_prefix) : BaseClass(drawable, prefix) {} \
0077    ClassName(RAttrBase *parent, const char *prefix = dflt_prefix) : BaseClass(parent, prefix) {} \
0078    ClassName(const ClassName &src) : ClassName() { src.CopyTo(*this); } \
0079    ClassName &operator=(const ClassName &src) { Clear(); src.CopyTo(*this); return *this; }
0080 
0081 
0082 #define R__ATTR_CLASS(ClassName,dflt_prefix) R__ATTR_CLASS_DERIVED(ClassName,dflt_prefix,RAttrAggregation)
0083 
0084 #endif