CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
edm::WorkerInPath Class Reference

#include <WorkerInPath.h>

Public Types

enum  FilterAction { Normal =0, Ignore, Veto }
 

Public Member Functions

bool checkResultsOfRunWorker (bool wasEvent)
 
void clearCounters ()
 
FilterAction filterAction () const
 
WorkergetWorker () const
 
template<typename T >
bool runWorker (typename T::MyPrincipal const &, EventSetup const &, StreamID streamID, typename T::Context const *context)
 
template<typename T >
void runWorkerAsync (WaitingTask *iTask, typename T::MyPrincipal const &, EventSetup const &, StreamID streamID, typename T::Context const *context)
 
void setPathContext (PathContext const *v)
 
void skipWorker (EventPrincipal const &iPrincipal)
 
void skipWorker (RunPrincipal const &)
 
void skipWorker (LuminosityBlockPrincipal const &)
 
int timesExcept () const
 
int timesFailed () const
 
int timesPassed () const
 
int timesVisited () const
 
 WorkerInPath (Worker *, FilterAction theAction, unsigned int placeInPath)
 

Private Attributes

FilterAction filterAction_
 
PlaceInPathContext placeInPathContext_
 
int timesExcept_
 
int timesFailed_
 
int timesPassed_
 
int timesVisited_
 
Workerworker_
 

Detailed Description

Definition at line 24 of file WorkerInPath.h.

Member Enumeration Documentation

Enumerator
Normal 
Ignore 
Veto 

Definition at line 26 of file WorkerInPath.h.

Constructor & Destructor Documentation

edm::WorkerInPath::WorkerInPath ( Worker w,
FilterAction  theAction,
unsigned int  placeInPath 
)

Definition at line 6 of file WorkerInPath.cc.

References edm::Worker::addedToPath().

6  :
8  timesPassed_(),
9  timesFailed_(),
10  timesExcept_(),
11  filterAction_(theFilterAction),
12  worker_(w),
13  placeInPathContext_(placeInPath)
14  {
15  w->addedToPath();
16  }
const double w
Definition: UKUtility.cc:23
FilterAction filterAction_
Definition: WorkerInPath.h:70
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:73

Member Function Documentation

bool edm::WorkerInPath::checkResultsOfRunWorker ( bool  wasEvent)
inline

Definition at line 76 of file WorkerInPath.h.

References edm::Worker::Exception, edm::Worker::Fail, filterAction(), Ignore, edm::Worker::Pass, edm::Worker::state(), timesExcept_, timesFailed_, timesPassed_, Veto, and worker_.

76  {
77  if(not wasEvent) {
78  return true;
79  }
80  auto state = worker_->state();
81  bool rc = true;
82  switch (state) {
83  case Worker::Fail:
84  {
85  rc = false;
86  break;
87  }
88  case Worker::Pass:
89  break;
90  case Worker::Exception:
91  {
92  ++timesExcept_;
93  return true;
94  }
95 
96  default:
97  assert(false);
98  }
99 
100  if(Ignore == filterAction()) {
101  rc = true;
102  } else if(Veto == filterAction()) {
103  rc = !rc;
104  }
105 
106  if(rc) {
107  ++timesPassed_;
108  } else {
109  ++timesFailed_;
110  }
111  return rc;
112 
113  }
State state() const
Definition: Worker.h:171
FilterAction filterAction() const
Definition: WorkerInPath.h:59
void edm::WorkerInPath::clearCounters ( )
inline
FilterAction edm::WorkerInPath::filterAction ( ) const
inline

Definition at line 59 of file WorkerInPath.h.

References filterAction_.

Referenced by checkResultsOfRunWorker().

59 { return filterAction_; }
FilterAction filterAction_
Definition: WorkerInPath.h:70
Worker* edm::WorkerInPath::getWorker ( ) const
inline

Definition at line 60 of file WorkerInPath.h.

References worker_.

60 { return worker_; }
template<typename T >
bool edm::WorkerInPath::runWorker ( typename T::MyPrincipal const &  ep,
EventSetup const &  es,
StreamID  streamID,
typename T::Context const *  context 
)

Definition at line 134 of file WorkerInPath.h.

References edm::Worker::doWork(), filterAction_, Ignore, placeInPathContext_, timesExcept_, timesFailed_, timesPassed_, timesVisited_, Veto, and worker_.

136  {
137 
138  if (T::isEvent_) {
139  ++timesVisited_;
140  }
141  bool rc = true;
142 
143  try {
144  // may want to change the return value from the worker to be
145  // the Worker::FilterAction so conditions in the path will be easier to
146  // identify
147  if(T::isEvent_) {
148  ParentContext parentContext(&placeInPathContext_);
149  rc = worker_->doWork<T>(ep, es,streamID, parentContext, context);
150  } else {
151  ParentContext parentContext(context);
152  rc = worker_->doWork<T>(ep, es,streamID, parentContext, context);
153  }
154  // Ignore return code for non-event (e.g. run, lumi) calls
155  if (!T::isEvent_) rc = true;
156  else if (filterAction_ == Veto) rc = !rc;
157  else if (filterAction_ == Ignore) rc = true;
158 
159  if (T::isEvent_) {
160  if(rc) ++timesPassed_; else ++timesFailed_;
161  }
162  }
163  catch(...) {
164  if (T::isEvent_) ++timesExcept_;
165  throw;
166  }
167 
168  return rc;
169  }
bool doWork(typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:712
FilterAction filterAction_
Definition: WorkerInPath.h:70
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:73
long double T
template<typename T >
void edm::WorkerInPath::runWorkerAsync ( WaitingTask iTask,
typename T::MyPrincipal const &  ep,
EventSetup const &  es,
StreamID  streamID,
typename T::Context const *  context 
)

Definition at line 116 of file WorkerInPath.h.

References edm::Worker::doWorkAsync(), edm::Worker::doWorkNoPrefetchingAsync(), placeInPathContext_, timesVisited_, and worker_.

119  {
120  if (T::isEvent_) {
121  ++timesVisited_;
122  }
123 
124  if(T::isEvent_) {
125  ParentContext parentContext(&placeInPathContext_);
126  worker_->doWorkAsync<T>(iTask,ep, es,streamID, parentContext, context);
127  } else {
128  ParentContext parentContext(context);
129  worker_->doWorkNoPrefetchingAsync<T>(iTask,ep, es,streamID, parentContext, context);
130  }
131  }
void doWorkNoPrefetchingAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:674
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:73
void doWorkAsync(WaitingTask *task, typename T::MyPrincipal const &, EventSetup const &c, StreamID stream, ParentContext const &parentContext, typename T::Context const *context)
Definition: Worker.h:615
long double T
void edm::WorkerInPath::setPathContext ( PathContext const *  v)
inline

Definition at line 62 of file WorkerInPath.h.

References placeInPathContext_, and edm::PlaceInPathContext::setPathContext().

void setPathContext(PathContext const *v)
PlaceInPathContext placeInPathContext_
Definition: WorkerInPath.h:73
void edm::WorkerInPath::skipWorker ( EventPrincipal const &  iPrincipal)
inline

Definition at line 44 of file WorkerInPath.h.

References edm::Worker::skipOnPath(), and worker_.

44  {
46  }
void skipOnPath()
Definition: Worker.cc:325
void edm::WorkerInPath::skipWorker ( RunPrincipal const &  )
inline

Definition at line 47 of file WorkerInPath.h.

47 {}
void edm::WorkerInPath::skipWorker ( LuminosityBlockPrincipal const &  )
inline

Definition at line 48 of file WorkerInPath.h.

48 {}
int edm::WorkerInPath::timesExcept ( ) const
inline

Definition at line 57 of file WorkerInPath.h.

References timesExcept_.

57 { return timesExcept_; }
int edm::WorkerInPath::timesFailed ( ) const
inline

Definition at line 56 of file WorkerInPath.h.

References timesFailed_.

56 { return timesFailed_; }
int edm::WorkerInPath::timesPassed ( ) const
inline

Definition at line 55 of file WorkerInPath.h.

References timesPassed_.

55 { return timesPassed_; }
int edm::WorkerInPath::timesVisited ( ) const
inline

Definition at line 54 of file WorkerInPath.h.

References timesVisited_.

54 { return timesVisited_; }

Member Data Documentation

FilterAction edm::WorkerInPath::filterAction_
private

Definition at line 70 of file WorkerInPath.h.

Referenced by filterAction(), and runWorker().

PlaceInPathContext edm::WorkerInPath::placeInPathContext_
private

Definition at line 73 of file WorkerInPath.h.

Referenced by runWorker(), runWorkerAsync(), and setPathContext().

int edm::WorkerInPath::timesExcept_
private

Definition at line 68 of file WorkerInPath.h.

Referenced by checkResultsOfRunWorker(), clearCounters(), runWorker(), and timesExcept().

int edm::WorkerInPath::timesFailed_
private

Definition at line 67 of file WorkerInPath.h.

Referenced by checkResultsOfRunWorker(), clearCounters(), runWorker(), and timesFailed().

int edm::WorkerInPath::timesPassed_
private

Definition at line 66 of file WorkerInPath.h.

Referenced by checkResultsOfRunWorker(), clearCounters(), runWorker(), and timesPassed().

int edm::WorkerInPath::timesVisited_
private

Definition at line 65 of file WorkerInPath.h.

Referenced by clearCounters(), runWorker(), runWorkerAsync(), and timesVisited().

Worker* edm::WorkerInPath::worker_
private