GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TDataLoop.h
Go to the documentation of this file.
1#ifndef TDATALOOP_H
2#define TDATALOOP_H
3
4/** \addtogroup Loops
5 * @{
6 */
7
8////////////////////////////////////////////////////////////////////////////////
9///
10/// \class TDataLoop
11///
12/// This loop reads raw events from a raw file.
13///
14////////////////////////////////////////////////////////////////////////////////
15
16#ifndef __CINT__
17#include <memory>
18#endif
19
20#include <cstdlib>
21
22#include "StoppableThread.h"
23#include "ThreadsafeQueue.h"
24#include "TRawFile.h"
25#include "TRawEvent.h"
26
27class TDataLoop : public StoppableThread {
28public:
29 static TDataLoop* Get(std::string name = "", TRawFile* source = nullptr);
30 TDataLoop(const TDataLoop&) = delete;
31 TDataLoop(TDataLoop&&) noexcept = delete;
32 TDataLoop& operator=(const TDataLoop&) = delete;
33 TDataLoop& operator=(TDataLoop&&) noexcept = delete;
34 ~TDataLoop() = default;
35
36#ifndef __CINT__
37 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<TRawEvent>>>& OutputQueue()
38 {
39 return fOutputQueue;
40 }
41#endif
42
43 const TRawFile& GetSource() const
44 {
45 return *fSource;
46 }
47
48 void ClearQueue() override;
49
50 bool Iteration() override;
51 void OnEnd() override;
52
53 size_t GetItemsPushed() override { return fOutputQueue->ItemsPushed(); }
54 size_t GetItemsPopped() override { return fOutputQueue->ItemsPopped(); }
55 size_t GetItemsCurrent() override { return fOutputQueue->Size(); }
56 size_t GetRate() override { return 0; }
57
58 void ReplaceSource(TRawFile* new_source);
59
60 void SetSelfStopping(bool self_stopping) { fSelfStopping = self_stopping; }
61 bool GetSelfStopping() const { return fSelfStopping; }
62
63private:
64 TDataLoop(std::string name, TRawFile* source);
66
70
71#ifndef __CINT__
72 std::shared_ptr<ThreadsafeQueue<std::shared_ptr<TRawEvent>>> fOutputQueue;
73 std::mutex fSourceMutex;
74#endif
75
76 /// \cond CLASSIMP
77 ClassDefOverride(TDataLoop, 0) // NOLINT(readability-else-after-return)
78 /// \endcond
79};
80
81/*! @} */
82#endif /* _TDATALOOP_H_ */
size_t GetRate() override
Definition TDataLoop.h:56
size_t GetItemsCurrent() override
Definition TDataLoop.h:55
size_t GetItemsPushed() override
Definition TDataLoop.h:53
TRawFile * fSource
Definition TDataLoop.h:67
void ReplaceSource(TRawFile *new_source)
Definition TDataLoop.cxx:36
bool fSelfStopping
Definition TDataLoop.h:68
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< TRawEvent > > > fOutputQueue
Definition TDataLoop.h:72
static TDataLoop * Get(std::string name="", TRawFile *source=nullptr)
Definition TDataLoop.cxx:16
std::shared_ptr< ThreadsafeQueue< std::shared_ptr< TRawEvent > > > & OutputQueue()
Definition TDataLoop.h:37
size_t GetItemsPopped() override
Definition TDataLoop.h:54
void SetSelfStopping(bool self_stopping)
Definition TDataLoop.h:60
void OnEnd() override
Definition TDataLoop.cxx:43
size_t fEventsRead
Definition TDataLoop.h:69
void ClearQueue() override
Definition TDataLoop.cxx:28
bool GetSelfStopping() const
Definition TDataLoop.h:61
TDataLoop(const TDataLoop &)=delete
const TRawFile & GetSource() const
Definition TDataLoop.h:43
std::mutex fSourceMutex
Definition TDataLoop.h:73
bool Iteration() override
Definition TDataLoop.cxx:48
TDataLoop(TDataLoop &&) noexcept=delete
Reader for raw files.
Definition TRawFile.h:31