Jpp 21.0.0-rc.1-88-g0130508c4
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* const 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 /**
35 * Constructor.
36 *
37 * \param __p pointer to object
38 */
41 {
42 label = get()->GetName();
43 }
44
45
46 /**
47 * Constructor.
48 *
49 * \param __p pointer to object
50 * \param __label label
51 */
53 const TString& __label):
55 {
56 this->label = __label;
57 }
58
59
60 /**
61 * Get label.
62 *
63 * \return label
64 */
65 TString getLabel() const
66 {
67 TString buffer(this->label);
68
69 const Ssiz_t pos = buffer.Index(LABEL_TERMINATOR);
70
71 if (pos != kNPOS) {
72 buffer = buffer(0, pos);
73 }
74
75 return buffer;
76 }
77
78
79 /**
80 * Set label.
81 *
82 * \param label label
83 */
84 void setLabel(const TString& label)
85 {
86 this->label = label;
87 }
88
89
90 /**
91 * Draw object.
92 */
93 void Draw(const std::string& option) const
94 {
95 this->get()->Draw(option.c_str());
96 }
97
98 protected:
99 TString label;
100 };
101}
102
103#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 *const 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).