evio  6.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FileEventIndex.h
Go to the documentation of this file.
1 //
2 // Copyright 2020, Jefferson Science Associates, LLC.
3 // Subject to the terms in the LICENSE file found in the top-level directory.
4 //
5 // EPSCI Group
6 // Thomas Jefferson National Accelerator Facility
7 // 12000, Jefferson Ave, Newport News, VA 23606
8 // (757)-269-7100
9 
10 
11 #ifndef EVIO_6_0_FILEEVENTINDEX_H
12 #define EVIO_6_0_FILEEVENTINDEX_H
13 
14 
15 #include <string>
16 #include <iostream>
17 #include <iomanip>
18 #include <sstream>
19 #include <algorithm>
20 #include <vector>
21 
22 
23 namespace evio {
24 
25 
34 
35  private:
36 
38  uint32_t currentEvent = 0;
39 
42  uint32_t currentRecord = 0;
43 
45  uint32_t currentRecordEvent = 0;
46 
55  std::vector<uint32_t> recordIndex;
56 
57  public:
58 
60  FileEventIndex() = default;
61 
62  void clear();
63  void resetIndex();
64  void show();
65  void addEventSize(uint32_t size);
66 
67  uint32_t getEventNumber() const;
68  uint32_t getRecordNumber() const;
69  uint32_t getRecordEventNumber() const;
70  uint32_t getMaxEvents() const;
71 
72  bool canAdvance() const;
73  bool canRetreat() const;
74  bool advance();
75  bool retreat();
76  bool setEvent(uint32_t event);
77 
78  std::string toString();
79 
80  int main(int argc, char **argv);
81 
82  // TODO: overwrite = operator ???
83 
84  };
85 
86 }
87 
88 #endif //EVIO_6_0_FILEEVENTINDEX_H
void resetIndex()
Resets the current index to 0.
Definition: FileEventIndex.cpp:28
uint32_t getMaxEvents() const
Gets the total number of events in file.
Definition: FileEventIndex.cpp:82
bool advance()
Advances the current event number by one.
Definition: FileEventIndex.cpp:105
bool retreat()
Reduces current event number by one.
Definition: FileEventIndex.cpp:145
void addEventSize(uint32_t size)
Adds the number of events in the next record to the index of records.
Definition: FileEventIndex.cpp:40
uint32_t getRecordNumber() const
Gets the current record number which is set by setEvent(uint32_t), or by using advance() or retreat()...
Definition: FileEventIndex.cpp:67
void clear()
Clear the entire object.
Definition: FileEventIndex.cpp:18
std::string toString()
Get a string representation of this object.
Definition: FileEventIndex.cpp:221
Class used to handle event indexes in the context of a file (or buffer) and having to change records...
Definition: FileEventIndex.h:33
bool setEvent(uint32_t event)
Set the current event to the desired position.
Definition: FileEventIndex.cpp:184
uint32_t getEventNumber() const
Gets the current event number which is set by advance(), retreat() or setEvent(uint32_t) (which also ...
Definition: FileEventIndex.cpp:58
void show()
Prints the content of the event index array on the screen.
Definition: FileEventIndex.cpp:164
bool canAdvance() const
Checks to see if the event counter reached the end.
Definition: FileEventIndex.cpp:91
FileEventIndex()=default
Constructor.
bool canRetreat() const
Checks if the event index can retreat (decrease).
Definition: FileEventIndex.cpp:136
uint32_t getRecordEventNumber() const
Gets the event number inside the record that corresponds to the current global event number from the ...
Definition: FileEventIndex.cpp:75
int main(int argc, char **argv)
Definition: FileEventIndex.cpp:234