Skip to content

Commit

Permalink
Clean up namespaces in core
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
  • Loading branch information
mjcarroll committed May 15, 2024
1 parent a188f8c commit 626d7fa
Show file tree
Hide file tree
Showing 40 changed files with 5,919 additions and 6,031 deletions.
401 changes: 199 additions & 202 deletions include/gz/transport/AdvertiseOptions.hh

Large diffs are not rendered by default.

194 changes: 95 additions & 99 deletions include/gz/transport/Clock.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,104 +26,100 @@
#include "gz/transport/config.hh"
#include "gz/transport/Export.hh"

namespace gz
namespace gz::transport
{
namespace transport
// Inline bracket to help doxygen filtering.
inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
//
//////////////////////////////////////////////////
/// \brief A Clock interface for time tracking
class GZ_TRANSPORT_VISIBLE Clock
{
// Inline bracket to help doxygen filtering.
inline namespace GZ_TRANSPORT_VERSION_NAMESPACE {
//
//////////////////////////////////////////////////
/// \brief A Clock interface for time tracking
class GZ_TRANSPORT_VISIBLE Clock
{
/// \brief Gets clock time
/// \return Current clock time, in nanoseconds
public: virtual std::chrono::nanoseconds Time() const = 0;

/// \brief Checks whether the clock is ready to be used or not.
/// \return True if clock is ready to be used, false otherwise
public: virtual bool IsReady() const = 0;

/// \brief Virtual destructor
public: virtual ~Clock() = default;
};

////////////////////////////////////////////////////////////////
/// \brief A Clock interface implementation that uses
/// gz::msgs::Clock messages distributed across
/// the network
class GZ_TRANSPORT_VISIBLE NetworkClock : public Clock
{
/// \brief Network clock time bases
public: enum class TimeBase : int64_t
{
REAL, ///< Use Clock message `real` time field as time base
SIM, ///< Use Clock message `sim` time field as time base
SYS ///< Use Clock message `sys` time field as time base
};

/// \brief Constructor that sets the initial time range option
/// \param[in] _topicName Name of the gz::msgs::Clock type
/// topic to be used
/// \param[in] _timeBase Time base for this clock, defaults to
/// simulation time
public: explicit NetworkClock(const std::string &_topicName,
const TimeBase _timeBase = TimeBase::SIM);

/// \brief Destructor
public: ~NetworkClock() override;

// Documentation inherited
public: std::chrono::nanoseconds Time() const override;

/// \brief Sets and distributes the given clock time
/// \param[in] _time The clock time to be set
/// \remarks No clock arbitration is performed
public: void SetTime(const std::chrono::nanoseconds _time);

// Documentation inherited
public: bool IsReady() const override;

/// \internal Implementation of this class
private: class Implementation;

/// \internal Pointer to the implementation of this class
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
private: std::unique_ptr<Implementation> dataPtr;
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
};

//////////////////////////////////////////////////
/// \brief A Clock implementation that leverages host OS time APIs
class GZ_TRANSPORT_VISIBLE WallClock : public Clock
{
/// \brief Returns system wall clock interface
/// \return The sole wall clock instance (a singleton)
public: static WallClock* Instance();

// Documentation inherited
public: std::chrono::nanoseconds Time() const override;

// Documentation inherited
public: bool IsReady() const override;

/// \internal Private singleton constructor
private: WallClock();

/// \brief Destructor
private: ~WallClock() override;

/// \internal Implementation of this class
private: class Implementation;

/// \internal Pointer to the implementation of this class
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
private: std::unique_ptr<Implementation> dataPtr;
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
};
}
}
}

#endif
/// \brief Gets clock time
/// \return Current clock time, in nanoseconds
public: virtual std::chrono::nanoseconds Time() const = 0;

/// \brief Checks whether the clock is ready to be used or not.
/// \return True if clock is ready to be used, false otherwise
public: virtual bool IsReady() const = 0;

/// \brief Virtual destructor
public: virtual ~Clock() = default;
};

////////////////////////////////////////////////////////////////
/// \brief A Clock interface implementation that uses
/// gz::msgs::Clock messages distributed across
/// the network
class GZ_TRANSPORT_VISIBLE NetworkClock : public Clock
{
/// \brief Network clock time bases
public: enum class TimeBase : int64_t
{
REAL, ///< Use Clock message `real` time field as time base
SIM, ///< Use Clock message `sim` time field as time base
SYS ///< Use Clock message `sys` time field as time base
};

/// \brief Constructor that sets the initial time range option
/// \param[in] _topicName Name of the gz::msgs::Clock type
/// topic to be used
/// \param[in] _timeBase Time base for this clock, defaults to
/// simulation time
public: explicit NetworkClock(const std::string &_topicName,
const TimeBase _timeBase = TimeBase::SIM);

/// \brief Destructor
public: ~NetworkClock() override;

// Documentation inherited
public: std::chrono::nanoseconds Time() const override;

/// \brief Sets and distributes the given clock time
/// \param[in] _time The clock time to be set
/// \remarks No clock arbitration is performed
public: void SetTime(const std::chrono::nanoseconds _time);

// Documentation inherited
public: bool IsReady() const override;

/// \internal Implementation of this class
private: class Implementation;

/// \internal Pointer to the implementation of this class
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
private: std::unique_ptr<Implementation> dataPtr;
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
};

//////////////////////////////////////////////////
/// \brief A Clock implementation that leverages host OS time APIs
class GZ_TRANSPORT_VISIBLE WallClock : public Clock
{
/// \brief Returns system wall clock interface
/// \return The sole wall clock instance (a singleton)
public: static WallClock* Instance();

// Documentation inherited
public: std::chrono::nanoseconds Time() const override;

// Documentation inherited
public: bool IsReady() const override;

/// \internal Private singleton constructor
private: WallClock();

/// \brief Destructor
private: ~WallClock() override;

/// \internal Implementation of this class
private: class Implementation;

/// \internal Pointer to the implementation of this class
GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING
private: std::unique_ptr<Implementation> dataPtr;
GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING
};
} // namespace GZ_TRANSPORT_VERSION_NAMESPACE
} // namespace gz::transport
#endif // GZ_TRANSPORT_CLOCK_HH_
Loading

0 comments on commit 626d7fa

Please sign in to comment.