SamplingMetricBase.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_FRAMEWORK_SAMPLINGMETRICBASE_H
17 #define SURGSIM_FRAMEWORK_SAMPLINGMETRICBASE_H
18 
19 #include <deque>
20 
23 
24 namespace SurgSim
25 {
26 namespace Framework
27 {
28 class Logger;
29 };
30 };
31 
32 namespace SurgSim
33 {
34 namespace Framework
35 {
36 
46 {
47 public:
50  explicit SamplingMetricBase(const std::string& name);
51 
55  typedef std::pair<double, double> MeasurementEntryType;
56 
63  typedef std::deque<MeasurementEntryType> MeasurementsType;
64 
65  void update(double dt) override;
66 
71  void setTargetManagerType(int targetManagerType);
72 
73  int getTargetManagerType() const override;
74 
76  void setMaxNumberOfMeasurements(size_t numberOfMeasurements);
77 
79  size_t getMaxNumberOfMeasurements() const;
80 
82  size_t getCurrentNumberOfMeasurements() const;
83 
87  double getElapsedTime() const;
88 
91 
92 protected:
93 
94  bool doWakeUp() override;
95 
96  bool doInitialize() override;
97 
103  virtual bool canMeasure(double dt);
104 
111  virtual double performMeasurement(double dt) = 0;
112 
113  std::shared_ptr<SurgSim::Framework::Logger> m_logger;
114 
115 private:
121 };
122 };
123 };
124 
125 #endif // SURGSIM_FRAMEWORK_SAMPLINGMETRICBASE_H
SurgSim::Framework::SamplingMetricBase::canMeasure
virtual bool canMeasure(double dt)
Determine if it is appropriate to take a measurement.
Definition: SamplingMetricBase.cpp:51
SurgSim::Framework::SamplingMetricBase::MeasurementsType
std::deque< MeasurementEntryType > MeasurementsType
Type of the cumulative entries data structure.
Definition: SamplingMetricBase.h:63
SurgSim::Framework::SamplingMetricBase::doInitialize
bool doInitialize() override
Interface to be implemented by derived classes.
Definition: SamplingMetricBase.cpp:44
SurgSim::Framework::SamplingMetricBase::getTargetManagerType
int getTargetManagerType() const override
Specifies which manger will handle this behavior.
Definition: SamplingMetricBase.cpp:61
SurgSim::Framework::Behavior
Behaviors perform actions.
Definition: Behavior.h:40
SurgSim::Framework::SamplingMetricBase::m_measurementValues
MeasurementsType m_measurementValues
measurement list
Definition: SamplingMetricBase.h:117
SurgSim::Framework::SamplingMetricBase::m_maxNumberOfMeasurements
size_t m_maxNumberOfMeasurements
Definition: SamplingMetricBase.h:120
SurgSim::Framework::SamplingMetricBase::SamplingMetricBase
SamplingMetricBase(const std::string &name)
Constructor for the class.
Definition: SamplingMetricBase.cpp:26
ObjectFactory.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Framework::SamplingMetricBase::getElapsedTime
double getElapsedTime() const
Get the amount of time since the last successful measurement reading based on the accumulation of suc...
Definition: SamplingMetricBase.cpp:93
SurgSim::Framework::SamplingMetricBase::update
void update(double dt) override
Update the behavior.
Definition: SamplingMetricBase.cpp:98
SurgSim::Framework::SamplingMetricBase::setMaxNumberOfMeasurements
void setMaxNumberOfMeasurements(size_t numberOfMeasurements)
Set the maximum number of measurements to store.
Definition: SamplingMetricBase.cpp:71
SurgSim::Framework::SamplingMetricBase
SamplingMetricBase provides a base class to support metric development.
Definition: SamplingMetricBase.h:45
SurgSim::Framework::SamplingMetricBase::getMeasurementValues
virtual MeasurementsType getMeasurementValues()
Return the measurement values obtained for this measurement.
Definition: SamplingMetricBase.cpp:56
SurgSim::Framework::SamplingMetricBase::MeasurementEntryType
std::pair< double, double > MeasurementEntryType
Type of the individual entries in the measurement data structure.
Definition: SamplingMetricBase.h:55
SurgSim::Framework::SamplingMetricBase::doWakeUp
bool doWakeUp() override
Interface to be implemented by derived classes.
Definition: SamplingMetricBase.cpp:39
SurgSim::Framework::SamplingMetricBase::performMeasurement
virtual double performMeasurement(double dt)=0
Obtain the measurement.
SurgSim::Framework::SamplingMetricBase::getCurrentNumberOfMeasurements
size_t getCurrentNumberOfMeasurements() const
Definition: SamplingMetricBase.cpp:88
Behavior.h
SurgSim::Framework::SamplingMetricBase::m_logger
std::shared_ptr< SurgSim::Framework::Logger > m_logger
Definition: SamplingMetricBase.h:113
SurgSim::Framework::SamplingMetricBase::getMaxNumberOfMeasurements
size_t getMaxNumberOfMeasurements() const
Definition: SamplingMetricBase.cpp:83
SurgSim::Framework::SamplingMetricBase::setTargetManagerType
void setTargetManagerType(int targetManagerType)
Set the desired manager type for this metric.
Definition: SamplingMetricBase.cpp:66
SurgSim::Framework::SamplingMetricBase::m_elapsedTime
double m_elapsedTime
Definition: SamplingMetricBase.h:119
SurgSim::Framework::SamplingMetricBase::m_targetManagerType
int m_targetManagerType
Definition: SamplingMetricBase.h:118