-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestSource.cc
120 lines (106 loc) · 2.19 KB
/
TestSource.cc
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// -*- C++ -*-
//
// Package: Package
// Class : Source
//
// Implementation:
// [Notes on implementation]
//
// Original Author: Chris Jones
// Created: Fri, 24 May 2013 16:05:37 GMT
// $Id$
//
// system include files
#include <iostream>
// user include files
#include "TestSource.h"
#include "Event.h"
#include "Run.h"
#include "writeLock.h"
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
TestSource::TestSource(unsigned int iNRuns, unsigned int iNEventsPerRun, unsigned int iNTransitions):
m_nextTransition{iNTransitions==0? kStop: kRun},
m_nextRunNumber{1},
m_nextEventNumber{0},
m_nTransitionsSeen{0},
m_nRuns{iNRuns},
m_nEventsPerRun{iNEventsPerRun},
m_nEventsSeen{0},
m_nTransitions{iNTransitions}
{
}
// TestSource::TestSource(const TestSource& rhs)
// {
// // do actual copying here;
// }
//TestSource::~TestSource()
//{
//}
//
// assignment operators
//
// const TestSource& TestSource::operator=(const TestSource& rhs)
// {
// //An exception safe implementation is
// TestSource temp(rhs);
// swap(rhs);
//
// return *this;
// }
//
// member functions
//
void
TestSource::finishTransition()
{
++m_nTransitionsSeen;
if(m_nTransitionsSeen == m_nTransitions) {
m_nextTransition = kStop;
return;
}
if(kRun == m_nextTransition) {
if(m_nEventsPerRun !=0) {
m_nextTransition = kEvent;
++m_nextEventNumber;
} else {
++m_nextRunNumber;
}
return;
}
if(kEvent == m_nextTransition) {
++m_nEventsSeen;
if(m_nEventsSeen % m_nEventsPerRun == 0) {
m_nextTransition = kRun;
++m_nextRunNumber;
} else {
++m_nextEventNumber;
}
}
}
void TestSource::gotoNextEvent(Event& iEvent) {
writeLock([&](){
std::cout <<"Event "<<nextRunsNumber()<<" "<<nextEventsNumber()<<std::endl;
});
iEvent.setNumber( {nextRunsNumber(),nextEventsNumber()});
finishTransition();
}
void TestSource::gotoNextRun(Run& iRun) {
writeLock([&](){
std::cout <<"Run "<<nextRunsNumber()<<std::endl;
});
finishTransition();
}
//
// const member functions
//
//
// static member functions
//