DDS-PSM-Cxx 1.1 RTF Avatar
  1. OMG Issue

DDSPSMC11_ — API corrections required to dds/core/Duration.hpp

  • Key: DDSPSMC11_-14
  • Status: open  
  • Source: Real-Time Innovations ( Alejandro Campos)
  • Summary:

    The class Duration needs the following corrections:

    • Add missing operator!=
    • Replace type of member sec_ from uint32_t to int32_t.

    We also suggest adding the following implicit constructor that allows interchanging C++11 chrono types and Duration throughout the API:

        /**
         * @brief Allow implicit creation from std::chrono::duration
         *
         * For example:
         * \code
         * dds::core::cond::WaitSet waitset;
         * // ...
         * waitset.wait(std::chrono::seconds(1) + std::chrono::milliseconds(250));
         * \endcode
         *
         */
        template <typename Rep, typename Period>
        /* implicit */ Duration(const std::chrono::duration<Rep, Period>& duration)
            : sec_(static_cast<int32_t>(
                  std::chrono::duration_cast<std::chrono::seconds, Rep, Period>(duration).count())),
              nsec_(static_cast<uint32_t>(
                  (std::chrono::nanoseconds(duration) % 1000000000).count()))
        {
        }
    
  • Reported: DDS-PSM-Cxx 1.0b2 — Wed, 13 Jul 2016 22:46 GMT
  • Updated: Sun, 30 Sep 2018 23:27 GMT