Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RAttrBase.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2019, 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#include <ROOT/RAttrBase.hxx>
10
11#include <ROOT/RLogger.hxx>
12
13#include <utility>
14
15using namespace ROOT::Experimental;
16
18{
19 static RLogChannel sLog("ROOT.GPad");
20 return sLog;
21}
22
23///////////////////////////////////////////////////////////////////////////////
24/// Clear internal data
25
27{
28 if ((fKind == kOwnAttr) && fD.ownattr) {
29 delete fD.ownattr;
30 fD.ownattr = nullptr;
31 }
32}
33
34///////////////////////////////////////////////////////////////////////////////
35/// Creates own attribute - only if no drawable and no parent are assigned
36
38{
39 if (((fKind == kParent) && !fD.parent) || ((fKind == kDrawable) && !fD.drawable))
40 fKind = kOwnAttr;
41
42 if (fKind != kOwnAttr)
43 return nullptr;
44
45 if (!fD.ownattr)
46 fD.ownattr = new RAttrMap();
47
48 return fD.ownattr;
49}
50
51///////////////////////////////////////////////////////////////////////////////
52/// Clear value if any with specified name
53
54void RAttrBase::ClearValue(const std::string &name)
55{
56 if (auto access = AccessAttr(name))
57 access.attr->Clear(access.fullname);
58}
59
60///////////////////////////////////////////////////////////////////////////////
61/// Set `<NoValue>` for attribute. Ensure that value can not be configured via style - defaults will be used
62/// Equivalent to css syntax { attrname:; }
63
64void RAttrBase::SetNoValue(const std::string &name)
65{
66 if (auto access = AccessAttr(name))
67 access.attr->AddNoValue(access.fullname);
68}
69
70///////////////////////////////////////////////////////////////////////////////
71/// Move all fields into target object
72
74{
75 std::swap(fKind, tgt.fKind);
76 std::swap(fD, tgt.fD);
77 std::swap(fPrefix, tgt.fPrefix);
78}
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.
Definition RAttrBase.cxx:54
const Rec_t AccessAttr(const std::string &name) const
Find attributes container and full-qualified name for value.
Definition RAttrBase.hxx:68
void MoveTo(RAttrBase &tgt)
Move all fields into target object.
Definition RAttrBase.cxx:73
const char * fPrefix
! name prefix for all attributes values
Definition RAttrBase.hxx:43
enum ROOT::Experimental::RAttrBase::@41 kDrawable
! kind of data
RAttrMap * CreateOwnAttr()
Creates own attribute - only if no drawable and no parent are assigned.
Definition RAttrBase.cxx:37
void ClearData()
Clear internal data.
Definition RAttrBase.cxx:26
void SetNoValue(const std::string &name)
Set <NoValue> for attribute.
Definition RAttrBase.cxx:64
A log configuration for a channel, e.g.
Definition RLogger.hxx:101
RLogChannel & GPadLog()
Log channel for GPad diagnostics.
Definition RAttrBase.cxx:17