Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrValue.hxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2020, 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_RAttrValue
10#define ROOT7_RAttrValue
11
12#include <ROOT/RAttrBase.hxx>
13
14namespace ROOT {
15namespace Experimental {
16
17/** \class RAttrValue
18\ingroup GpadROOT7
19\author Sergey Linev <s.linev@gsi.de>
20\date 2020-06-24
21\brief Template class to access single value from drawable or other 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
26template<typename T>
27class RAttrValue : public RAttrBase {
28protected:
29
30 RAttrMap fDefaults; ///<! map with default values
31
32 const RAttrMap &GetDefaults() const override { return fDefaults; }
33
34 bool IsValue() const override { return true; }
35
36public:
37
38 RAttrValue() = default;
39
40 RAttrValue(RDrawable *drawable, const std::string &name, const T &dflt = T())
41 {
42 fDefaults.AddValue("", dflt);
43 AssignDrawable(drawable, name);
44 }
45
46 RAttrValue(RAttrBase *parent, const std::string &name, const T &dflt = T())
47 {
48 fDefaults.AddValue("", dflt);
49 AssignParent(parent, name);
50 }
51
52 void Set(const T &v) { SetValue("", v); }
53 T Get() const { return GetValue<T>(""); }
54 void Clear() { ClearValue(""); }
55 bool Has() const { return HasValue<T>(""); }
56
57 RAttrValue &operator=(const T &v) { Set(v); return *this; }
58
59 operator T() const { return Get(); }
60};
61
62} // namespace Experimental
63} // namespace ROOT
64
65#endif // ROOT7_RAttrValue
char name[80]
Definition TGX11.cxx:110
Base class for all attributes, used with RDrawable.
Definition RAttrBase.hxx:31
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.
void SetValue(const std::string &name, bool value)
Set boolean value.
void AssignParent(RAttrBase *parent, const std::string &prefix)
Assign parent object for this RAttrBase.
RAttrMap & AddValue(const std::string &name, bool value)
Definition RAttrMap.hxx:157
Template class to access single value from drawable or other attributes.
RAttrMap fDefaults
! map with default values
bool IsValue() const override
RAttrValue & operator=(const T &v)
RAttrValue(RDrawable *drawable, const std::string &name, const T &dflt=T())
const RAttrMap & GetDefaults() const override
Return default values for attributes, empty for base class.
RAttrValue(RAttrBase *parent, const std::string &name, const T &dflt=T())
Base class for drawable entities: objects that can be painted on a RPad.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...