Jpp  16.0.1
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFrame_t.hh
Go to the documentation of this file.
1 #ifndef __JTRIGGER__JFRAME_T__
2 #define __JTRIGGER__JFRAME_T__
3 
4 #include <vector>
5 
7 
8 
9 /**
10  * \author mdejong
11  */
12 
13 namespace JTRIGGER {}
14 namespace JPP { using namespace JTRIGGER; }
15 
16 namespace JTRIGGER {
17 
18  /**
19  * Data frame with end marker.
20  *
21  * The end marker is a special element that is used in JTOOLS::JMergeSort to speed up the sorting of data.\n
22  * It is placed within the capacity of the container whilst its size is maintained.\n
23  * Here, it is defined by an element of which the time is larger than any possible nominal value.\n
24  * The end marker should manually be put using method putEndMarker() after modifications of the contents of the container.
25  */
26  template<class JElement_t, class JAllocator_t = std::allocator<JElement_t> >
27  class JFrame_t :
28  public std::vector<JElement_t, JAllocator_t>,
29  public JHitToolkit<JElement_t>
30  {
31  public:
32  /**
33  * Default constructor.
34  *
35  * Empty container with end marker.
36  */
38  {
39  this->putEndMarker();
40  }
41 
42 
43  /**
44  * Copy constructor.
45  *
46  * \param frame frame
47  */
48  JFrame_t(const JFrame_t& frame) :
49  std::vector<JElement_t, JAllocator_t>(frame.begin(), frame.end())
50  {
51  this->putEndMarker();
52  }
53 
54 
55  /**
56  * Move constructor.
57  *
58  * \param frame frame
59  */
61  {
62  this->swap(frame);
63  this->putEndMarker();
64  }
65 
66 
67  /**
68  * Assignment operator.
69  *
70  * \param frame frame
71  * \return this frame
72  */
73  JFrame_t& operator=(const JFrame_t& frame)
74  {
75  this->assign(frame.begin(), frame.end());
76  this->putEndMarker();
77 
78  return *this;
79  }
80 
81 
82  /**
83  * Check presence of end marker.
84  *
85  * \return true if end marker present; else false
86  */
87  bool hasEndMarker() const
88  {
89  return (this->capacity() > this->size() && this->getT(*(this->end())) == this->getT(this->getEndMarker()));
90  }
91 
92 
93  /**
94  * Append end marker to data.
95  */
96  void putEndMarker()
97  {
98  if (this->capacity() <= this->size()) {
99  this->reserve(this->size() + 1);
100  }
101 
102  *(this->end()) = this->getEndMarker();
103  }
104 
105 
106  /**
107  * Reset.
108  *
109  * Clear container and put end marker.
110  */
111  void reset()
112  {
113  this->clear();
114  this->putEndMarker();
115  }
116  };
117 }
118 
119 #endif
Data frame with end marker.
Definition: JFrame_t.hh:27
JFrame_t(JFrame_t &frame)
Move constructor.
Definition: JFrame_t.hh:60
Tools for handling different hit types.
void reset()
Reset.
Definition: JFrame_t.hh:111
JAssignSequence< typename JContainer_t::value_type > assign(JContainer_t &out)
Helper method to assign sequence of Comma Separated Values to output container.
Definition: JCSV.hh:129
JFrame_t & operator=(const JFrame_t &frame)
Assignment operator.
Definition: JFrame_t.hh:73
bool hasEndMarker() const
Check presence of end marker.
Definition: JFrame_t.hh:87
JFrame_t(const JFrame_t &frame)
Copy constructor.
Definition: JFrame_t.hh:48
Template definition of hit toolkit.
Definition: JHitToolkit.hh:60
void putEndMarker()
Append end marker to data.
Definition: JFrame_t.hh:96
JFrame_t()
Default constructor.
Definition: JFrame_t.hh:37