Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLineAttributes.hh
Go to the documentation of this file.
1#ifndef __JROOT__JLINEATTRIBUTES__
2#define __JROOT__JLINEATTRIBUTES__
3
4#include <vector>
5
6#include "TAttLine.h"
7
9
10
11/**
12 * \author mdejong
13 */
14
15namespace JROOT {}
16namespace JPP { using namespace JROOT; }
17
18namespace JROOT {
19
21
22
23 /**
24 * Auxiliary class to set line attributes.
25 */
27 public JRewindableObjectIterator<TAttLine>,
28 public std::vector <TAttLine>
29 {
30 public:
31
33
34
35 /**
36 * Constructor.
37 *
38 * \param width line width
39 */
40 JLineAttributes(const Width_t width = 2) :
41 std::vector<TAttLine>(),
42 index(0)
43 {
44 for (int i = 1; i <= 10; ++i) {
45 push_back(TAttLine(kBlack, i, width));
46 }
47 }
48
49
50 /**
51 * Get reference to unique instance of this class object.
52 *
53 * \return reference to this class object
54 */
56 {
57 static JLineAttributes line(2);
58
59 return line;
60 }
61
62
63 /**
64 * Set line width.
65 *
66 * \param width line width
67 */
68 void setLineWidth(const Width_t width)
69 {
70 for (iterator i = this->begin(); i != this->end(); ++i) {
71 i->SetLineWidth(width);
72 }
73 }
74
75
76 /**
77 * Rewind index.
78 */
79 virtual void rewind() override
80 {
81 index = 0;
82 }
83
84
85 /**
86 * Check availability of next element.
87 *
88 * \return true if the iteration has more elements; else false
89 */
90 virtual bool hasNext() override
91 {
92 return !this->empty();
93 }
94
95
96 /**
97 * Get next element.
98 *
99 * \return pointer to element
100 */
101 virtual const pointer_type& next() override
102 {
103 static pointer_type ps;
104
105 if (index < this->size()) {
106 ps.reset(&this->at(index));
107 }
108
109 ++index;
110
111 index = index%this->size();
112
113 return ps;
114 }
115
116
117 /**
118 * Get line attributes.
119 *
120 * \param index index
121 * \return line attributes
122 */
123 const TAttLine& get(unsigned int index)
124 {
125 return this->at(index%this->size());
126 }
127
128
129 private:
130 unsigned int index;
131 };
132}
133
134#endif
virtual void reset() override
Reset pointer.
Definition JPointer.hh:84
Interface for object iteration with rewinding.
Auxiliary class to set line attributes.
static JLineAttributes & getInstance()
Get reference to unique instance of this class object.
void setLineWidth(const Width_t width)
Set line width.
const TAttLine & get(unsigned int index)
Get line attributes.
virtual bool hasNext() override
Check availability of next element.
virtual void rewind() override
Rewind index.
JLineAttributes(const Width_t width=2)
Constructor.
JRewindableObjectIterator< TAttLine >::pointer_type pointer_type
virtual const pointer_type & next() override
Get next element.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for ROOT I/O.