Logo ROOT  
Reference Guide
RAttrMap.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/RAttrMap.hxx"
10
11#include "ROOT/RAttrBase.hxx"
12#include "ROOT/RLogger.hxx"
13
14template<> bool ROOT::Experimental::RAttrMap::Value_t::Get<bool>() const { return GetBool(); }
15template<> int ROOT::Experimental::RAttrMap::Value_t::Get<int>() const { return GetInt(); }
16template<> double ROOT::Experimental::RAttrMap::Value_t::Get<double>() const { return GetDouble(); }
17template<> std::string ROOT::Experimental::RAttrMap::Value_t::Get<std::string>() const { return GetString(); }
18
19template<> bool ROOT::Experimental::RAttrMap::Value_t::GetValue<bool,void>(const Value_t *rec) { return rec ? rec->GetBool() : false; }
20template<> int ROOT::Experimental::RAttrMap::Value_t::GetValue<int,void>(const Value_t *rec) { return rec ? rec->GetInt() : 0; }
21template<> double ROOT::Experimental::RAttrMap::Value_t::GetValue<double,void>(const Value_t *rec) { return rec ? rec->GetDouble() : 0.; }
22template<> std::string ROOT::Experimental::RAttrMap::Value_t::GetValue<std::string,void>(const Value_t *rec) { return rec ? rec->GetString() : ""; }
23
24template<> const ROOT::Experimental::RAttrMap::Value_t *ROOT::Experimental::RAttrMap::Value_t::GetValue<const ROOT::Experimental::RAttrMap::Value_t *,void>(const Value_t *rec) { return rec; }
25template<> const ROOT::Experimental::RAttrMap::Value_t *ROOT::Experimental::RAttrMap::Value_t::GetValue<const ROOT::Experimental::RAttrMap::Value_t *,bool>(const Value_t *rec) { return rec && rec->Kind() == RAttrMap::kBool ? rec : nullptr; }
26template<> const ROOT::Experimental::RAttrMap::Value_t *ROOT::Experimental::RAttrMap::Value_t::GetValue<const ROOT::Experimental::RAttrMap::Value_t *,int>(const Value_t *rec) { return rec && rec->Kind() == RAttrMap::kInt ? rec : nullptr; }
27template<> const ROOT::Experimental::RAttrMap::Value_t *ROOT::Experimental::RAttrMap::Value_t::GetValue<const ROOT::Experimental::RAttrMap::Value_t *,double>(const Value_t *rec) { return rec && rec->Kind() == RAttrMap::kDouble ? rec : nullptr; }
28template<> const ROOT::Experimental::RAttrMap::Value_t *ROOT::Experimental::RAttrMap::Value_t::GetValue<const ROOT::Experimental::RAttrMap::Value_t *,std::string>(const Value_t *rec) { return rec && rec->Kind() == RAttrMap::kString ? rec : nullptr; }
29
30
31using namespace std::string_literals;
32
34{
35 auto prefix = vis.GetPrefix();
36
37 for (const auto &entry : vis.GetDefaults())
38 m[prefix+entry.first] = entry.second->Copy();
39
40 return *this;
41}
Base class for all attributes, used with RDrawable.
Definition: RAttrBase.hxx:27
const std::string & GetPrefix() const
Definition: RAttrBase.hxx:151
virtual const RAttrMap & GetDefaults() const
Return default values for attributes, empty for base class.
Definition: RAttrBase.cxx:17
virtual EValuesKind Kind() const =0
RAttrMap & AddDefaults(const RAttrBase &vis)
Definition: RAttrMap.cxx:33
std::unordered_map< std::string, std::unique_ptr< Value_t > > m
JSON_object.
Definition: RAttrMap.hxx:102