Skip to content
Snippets Groups Projects
Commit 6d07b8b9 authored by Mederic Fourmy's avatar Mederic Fourmy
Browse files

Merge branch 'devel' into 451-refactoring-wolf-installation-system

parents 038ffdd6 3d4ee1cb
No related branches found
No related tags found
2 merge requests!451After cmake and const refactor,!445Resolve "Refactoring WOLF installation system"
...@@ -157,16 +157,16 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha ...@@ -157,16 +157,16 @@ class FrameBase : public NodeBase, public HasStateBlocks, public std::enable_sha
CaptureBaseConstPtr getCaptureOf(const SensorBaseConstPtr _sensor_ptr) const; CaptureBaseConstPtr getCaptureOf(const SensorBaseConstPtr _sensor_ptr) const;
CaptureBasePtr getCaptureOf(const SensorBaseConstPtr _sensor_ptr); CaptureBasePtr getCaptureOf(const SensorBaseConstPtr _sensor_ptr);
CaptureBaseConstPtr getCaptureOf(const SensorBasePtr _sensor_ptr, const std::string& type) const; CaptureBaseConstPtr getCaptureOf(const SensorBaseConstPtr _sensor_ptr, const std::string& type) const;
CaptureBasePtr getCaptureOf(const SensorBasePtr _sensor_ptr, const std::string& type); CaptureBasePtr getCaptureOf(const SensorBasePtr _sensor_ptr, const std::string& type);
CaptureBaseConstPtrList getCapturesOf(const SensorBasePtr _sensor_ptr) const; CaptureBaseConstPtrList getCapturesOf(const SensorBaseConstPtr _sensor_ptr) const;
CaptureBasePtrList getCapturesOf(const SensorBasePtr _sensor_ptr); CaptureBasePtrList getCapturesOf(const SensorBasePtr _sensor_ptr);
FactorBaseConstPtr getFactorOf(const ProcessorBasePtr _processor_ptr) const; FactorBaseConstPtr getFactorOf(const ProcessorBaseConstPtr _processor_ptr) const;
FactorBasePtr getFactorOf(const ProcessorBasePtr _processor_ptr); FactorBasePtr getFactorOf(const ProcessorBasePtr _processor_ptr);
FactorBaseConstPtr getFactorOf(const ProcessorBasePtr _processor_ptr, const std::string& type) const; FactorBaseConstPtr getFactorOf(const ProcessorBaseConstPtr _processor_ptr, const std::string& type) const;
FactorBasePtr getFactorOf(const ProcessorBasePtr _processor_ptr, const std::string& type); FactorBasePtr getFactorOf(const ProcessorBasePtr _processor_ptr, const std::string& type);
unsigned int getHits() const; unsigned int getHits() const;
......
...@@ -92,6 +92,7 @@ class Buffer ...@@ -92,6 +92,7 @@ class Buffer
public: public:
typedef typename std::map<TimeStamp,T>::iterator Iterator; // buffer iterator typedef typename std::map<TimeStamp,T>::iterator Iterator; // buffer iterator
typedef typename std::map<TimeStamp,T>::const_iterator ConstIterator; // buffer iterator
Buffer(){}; Buffer(){};
~Buffer(void){}; ~Buffer(void){};
...@@ -101,27 +102,28 @@ public: ...@@ -101,27 +102,28 @@ public:
* Select from the buffer the closest element (w.r.t. time stamp), * Select from the buffer the closest element (w.r.t. time stamp),
* respecting a defined time tolerances * respecting a defined time tolerances
*/ */
T select(const TimeStamp& _time_stamp, const double& _time_tolerance); T select(const TimeStamp& _time_stamp, const double& _time_tolerance) const;
/**\brief Select an element iterator from the buffer /**\brief Select an element iterator from the buffer
* *
* Select from the buffer the iterator pointing to the closest element (w.r.t. time stamp), * Select from the buffer the iterator pointing to the closest element (w.r.t. time stamp),
* respecting a defined time tolerances * respecting a defined time tolerances
*/ */
ConstIterator selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance) const;
Iterator selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance); Iterator selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance);
T selectFirstBefore(const TimeStamp& _time_stamp, const double& _time_tolerance); T selectFirstBefore(const TimeStamp& _time_stamp, const double& _time_tolerance) const;
T selectLastAfter(const TimeStamp& _time_stamp, const double& _time_tolerance); T selectLastAfter(const TimeStamp& _time_stamp, const double& _time_tolerance) const;
T selectFirst(); T selectFirst() const;
T selectLast(); T selectLast() const;
/**\brief Buffer size /**\brief Buffer size
* *
*/ */
SizeStd size(void); SizeStd size(void) const;
/**\brief Add a element to the buffer /**\brief Add a element to the buffer
* *
...@@ -132,6 +134,7 @@ public: ...@@ -132,6 +134,7 @@ public:
* *
* elements are ordered from most recent to oldest * elements are ordered from most recent to oldest
*/ */
const std::map<TimeStamp,T>& getContainer() const;
std::map<TimeStamp,T>& getContainer(); std::map<TimeStamp,T>& getContainer();
/**\brief Remove all elements in the buffer with a time stamp older than the specified /**\brief Remove all elements in the buffer with a time stamp older than the specified
...@@ -152,7 +155,7 @@ public: ...@@ -152,7 +155,7 @@ public:
/**\brief is the buffer empty ? /**\brief is the buffer empty ?
* *
*/ */
bool empty(); bool empty() const;
protected: protected:
/**\brief Check time tolerance /**\brief Check time tolerance
...@@ -160,14 +163,19 @@ protected: ...@@ -160,14 +163,19 @@ protected:
* Check if the time distance between two time stamps is smaller than * Check if the time distance between two time stamps is smaller than
* the time tolerance. * the time tolerance.
*/ */
static bool checkTimeTolerance(const TimeStamp& _time_stamp1, const TimeStamp& _time_stamp2, const double& _time_tolerance); static bool checkTimeTolerance(const TimeStamp& _time_stamp1,
const TimeStamp& _time_stamp2,
const double& _time_tolerance);
/**\brief Check time tolerance /**\brief Check time tolerance
* *
* Check if the time distance between two time stamps is smaller than * Check if the time distance between two time stamps is smaller than
* the minimum time tolerance of the two frames. * the minimum time tolerance of the two frames.
*/ */
static bool doubleCheckTimeTolerance(const TimeStamp& _time_stamp1, const double& _time_tolerance1, const TimeStamp& _time_stamp2, const double& _time_tolerance2); static bool doubleCheckTimeTolerance(const TimeStamp& _time_stamp1,
const double& _time_tolerance1,
const TimeStamp& _time_stamp2,
const double& _time_tolerance2);
protected: protected:
...@@ -454,6 +462,42 @@ std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&... ...@@ -454,6 +462,42 @@ std::shared_ptr<classType> ProcessorBase::emplace(SensorBasePtr _sen_ptr, T&&...
///////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////
template <typename T>
typename Buffer<T>::ConstIterator Buffer<T>::selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance) const
{
Buffer<T>::ConstIterator post = container_.upper_bound(_time_stamp);
bool prev_exists = (post != container_.begin());
bool post_exists = (post != container_.end());
bool post_ok = post_exists && checkTimeTolerance(post->first, _time_stamp, _time_tolerance);
if (prev_exists)
{
Buffer<T>::ConstIterator prev = std::prev(post);
bool prev_ok = checkTimeTolerance(prev->first, _time_stamp, _time_tolerance);
if (prev_ok && !post_ok)
return prev;
else if (!prev_ok && post_ok)
return post;
else if (prev_ok && post_ok)
{
if (std::fabs(post->first - _time_stamp) < std::fabs(prev->first - _time_stamp))
return post;
else
return prev;
}
}
else if (post_ok)
return post;
return container_.end();
}
template <typename T> template <typename T>
typename Buffer<T>::Iterator Buffer<T>::selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance) typename Buffer<T>::Iterator Buffer<T>::selectIterator(const TimeStamp& _time_stamp, const double& _time_tolerance)
{ {
...@@ -491,12 +535,12 @@ typename Buffer<T>::Iterator Buffer<T>::selectIterator(const TimeStamp& _time_st ...@@ -491,12 +535,12 @@ typename Buffer<T>::Iterator Buffer<T>::selectIterator(const TimeStamp& _time_st
} }
template <typename T> template <typename T>
T Buffer<T>::select(const TimeStamp& _time_stamp, const double& _time_tolerance) T Buffer<T>::select(const TimeStamp& _time_stamp, const double& _time_tolerance) const
{ {
if (container_.empty()) if (container_.empty())
return nullptr; return nullptr;
Buffer<T>::Iterator it = selectIterator(_time_stamp, _time_tolerance); auto it = selectIterator(_time_stamp, _time_tolerance);
// end is returned from selectIterator if an element of the buffer complying with the time stamp // end is returned from selectIterator if an element of the buffer complying with the time stamp
// and time tolerance has not been found // and time tolerance has not been found
...@@ -508,7 +552,7 @@ T Buffer<T>::select(const TimeStamp& _time_stamp, const double& _time_tolerance) ...@@ -508,7 +552,7 @@ T Buffer<T>::select(const TimeStamp& _time_stamp, const double& _time_tolerance)
} }
template <typename T> template <typename T>
T Buffer<T>::selectFirstBefore(const TimeStamp& _time_stamp, const double& _time_tolerance) T Buffer<T>::selectFirstBefore(const TimeStamp& _time_stamp, const double& _time_tolerance) const
{ {
// There is no element // There is no element
if (container_.empty()) if (container_.empty())
...@@ -529,7 +573,7 @@ T Buffer<T>::selectFirstBefore(const TimeStamp& _time_stamp, const double& _time ...@@ -529,7 +573,7 @@ T Buffer<T>::selectFirstBefore(const TimeStamp& _time_stamp, const double& _time
template <typename T> template <typename T>
T Buffer<T>::selectLastAfter(const TimeStamp& _time_stamp, const double& _time_tolerance) T Buffer<T>::selectLastAfter(const TimeStamp& _time_stamp, const double& _time_tolerance) const
{ {
// There is no element // There is no element
if (container_.empty()) if (container_.empty())
...@@ -549,7 +593,7 @@ T Buffer<T>::selectLastAfter(const TimeStamp& _time_stamp, const double& _time_t ...@@ -549,7 +593,7 @@ T Buffer<T>::selectLastAfter(const TimeStamp& _time_stamp, const double& _time_t
} }
template <typename T> template <typename T>
T Buffer<T>::selectFirst() T Buffer<T>::selectFirst() const
{ {
// There is no element // There is no element
if (container_.empty()) if (container_.empty())
...@@ -560,7 +604,7 @@ T Buffer<T>::selectFirst() ...@@ -560,7 +604,7 @@ T Buffer<T>::selectFirst()
} }
template <typename T> template <typename T>
T Buffer<T>::selectLast() T Buffer<T>::selectLast() const
{ {
// There is no element // There is no element
if (container_.empty()) if (container_.empty())
...@@ -576,6 +620,12 @@ void Buffer<T>::emplace(const TimeStamp& _time_stamp, const T& _element) ...@@ -576,6 +620,12 @@ void Buffer<T>::emplace(const TimeStamp& _time_stamp, const T& _element)
container_.emplace(_time_stamp, _element); container_.emplace(_time_stamp, _element);
} }
template <typename T>
const std::map<TimeStamp,T>& Buffer<T>::getContainer() const
{
return container_;
}
template <typename T> template <typename T>
std::map<TimeStamp,T>& Buffer<T>::getContainer() std::map<TimeStamp,T>& Buffer<T>::getContainer()
{ {
...@@ -589,13 +639,13 @@ inline void Buffer<T>::clear() ...@@ -589,13 +639,13 @@ inline void Buffer<T>::clear()
} }
template <typename T> template <typename T>
inline bool Buffer<T>::empty() inline bool Buffer<T>::empty() const
{ {
return container_.empty(); return container_.empty();
} }
template <typename T> template <typename T>
inline SizeStd Buffer<T>::size(void) inline SizeStd Buffer<T>::size(void) const
{ {
return container_.size(); return container_.size();
} }
...@@ -628,8 +678,8 @@ inline bool Buffer<T>::doubleCheckTimeTolerance(const TimeStamp& _time_stamp1, ...@@ -628,8 +678,8 @@ inline bool Buffer<T>::doubleCheckTimeTolerance(const TimeStamp& _time_stamp1,
template <typename T> template <typename T>
inline bool Buffer<T>::checkTimeTolerance(const TimeStamp& _time_stamp1, inline bool Buffer<T>::checkTimeTolerance(const TimeStamp& _time_stamp1,
const TimeStamp& _time_stamp2, const TimeStamp& _time_stamp2,
const double& _time_tolerance) const double& _time_tolerance)
{ {
double time_diff = std::fabs(_time_stamp1 - _time_stamp2); double time_diff = std::fabs(_time_stamp1 - _time_stamp2);
bool pass = time_diff <= _time_tolerance; bool pass = time_diff <= _time_tolerance;
......
...@@ -230,7 +230,7 @@ CaptureBasePtrList FrameBase::getCapturesOfType(const std::string& type) ...@@ -230,7 +230,7 @@ CaptureBasePtrList FrameBase::getCapturesOfType(const std::string& type)
return captures; return captures;
} }
CaptureBaseConstPtr FrameBase::getCaptureOf(const SensorBasePtr _sensor_ptr, const std::string& type) const CaptureBaseConstPtr FrameBase::getCaptureOf(const SensorBaseConstPtr _sensor_ptr, const std::string& type) const
{ {
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
if (capture_ptr->getSensor() == _sensor_ptr && capture_ptr->getType() == type) if (capture_ptr->getSensor() == _sensor_ptr && capture_ptr->getType() == type)
...@@ -264,7 +264,7 @@ CaptureBasePtr FrameBase::getCaptureOf(const SensorBaseConstPtr _sensor_ptr) ...@@ -264,7 +264,7 @@ CaptureBasePtr FrameBase::getCaptureOf(const SensorBaseConstPtr _sensor_ptr)
return nullptr; return nullptr;
} }
CaptureBaseConstPtrList FrameBase::getCapturesOf(const SensorBasePtr _sensor_ptr) const CaptureBaseConstPtrList FrameBase::getCapturesOf(const SensorBaseConstPtr _sensor_ptr) const
{ {
CaptureBaseConstPtrList captures; CaptureBaseConstPtrList captures;
for (auto capture_ptr : getCaptureList()) for (auto capture_ptr : getCaptureList())
...@@ -282,7 +282,7 @@ CaptureBasePtrList FrameBase::getCapturesOf(const SensorBasePtr _sensor_ptr) ...@@ -282,7 +282,7 @@ CaptureBasePtrList FrameBase::getCapturesOf(const SensorBasePtr _sensor_ptr)
return captures; return captures;
} }
FactorBaseConstPtr FrameBase::getFactorOf(const ProcessorBasePtr _processor_ptr, const std::string& type) const FactorBaseConstPtr FrameBase::getFactorOf(const ProcessorBaseConstPtr _processor_ptr, const std::string& type) const
{ {
for (auto factor_ptr : getConstrainedByList()) for (auto factor_ptr : getConstrainedByList())
if (factor_ptr->getProcessor() == _processor_ptr && factor_ptr->getType() == type) if (factor_ptr->getProcessor() == _processor_ptr && factor_ptr->getType() == type)
...@@ -308,7 +308,7 @@ FactorBasePtr FrameBase::getFactorOf(const ProcessorBasePtr _processor_ptr, cons ...@@ -308,7 +308,7 @@ FactorBasePtr FrameBase::getFactorOf(const ProcessorBasePtr _processor_ptr, cons
return nullptr; return nullptr;
} }
FactorBaseConstPtr FrameBase::getFactorOf(const ProcessorBasePtr _processor_ptr) const FactorBaseConstPtr FrameBase::getFactorOf(const ProcessorBaseConstPtr _processor_ptr) const
{ {
for (auto factor_ptr : getConstrainedByList()) for (auto factor_ptr : getConstrainedByList())
if (factor_ptr->getProcessor() == _processor_ptr) if (factor_ptr->getProcessor() == _processor_ptr)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment