15#include <unordered_map>
21namespace Experimental {
48 virtual bool GetBool()
const {
return false; }
49 virtual int GetInt()
const {
return 0; }
51 virtual std::string
GetString()
const {
return ""; }
53 virtual std::unique_ptr<Value_t>
Copy()
const = 0;
55 template<
typename T> T
Get()
const;
57 template <
typename RET_TYPE,
typename MATCH_TYPE =
void>
65 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<NoValue_t>(); }
77 int GetInt() const final {
return v ? 1 : 0; }
79 std::string
GetString() const final {
return v ?
"true" :
"false"; }
80 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<BoolValue_t>(
v); }
91 bool GetBool() const final {
return v ? true :
false; }
94 std::string
GetString() const final {
return std::to_string(
v); }
95 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<IntValue_t>(
v); }
106 bool GetBool() const final {
return v ? true :
false; }
109 std::string
GetString() const final {
return std::to_string(
v); }
110 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<DoubleValue_t>(
v); }
123 bool GetBool() const final {
return v.compare(
"true") == 0; }
126 std::unique_ptr<Value_t>
Copy() const final {
return std::make_unique<StringValue_t>(
v); }
133 std::unordered_map<std::string, std::unique_ptr<Value_t>>
m;
152 m[
name] = std::make_unique<StringValue_t>(
value.AsString());
160 m[
name] = std::make_unique<StringValue_t>(
value.AsString());
174 for (
const auto &pair :
src.m)
175 m[pair.first] = pair.second->Copy();
181 for (
const auto &pair :
src.m)
182 m[pair.first] = pair.second->Copy();
188 auto entry =
m.find(
name);
189 return (entry !=
m.end()) ? entry->second.get() :
nullptr;
195 auto entry =
m.find(
name);
196 if (entry !=
m.end())
203 auto end()
const {
return m.end(); }
206template<>
bool RAttrMap::Value_t::Get<bool>()
const;
207template<>
int RAttrMap::Value_t::Get<int>()
const;
208template<>
double RAttrMap::Value_t::Get<double>()
const;
209template<> std::string RAttrMap::Value_t::Get<std::string>()
const;
210template<> RPadLength RAttrMap::Value_t::Get<RPadLength>()
const;
211template<> RColor RAttrMap::Value_t::Get<RColor>()
const;
213template<>
bool RAttrMap::Value_t::GetValue<bool,void>(
const Value_t *rec);
214template<>
int RAttrMap::Value_t::GetValue<int,void>(
const Value_t *rec);
215template<>
double RAttrMap::Value_t::GetValue<double,void>(
const Value_t *rec);
216template<> std::string RAttrMap::Value_t::GetValue<std::string,void>(
const Value_t *rec);
217template<> RPadLength RAttrMap::Value_t::GetValue<RPadLength,void>(
const Value_t *rec);
218template<> RColor RAttrMap::Value_t::GetValue<RColor,void>(
const Value_t *rec);
220template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,void>(
const Value_t *rec);
221template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,bool>(
const Value_t *rec);
222template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,int>(
const Value_t *rec);
223template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,double>(
const Value_t *rec);
224template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,std::string>(
const Value_t *rec);
225template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,RPadLength>(
const Value_t *rec);
226template<>
const RAttrMap::Value_t *RAttrMap::Value_t::GetValue<const RAttrMap::Value_t *,RColor>(
const Value_t *rec);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
Base class for all attributes, used with RDrawable.
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
double GetDouble() const final
bool CanConvertFrom(EValuesKind kind) const final
bool CanConvertTo(EValuesKind kind) const final
std::string GetString() const final
BoolValue_t(bool _v=false)
bool GetBool() const final
bool IsEqual(const Value_t &tgt) const final
std::unique_ptr< Value_t > Copy() const final
bool CanConvertFrom(EValuesKind kind) const final
bool IsEqual(const Value_t &tgt) const final
double GetDouble() const final
DoubleValue_t(double _v=0)
std::string GetString() const final
EValuesKind Kind() const final
bool GetBool() const final
bool CanConvertTo(EValuesKind kind) const final
double GetDouble() const final
EValuesKind Kind() const final
bool CanConvertFrom(EValuesKind kind) const final
bool GetBool() const final
std::string GetString() const final
bool CanConvertTo(EValuesKind kind) const final
std::unique_ptr< Value_t > Copy() const final
bool IsEqual(const Value_t &tgt) const final
bool IsEqual(const Value_t &tgt) const final
EValuesKind Kind() const final
std::unique_ptr< Value_t > Copy() const final
std::string GetString() const final
bool GetBool() const final
bool IsEqual(const Value_t &tgt) const final
StringValue_t(const std::string _v="")
std::string v
string value
bool CanConvertTo(EValuesKind kind) const final
std::unique_ptr< Value_t > Copy() const final
bool CanConvertFrom(EValuesKind) const final
EValuesKind Kind() const final
virtual std::string GetString() const
virtual bool CanConvertTo(EValuesKind kind) const
virtual bool GetBool() const
virtual ~Value_t()=default
virtual EValuesKind Kind() const =0
virtual std::unique_ptr< Value_t > Copy() const =0
virtual bool CanConvertFrom(EValuesKind kind) const
static RET_TYPE GetValue(const Value_t *rec)
virtual int GetInt() const
virtual double GetDouble() const
virtual bool IsEqual(const Value_t &) const
RAttrMap & AddString(const std::string &name, const std::string &value)
const Value_t * Find(const std::string &name) const
RAttrMap & AddValue(const std::string &name, bool value)
RAttrMap & AddDouble(const std::string &name, double value)
RAttrMap & AddNoValue(const std::string &name)
RAttrMap & operator=(const RAttrMap &src)
RAttrMap(const RAttrMap &src)
RAttrMap & AddValue(const std::string &name, double value)
std::unordered_map< std::string, std::unique_ptr< Value_t > > m
JSON_object.
RAttrMap & AddInt(const std::string &name, int value)
bool Change(const std::string &name, Value_t *value=nullptr)
Change attribute using string value and kind Used to change attributes from JS side Returns true if v...
RAttrMap & AddColor(const std::string &name, const RColor &value)
RAttrMap & AddValue(const std::string &name, const RColor &value)
RAttrMap & AddPadLength(const std::string &name, const RPadLength &value)
RAttrMap & AddBool(const std::string &name, bool value)
RAttrMap & AddValue(const std::string &name, const RPadLength &value)
RAttrMap & AddDefaults(const RAttrBase &vis)
Add defaults values form sub attribute.
void Clear(const std::string &name)
Clear specified attribute.
void AddBestMatch(const std::string &name, const std::string &value)
Add attribute, converting to best possible type Tested boolean, int, double.
RAttrMap & Add(const std::string &name, std::unique_ptr< Value_t > &&value)
RAttrMap & AddValue(const std::string &name, const std::string &value)
RAttrMap()=default
JSON_asbase - store as map object.
RAttrMap & AddValue(const std::string &name, int value)
A set of defaults for graphics attributes, e.g.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.