forked from hep-cce2/root_serialization
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSourceBase.h
More file actions
39 lines (29 loc) · 1010 Bytes
/
SourceBase.h
File metadata and controls
39 lines (29 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#if !defined(SourceBase_h)
#define SourceBase_h
#include "DataProductRetriever.h"
#include "EventIdentifier.h"
#include <vector>
#include <chrono>
namespace cce::tf {
class SourceBase {
public:
explicit SourceBase():
accumulatedTime_{std::chrono::microseconds::zero()} {}
virtual ~SourceBase() {}
virtual size_t numberOfDataProducts() const = 0;
virtual std::vector<DataProductRetriever>& dataProducts() = 0;
virtual EventIdentifier eventIdentifier() = 0;
bool gotoEvent(long iEventIndex);
std::chrono::microseconds accumulatedTime() const { return accumulatedTime_;}
private:
virtual bool readEvent(long iEventIndex) = 0;
std::chrono::microseconds accumulatedTime_;
};
inline bool SourceBase::gotoEvent(long iEventIndex) {
auto start = std::chrono::high_resolution_clock::now();
auto more = readEvent(iEventIndex);
accumulatedTime_ += std::chrono::duration_cast<decltype(accumulatedTime_)>(std::chrono::high_resolution_clock::now() - start);
return more;
}
}
#endif