Skip to content
Snippets Groups Projects
Commit 561e2ad0 authored by Olivier Stasse's avatar Olivier Stasse
Browse files

Forward declaration of << operator for dynamicgraph::timestamp_t

GCC accept this but according to C++ standard this is not correct.
CLANG does not accept it.
parent 6949b0e0
No related branches found
No related tags found
No related merge requests found
Pipeline #25480 failed
/**
* @file
* @license BSD 3-clause
* @copyright Copyright (c) 2023, LAAS/CNRS
* @copyright Copyright (c) 2020, New York University and Max Planck
* Gesellschaft
*
* @brief Define the time stamp signal.
*/
#pragma once
#include <ostream>
#include <chrono>
namespace dynamic_graph_bridge
{
/** @brief Time stamp type. */
typedef std::chrono::time_point<std::chrono::high_resolution_clock> timestamp_t;
} // namespace dynamic_graph_bridge
namespace dynamicgraph
{
/**
* @brief out stream the time stamp data.
*
* @param os
* @param time_stamp
* @return std::ostream&
*
* For clang this function needs to be forward declared before the template using it.
* This is more in accordance to the standard.
*/
inline std::ostream &operator<<(
std::ostream &os, const dynamic_graph_bridge::timestamp_t &time_stamp)
{
std::chrono::time_point<std::chrono::high_resolution_clock,
std::chrono::milliseconds>
time_stamp_nanosec =
std::chrono::time_point_cast<std::chrono::milliseconds>(time_stamp);
os << time_stamp_nanosec.time_since_epoch().count();
return os;
}
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
* @date 2019-05-22 * @date 2019-05-22
*/ */
#include "fwd.hpp"
#include <dynamic-graph/factory.h> #include <dynamic-graph/factory.h>
#include "ros_subscribe.hpp" #include "ros_subscribe.hpp"
...@@ -163,6 +164,7 @@ Add::Add(RosSubscribe& entity, const std::string& doc_string) ...@@ -163,6 +164,7 @@ Add::Add(RosSubscribe& entity, const std::string& doc_string)
Value Add::doExecute() Value Add::doExecute()
{ {
using namespace dynamicgraph;
RosSubscribe& entity = static_cast<RosSubscribe&>(owner()); RosSubscribe& entity = static_cast<RosSubscribe&>(owner());
std::vector<Value> values = getParameterValues(); std::vector<Value> values = getParameterValues();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#pragma once #pragma once
#include "fwd.hpp"
#include <dynamic-graph/command.h> #include <dynamic-graph/command.h>
#include <dynamic-graph/entity.h> #include <dynamic-graph/entity.h>
#include <dynamic-graph/signal-ptr.h> #include <dynamic-graph/signal-ptr.h>
......
...@@ -9,36 +9,12 @@ ...@@ -9,36 +9,12 @@
#pragma once #pragma once
#include <dynamic-graph/signal-caster.h> #include "fwd.hpp"
#include <chrono>
namespace dynamic_graph_bridge #include <dynamic-graph/signal-caster.h>
{
/** @brief Time stamp type. */
typedef std::chrono::time_point<std::chrono::high_resolution_clock> timestamp_t;
} // namespace dynamic_graph_bridge
namespace dynamicgraph namespace dynamicgraph
{ {
/**
* @brief out stream the time stamp data.
*
* @param os
* @param time_stamp
* @return std::ostream&
*/
inline std::ostream &operator<<(
std::ostream &os, const dynamic_graph_bridge::timestamp_t &time_stamp)
{
std::chrono::time_point<std::chrono::high_resolution_clock,
std::chrono::milliseconds>
time_stamp_nanosec =
std::chrono::time_point_cast<std::chrono::milliseconds>(time_stamp);
os << time_stamp_nanosec.time_since_epoch().count();
return os;
}
/** /**
* @brief Structure used to serialize/deserialize the time stamp. * @brief Structure used to serialize/deserialize the time stamp.
......
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