Jpp  15.0.1-rc.1-highqe
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JRootObject.hh
Go to the documentation of this file.
1 #ifndef __JGIZMO__JROOTOBJECT__
2 #define __JGIZMO__JROOTOBJECT__
3 
4 #include <string>
5 
6 #include "TObject.h"
7 #include "TString.h"
8 
9 #include "JLang/JPointer.hh"
10 
11 
12 /**
13  * \author mdejong
14  */
15 
16 namespace JGIZMO {}
17 namespace JPP { using namespace JGIZMO; }
18 
19 namespace JGIZMO {
20 
21  using JLANG::JPointer;
22 
23  static const char LABEL_TERMINATOR = '&'; //!< label terminator
24 
25 
26  /**
27  * Auxiliary data structure for TObject with a user defined label.
28  */
29  class JRootObject :
30  public JPointer<TObject>
31  {
32  public:
33  /**
34  * Constructor.
35  *
36  * \param __p pointer to object
37  */
39  JLANG::JPointer<TObject>(__p)
40  {
41  label = get()->GetName();
42  }
43 
44 
45  /**
46  * Constructor.
47  *
48  * \param __p pointer to object
49  * \param __label label
50  */
52  const TString& __label):
53  JLANG::JPointer<TObject>(__p)
54  {
55  this->label = __label;
56  }
57 
58 
59  /**
60  * Get label.
61  *
62  * \return label
63  */
64  TString getLabel() const
65  {
66  TString buffer(this->label);
67 
68  const Ssiz_t pos = buffer.Last(LABEL_TERMINATOR);
69 
70  if (pos != kNPOS) {
71  buffer = buffer(0, pos);
72  }
73 
74  return buffer;
75  }
76 
77 
78  /**
79  * Set label.
80  *
81  * \param label label
82  */
83  void setLabel(const TString& label)
84  {
85  this->label = label;
86  }
87 
88 
89  /**
90  * Draw object.
91  */
92  void Draw(const std::string& option) const
93  {
94  this->get()->Draw(option.c_str());
95  }
96 
97  protected:
98  TString label;
99  };
100 }
101 
102 #endif
JClass_t * __p
pointer to object
Definition: JPointer.hh:136
Definition: JRoot.hh:19
JRootObject(TObject *__p)
Constructor.
Definition: JRootObject.hh:38
Auxiliary data structure for TObject with a user defined label.
Definition: JRootObject.hh:29
Template implementation of class that holds pointer to object(s).
Definition: JPointer.hh:22
JRootObject(TObject *__p, const TString &__label)
Constructor.
Definition: JRootObject.hh:51
static const char LABEL_TERMINATOR
label terminator
Definition: JRootObject.hh:23
void Draw(const std::string &option) const
Draw object.
Definition: JRootObject.hh:92
TString getLabel() const
Get label.
Definition: JRootObject.hh:64
void setLabel(const TString &label)
Set label.
Definition: JRootObject.hh:83