diff --git a/src/fwd.hpp b/src/fwd.hpp new file mode 100644 index 0000000000000000000000000000000000000000..878b347e35c7c4d16fab44f923ff1c0da8a73516 --- /dev/null +++ b/src/fwd.hpp @@ -0,0 +1,45 @@ +/** + * @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; +} +} diff --git a/src/ros_subscribe.cpp b/src/ros_subscribe.cpp index 9d65b3d3a31365f507b3fa516e2100a66fcc5168..0f787ad993eb287fb0e6074b18ec93510044174a 100644 --- a/src/ros_subscribe.cpp +++ b/src/ros_subscribe.cpp @@ -7,6 +7,7 @@ * @date 2019-05-22 */ +#include "fwd.hpp" #include <dynamic-graph/factory.h> #include "ros_subscribe.hpp" @@ -163,6 +164,7 @@ Add::Add(RosSubscribe& entity, const std::string& doc_string) Value Add::doExecute() { + using namespace dynamicgraph; RosSubscribe& entity = static_cast<RosSubscribe&>(owner()); std::vector<Value> values = getParameterValues(); diff --git a/src/ros_subscribe.hpp b/src/ros_subscribe.hpp index 5f361be2722488f61c09bcc66f1b64f4413257fe..c00bfa96e2eba69ac99bdad3288cb5beb534bc08 100644 --- a/src/ros_subscribe.hpp +++ b/src/ros_subscribe.hpp @@ -10,6 +10,7 @@ #pragma once +#include "fwd.hpp" #include <dynamic-graph/command.h> #include <dynamic-graph/entity.h> #include <dynamic-graph/signal-ptr.h> diff --git a/src/time_point_io.hpp b/src/time_point_io.hpp index 0827b07929a852e7d634cbe7dd4709c74af61332..d9260f75d722dfc7ba8fd042247e30318e34fe6a 100644 --- a/src/time_point_io.hpp +++ b/src/time_point_io.hpp @@ -9,36 +9,12 @@ #pragma once -#include <dynamic-graph/signal-caster.h> - -#include <chrono> +#include "fwd.hpp" -namespace dynamic_graph_bridge -{ -/** @brief Time stamp type. */ -typedef std::chrono::time_point<std::chrono::high_resolution_clock> timestamp_t; - -} // namespace dynamic_graph_bridge +#include <dynamic-graph/signal-caster.h> 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.