Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
RDisplayItem.cxx
Go to the documentation of this file.
1 /*************************************************************************
2  * Copyright (C) 1995-2017, 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/RDisplayItem.hxx"
10 
11 #include "ROOT/RDrawable.hxx"
12 
13 #include "TString.h"
14 
15 ////////////////////////////////////////////////////////////////////////////
16 /// Assign id using arbitrary pointer value
17 /// Typically drawable pointer should be used here
18 
19 void ROOT::Experimental::RDisplayItem::SetObjectIDAsPtr(const void *ptr)
20 {
21  SetObjectID(ObjectIDFromPtr(ptr));
22 }
23 
24 void ROOT::Experimental::RDisplayItem::BuildFullId(const std::string &prefix)
25 {
26  SetObjectID(prefix + std::to_string(GetIndex()) + "_" + GetObjectID());
27 }
28 
29 std::string ROOT::Experimental::RDisplayItem::ObjectIDFromPtr(const void *ptr)
30 {
31  auto hash = TString::Hash(&ptr, sizeof(ptr));
32  return std::to_string(hash);
33 }