CurrentHistogram.cxx
Go to the documentation of this file.
2 #include <iostream>
3 using namespace om;
4 
6  fHistory(0),
7  fPlace(fHistory.end())
8 { }
9 
10 //......................................................................
11 
12 int CurrentHistogram::Set(const char* nm)
13 {
14 
15  //
16  // Check if we're already there...
17  //
18  if (fPlace != fHistory.end() && *fPlace == nm) return 0;
19 
20  //
21  // If we're at the front of the deque, add the new histo to the front.
22  //
23  if(fPlace == fHistory.begin()) fHistory.push_front(std::string(nm));
24 
25  // If we're in the middle of the deque, erase everything forward of this spot
26  // and add the new histo.
27  if(fPlace != fHistory.begin()) {
28 
29  // Erase entries between the [beginning and current place).
30  std::deque<std::string>::iterator i1(fHistory.begin());
31  std::deque<std::string>::iterator i2(fPlace);
32  fHistory.erase(i1, i2);
33 
34  // Add histo to the new beginning.
35  fHistory.push_front(std::string(nm));
36 
37  }
38 
39  //
40  // If we've grown too big, truncate by dropping oldest entries at
41  // beginning of list.
42  //
43  if (fHistory.size() > kMaxHistory) fHistory.resize(kMaxHistory);
44 
45  //
46  // Set our place in the history to the new end of the list
47  //
48  fPlace = fHistory.begin();
49 
50  return 1;
51 
52 }
53 
54 //......................................................................
55 
57 {
58  if (fPlace == fHistory.begin()) return false;
59  return true;
60 }
61 
62 //......................................................................
63 
65 {
66  std::deque<std::string>::iterator i(fPlace+1);
67  if (i >= fHistory.end()) return false;
68  return true;
69 }
70 
71 //......................................................................
72 
74 {
75  if (fPlace == fHistory.end() || *fPlace == "") return false;
76  return true;
77 }
78 
79 //......................................................................
80 
82 {
83  if (this->ForwardOK()) { --fPlace; return 1; }
84  return 0;
85 }
86 
87 //......................................................................
88 
90 {
91  if (this->BackwardOK()) { ++fPlace; return 1; }
92  return 0;
93 }
94 
95 //......................................................................
96 
97 const char* CurrentHistogram::Current() const
98 {
99  if (fPlace == fHistory.end()) return "";
100  return fPlace->c_str();
101 }
102 
103 ////////////////////////////////////////////////////////////////////////
int Set(const char *nm)
static const unsigned int kMaxHistory
< How deep do we allow the history to go?
static constexpr Double_t nm
Definition: Munits.h:133
std::deque< std::string > fHistory
const char * Current() const
std::deque< std::string >::iterator fPlace
Online Monitoring package header.
enum BeamMode string