CustusX  18.04
An IGT application
cxFilterTimedAlgorithm.cpp
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #include "cxFilterTimedAlgorithm.h"
13 #include "cxLogger.h"
14 #include "cxFilter.h"
15 
16 namespace cx
17 {
18 
20  ThreadedTimedAlgorithm<bool>(filter->getName(), 20)
21 {
22  mFilter = filter;
23  mUseDefaultMessages = false;
24 }
25 
27 {}
28 
30 {
31  return mFilter;
32 }
33 
35 {
36  mFilter->preProcess();
37 }
38 
40 {
41  bool success = this->getResult();
42 
43  mFilter->postProcess();
44 
45  if (success)
46  {
47  reportSuccess(QString("Done \"%1\": [%2s]")
48  .arg(mFilter->getName())
49  .arg(this->getSecondsPassedAsString()));
50  }
51  else
52  {
53  reportWarning(QString("Failed \"%1\": [%2s]")
54  .arg(mFilter->getName())
55  .arg(this->getSecondsPassedAsString()));
56  }
57 }
58 
59 bool FilterTimedAlgorithm::calculate()
60 {
61  return mFilter->execute();
62 }
63 
64 
65 } // namespace cx
Base class for algorithms that wants to thread and time their execution. T is the return type of the ...
boost::shared_ptr< class Filter > FilterPtr
void reportWarning(QString msg)
Definition: cxLogger.cpp:70
void reportSuccess(QString msg)
Definition: cxLogger.cpp:72
FilterTimedAlgorithm(FilterPtr filter)
QString getSecondsPassedAsString() const
Namespace for all CustusX production code.