Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
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
16namespace JGIZMO {}
17namespace JPP { using namespace JGIZMO; }
18
19namespace 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 */
30 public JPointer<TObject>
31 {
32 public:
33 /**
34 * Constructor.
35 *
36 * \param __p pointer to object
37 */
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):
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
Auxiliary data structure for TObject with a user defined label.
JRootObject(TObject *__p)
Constructor.
void Draw(const std::string &option) const
Draw object.
TString getLabel() const
Get label.
JRootObject(TObject *__p, const TString &__label)
Constructor.
void setLabel(const TString &label)
Set label.
Template implementation of class that holds pointer to object(s).
Definition JPointer.hh:24
virtual JClass_t * get() const override
Get pointer.
Definition JPointer.hh:64
JClass_t * __p
pointer to object
Definition JPointer.hh:136
Auxiliary applications for use of ROOT and more.
static const char LABEL_TERMINATOR
label terminator
Auxiliary classes and methods for language specific functionality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).