Orfeo Toolbox  3.16
itkResourceProbe.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkResourceProbe.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-26 15:20:21 $
7  Version: $Revision: 1.1 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  Portions of this code are covered under the VTK copyright.
13  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
14 
15  This software is distributed WITHOUT ANY WARRANTY; without even
16  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17  PURPOSE. See the above copyright notices for more information.
18 
19 =========================================================================*/
20 #ifndef __itkResourceProbe_txx
21 #define __itkResourceProbe_txx
22 
23 #include "itkResourceProbe.h"
24 #include "itkNumericTraits.h"
25 
26 namespace itk
27 {
28 
30 template<class ValueType, class MeanType>
32 ::ResourceProbe(const std::string & type, const std::string & unit)
33 :m_TypeString(type),m_UnitString(unit)
34 {
35  this->m_TotalValue = NumericTraits< ValueType >::ZeroValue();
36  this->m_StartValue = NumericTraits< ValueType >::ZeroValue();
37  this->m_NumberOfStarts = NumericTraits< CountType >::ZeroValue();
38  this->m_NumberOfStops = NumericTraits< CountType >::ZeroValue();
39 }
40 
42 template<class ValueType, class MeanType>
45 {
46 }
47 
49 template<class ValueType, class MeanType>
50 std::string
52 ::GetType(void)const
53 {
54  return this->m_TypeString;
55 }
56 
58 template<class ValueType, class MeanType>
59 std::string
61 ::GetUnit(void)const
62 {
63  return this->m_UnitString;
64 }
65 
67 template<class ValueType, class MeanType>
68 void
70 ::Start(void)
71 {
72  this->m_NumberOfStarts++;
73  this->m_StartValue = this->GetInstantValue();
74 }
75 
77 template<class ValueType, class MeanType>
78 void
80 ::Stop(void)
81 {
82  if( this->m_NumberOfStops == this->m_NumberOfStarts )
83  {
84  itkGenericExceptionMacro( << "Can't stop a probe that has not been started." );
85  }
86  this->m_TotalValue += this->GetInstantValue() - this->m_StartValue;
87  this->m_NumberOfStops++;
88 }
89 
91 template<class ValueType, class MeanType>
95 {
96  return this->m_NumberOfStarts;
97 }
98 
100 template<class ValueType, class MeanType>
104 {
105  return this->m_NumberOfStops;
106 }
107 
109 template<class ValueType, class MeanType>
110 ValueType
112 ::GetTotal(void) const
113 {
114  return this->m_TotalValue;
115 }
116 
118 template<class ValueType, class MeanType>
119 MeanType
121 ::GetMean(void) const
122 {
123  MeanType meanValue = NumericTraits< MeanType >::ZeroValue();
124 
125  if( this->m_NumberOfStops)
126  {
127  meanValue = static_cast<MeanType>(this->m_TotalValue) / static_cast<MeanType>(this->m_NumberOfStops);
128  }
129 
130  return meanValue;
131 
132 }
133 
134 
135 } // end namespace itk
136 
137 #endif

Generated at Sun May 19 2013 00:04:02 for Orfeo Toolbox with doxygen 1.8.3.1