Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 
14 template<> bool ROOT::Experimental::RAttrMap::Value_t::Get<bool>() const { return GetBool(); }
15 template<> int ROOT::Experimental::RAttrMap::Value_t::Get<int>() const { return GetInt(); }
16 template<> double ROOT::Experimental::RAttrMap::Value_t::Get<double>() const { return GetDouble(); }
17 template<> std::string ROOT::Experimental::RAttrMap::Value_t::Get<std::string>() const { return GetString(); }
18 
19 template<> bool ROOT::Experimental::RAttrMap::Value_t::GetValue<bool,void>(const Value_t *rec) { return rec ? rec->GetBool() : false; }
20 template<> int ROOT::Experimental::RAttrMap::Value_t::GetValue<int,void>(const Value_t *rec) { return rec ? rec->GetInt() : 0; }
21 template<> double ROOT::Experimental::RAttrMap::Value_t::GetValue<double,void>(const Value_t *rec) { return rec ? rec->GetDouble() : 0.; }
22 template<> std::string ROOT::Experimental::RAttrMap::Value_t::GetValue<std::string,void>(const Value_t *rec) { return rec ? rec->GetString() : ""; }
23 
24 template<> 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; }
25 template<> 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; }
26 template<> 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; }
27 template<> 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; }
28 template<> 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 
31 using namespace std::string_literals;
32 
33 ROOT::Experimental::RAttrMap &ROOT::Experimental::RAttrMap::AddDefaults(const RAttrBase &vis)
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 }