CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 assert(), 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  ++timesFailed_;
86  rc = false;
87  break;
88  }
89  case Worker::Pass:
90  break;
91  case Worker::Exception:
92  {
93  ++timesExcept_;
94  return true;
95  }
96 
97  default:
98  assert(false);
99  }
100 
101  if(Ignore == filterAction()) {
102  rc = true;
103  } else if(Veto == filterAction()) {
104  rc = !rc;
105  }
106 
107  if(rc) {
108  ++timesPassed_;
109  } else {
110  ++timesFailed_;
111  }
112  return rc;
113 
114  }
assert(m_qm.get())
State state() const
Definition: Worker.h:162
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 135 of file WorkerInPath.h.

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

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

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

120  {
121  if (T::isEvent_) {
122  ++timesVisited_;
123  }
124 
125  if(T::isEvent_) {
126  ParentContext parentContext(&placeInPathContext_);
127  worker_->doWorkAsync<T>(iTask,ep, es,streamID, parentContext, context);
128  } else {
129  ParentContext parentContext(context);
130  worker_->doWorkAsync<T>(iTask,ep, es,streamID, parentContext, context);
131  }
132  }
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:602
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:311
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