ATLAS Offline Software
Loading...
Searching...
No Matches
ProductGen Class Reference

#include <ProductGen.h>

Collaboration diagram for ProductGen:

Public Member Functions

 ProductGen ()
 ProductGen (const std::vector< std::size_t > &ends)
std::vector< std::size_t > next ()

Private Member Functions

bool atEnd ()

Private Attributes

std::vector< std::size_t > m_ends
std::vector< std::size_t > m_counters
std::size_t m_ncounters {}
bool m_done {true}

Detailed Description

Definition at line 13 of file ProductGen.h.

Constructor & Destructor Documentation

◆ ProductGen() [1/2]

ProductGen::ProductGen ( )

Definition at line 9 of file ProductGen.cxx.

9{}

◆ ProductGen() [2/2]

ProductGen::ProductGen ( const std::vector< std::size_t > & ends)
explicit

Definition at line 11 of file ProductGen.cxx.

11 :
12 m_ends(ends), m_counters(ends.size(), 0), m_ncounters(ends.size()){
13
14 if (!m_ends.empty()){
15 m_done = false;
16 for(auto& i : m_ends){
17 if(i < 1) {
18 m_done = true;
19 break;
20 } else {
21 i -= 1;
22 }
23 }
24 }
25
26}
bool m_done
Definition ProductGen.h:25
std::size_t m_ncounters
Definition ProductGen.h:24
std::vector< std::size_t > m_counters
Definition ProductGen.h:23
std::vector< std::size_t > m_ends
Definition ProductGen.h:22

Member Function Documentation

◆ atEnd()

bool ProductGen::atEnd ( )
inlineprivate

Definition at line 26 of file ProductGen.h.

26{return (m_counters == m_ends);}

◆ next()

std::vector< std::size_t > ProductGen::next ( )

Definition at line 29 of file ProductGen.cxx.

29 {
30
31 if(m_done){return std::vector<std::size_t>();}
32
33 auto result = std::vector<std::size_t>(m_counters);
34 m_done = atEnd();
35 for(std::size_t i = 0; i < m_ncounters; ++i){
36
37 if(m_counters[i] == m_ends[i]){
38 m_counters[i] = 0;
39 } else {
40 m_counters[i] += 1;
41 break;
42 }
43 }
44 return result;
45}
bool atEnd()
Definition ProductGen.h:26

Member Data Documentation

◆ m_counters

std::vector<std::size_t> ProductGen::m_counters
private

Definition at line 23 of file ProductGen.h.

◆ m_done

bool ProductGen::m_done {true}
private

Definition at line 25 of file ProductGen.h.

25{true};

◆ m_ends

std::vector<std::size_t> ProductGen::m_ends
private

Definition at line 22 of file ProductGen.h.

◆ m_ncounters

std::size_t ProductGen::m_ncounters {}
private

Definition at line 24 of file ProductGen.h.

24{};

The documentation for this class was generated from the following files: