opensurgsim
SamplingMetricBase.h
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 
21 #include "SurgSim/Framework/Behavior.h"
22 #include "SurgSim/Framework/ObjectFactory.h"
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 
90  virtual MeasurementsType getMeasurementValues();
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:
117  MeasurementsType m_measurementValues;
118  int m_targetManagerType;
119  double m_elapsedTime;
120  size_t m_maxNumberOfMeasurements;
121 };
122 };
123 };
124 
125 #endif // SURGSIM_FRAMEWORK_SAMPLINGMETRICBASE_H
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
std::pair< double, double > MeasurementEntryType
Type of the individual entries in the measurement data structure.
Definition: SamplingMetricBase.h:55
SamplingMetricBase provides a base class to support metric development.
Definition: SamplingMetricBase.h:45
Behaviors perform actions.
Definition: Behavior.h:40
std::deque< MeasurementEntryType > MeasurementsType
Type of the cumulative entries data structure.
Definition: SamplingMetricBase.h:63