Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up namespaces #502

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading