ATLAS Offline Software
Loading...
Searching...
No Matches
JetStreamer.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGHLTJETHYPO_JETSTEAMER_H
6#define TRIGHLTJETHYPO_JETSTEAMER_H
7
8/*
9 * JetStreamer owns a linked list of IJetStream objects.
10 * These provide vectors of indices according to the conrete types.
11 * The stream objects cycle, which allows for stepping through
12 * all possible combinations of jets. On each call to bump an element
13 * in the list informs its left neigbor if the fact. The
14 * the cycle state is relayed back to JetStreamer: when all elements
15 * in the list have cycled, the iteration stops.
16 */
17
18#include "./IJetStream.h"
19#include "./SimpleJetStream.h"
21
22#include <sstream>
23#include <ostream>
24
26
27 public:
28
29 friend std::ostream& operator << (std::ostream&, const JetStreamer&);
30 friend std::ostream& operator << (std::stringstream&, const JetStreamer&);
31
32
33 JetStreamer(std::unique_ptr<IJetStream>&& stream) :
34 m_stream(std::move(stream))
35 {
36 m_valid = m_stream != nullptr and m_stream->valid();
37 }
38
39
40 std::vector<std::size_t> next() {
41
42 if (!m_valid) {
43 return std::vector<std::size_t>();
44 }
45
46 if (m_done) {return std::vector<std::size_t>();}
47 auto result = m_stream->get(); // stream always as legal data
48
49 m_done = m_stream->bump();
50
51 return result;
52 }
53
54 bool isValid() const {return m_valid;}
55
56 private:
57 std::unique_ptr<IJetStream> m_stream;
58 bool m_done{false};
59 bool m_valid{false};
60};
61
62std::ostream& operator << (std::ostream&, const JetStreamer&);
63
64#endif
std::ostream & operator<<(std::ostream &, const JetStreamer &)
std::unique_ptr< IJetStream > m_stream
Definition JetStreamer.h:57
std::vector< std::size_t > next()
Definition JetStreamer.h:40
bool isValid() const
Definition JetStreamer.h:54
friend std::ostream & operator<<(std::ostream &, const JetStreamer &)
JetStreamer(std::unique_ptr< IJetStream > &&stream)
Definition JetStreamer.h:33
STL namespace.