Skip to content
Merged
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
375 changes: 186 additions & 189 deletions include/gz/transport/HandlerStorage.hh

Large diffs are not rendered by default.

71 changes: 34 additions & 37 deletions include/gz/transport/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,45 @@
#endif
#endif

namespace ignition
namespace ignition::transport
{
namespace transport
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
/// \brief Constant used when not interested in throttling.
static const uint64_t kUnthrottled = std::numeric_limits<uint64_t>::max();
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
/// \brief Constant used when not interested in throttling.
static const uint64_t kUnthrottled = std::numeric_limits<uint64_t>::max();

/// \brief Find the environment variable '_name' and return its value.
/// \param[in] _name Name of the environment variable.
/// \param[out] _value Value if the variable was found.
/// \return True if the variable was found or false otherwise.
bool IGNITION_TRANSPORT_VISIBLE env(const std::string &_name,
std::string &_value);
/// \brief Find the environment variable '_name' and return its value.
/// \param[in] _name Name of the environment variable.
/// \param[out] _value Value if the variable was found.
/// \return True if the variable was found or false otherwise.
bool IGNITION_TRANSPORT_VISIBLE env(const std::string &_name,
std::string &_value);

/// \brief split at a one character delimiter to get a vector of something
/// \param[in] _orig The string to split
/// \param[in] _delim a character to split the string at
/// \returns vector of split pieces of the string excluding the delimiter
std::vector<std::string> IGNITION_TRANSPORT_VISIBLE split(
const std::string &_orig,
char _delim);
/// \brief split at a one character delimiter to get a vector of something
/// \param[in] _orig The string to split
/// \param[in] _delim a character to split the string at
/// \returns vector of split pieces of the string excluding the delimiter
std::vector<std::string> IGNITION_TRANSPORT_VISIBLE split(
const std::string &_orig,
char _delim);

/// \brief Portable function to get the id of the current process.
/// \returns id of current process
unsigned int IGNITION_TRANSPORT_VISIBLE getProcessId();
/// \brief Portable function to get the id of the current process.
/// \returns id of current process
unsigned int IGNITION_TRANSPORT_VISIBLE getProcessId();

// Use safer functions on Windows
#ifdef _MSC_VER
#define ign_strcat strcat_s
#define ign_strcpy strcpy_s
#define ign_sprintf sprintf_s
#define ign_strdup _strdup
#else
#define ign_strcat std::strcat
#define ign_strcpy std::strcpy
#define ign_sprintf std::sprintf
#define ign_strdup strdup
#endif
}
// Use safer functions on Windows
#ifdef _MSC_VER
#define ign_strcat strcat_s
#define ign_strcpy strcpy_s
#define ign_sprintf sprintf_s
#define ign_strdup _strdup
#else
#define ign_strcat std::strcat
#define ign_strcpy std::strcpy
#define ign_sprintf std::sprintf
#define ign_strdup strdup
#endif
}
}

Expand Down
131 changes: 64 additions & 67 deletions include/gz/transport/MessageInfo.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,85 +24,82 @@
#include "gz/transport/config.hh"
#include "gz/transport/Export.hh"

namespace ignition
namespace ignition::transport
{
namespace transport
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
class MessageInfoPrivate;

/// \brief A class that provides information about the message received.
class IGNITION_TRANSPORT_VISIBLE MessageInfo
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
class MessageInfoPrivate;

/// \brief A class that provides information about the message received.
class IGNITION_TRANSPORT_VISIBLE MessageInfo
{
/// \brief Default constructor.
public: MessageInfo();

/// \brief Explicit copy constructor (The copy constructor is deleted by
/// default due to the use of std::unique_ptr member).
/// \param[in] _other an instance to copy data from
public: MessageInfo(const MessageInfo &_other);

/// \brief Move constructor
/// \param[in] _other an instance data is moved from
public: MessageInfo(MessageInfo &&_other); // NOLINT

/// \brief Destructor.
public: ~MessageInfo();

/// \brief Get the topic name associated to the message.
/// \return The topic name.
public: const std::string &Topic() const;

/// \brief Set the topic name associated to the message.
public: void SetTopic(const std::string &_topic);

/// \brief Get the name of the message type.
/// \return The message type name.
public: const std::string &Type() const;

/// \brief Set the name of the message type.
/// \param[in] _type the type name to set.
public: void SetType(const std::string &_type);

/// \brief Get the name of the partition.
/// \return The partition name.
public: const std::string &Partition() const;

/// \brief Set the partition of the topic the message was on.
/// \param[in] _partition of the topic.
public: void SetPartition(const std::string &_partition);

/// \brief Set both the topic and the partition from a single string.
/// \param[in] _fullyQualifiedName The topic string with the partition
/// information included.
/// \return true if the topic and partition were set
/// \sa TopicUtils::FullyQualifiedName
public: bool SetTopicAndPartition(const std::string &_fullyQualifiedName);

/// \brief Whether the message is coming from a node within this process.
/// \return True when intra-process, false otherwise.
public: bool IntraProcess() const;

/// \brief Set whether this message is intra-process or not.
/// \param[in] _value The intra-process value.
public: void SetIntraProcess(bool _value);
/// \brief Default constructor.
public: MessageInfo();

/// \brief Explicit copy constructor (The copy constructor is deleted by
/// default due to the use of std::unique_ptr member).
/// \param[in] _other an instance to copy data from
public: MessageInfo(const MessageInfo &_other);

/// \brief Move constructor
/// \param[in] _other an instance data is moved from
public: MessageInfo(MessageInfo &&_other); // NOLINT

/// \brief Destructor.
public: ~MessageInfo();

/// \brief Get the topic name associated to the message.
/// \return The topic name.
public: const std::string &Topic() const;

/// \brief Set the topic name associated to the message.
public: void SetTopic(const std::string &_topic);

/// \brief Get the name of the message type.
/// \return The message type name.
public: const std::string &Type() const;

/// \brief Set the name of the message type.
/// \param[in] _type the type name to set.
public: void SetType(const std::string &_type);

/// \brief Get the name of the partition.
/// \return The partition name.
public: const std::string &Partition() const;

/// \brief Set the partition of the topic the message was on.
/// \param[in] _partition of the topic.
public: void SetPartition(const std::string &_partition);

/// \brief Set both the topic and the partition from a single string.
/// \param[in] _fullyQualifiedName The topic string with the partition
/// information included.
/// \return true if the topic and partition were set
/// \sa TopicUtils::FullyQualifiedName
public: bool SetTopicAndPartition(const std::string &_fullyQualifiedName);

/// \brief Whether the message is coming from a node within this process.
/// \return True when intra-process, false otherwise.
public: bool IntraProcess() const;

/// \brief Set whether this message is intra-process or not.
/// \param[in] _value The intra-process value.
public: void SetIntraProcess(bool _value);

#ifdef _WIN32
// Disable warning C4251 which is triggered by
// std::unique_ptr
#pragma warning(push)
#pragma warning(disable: 4251)
#endif
/// \internal
/// \brief Pointer to private data.
protected: std::unique_ptr<MessageInfoPrivate> dataPtr;
/// \internal
/// \brief Pointer to private data.
protected: std::unique_ptr<MessageInfoPrivate> dataPtr;
#ifdef _WIN32
#pragma warning(pop)
#endif
};
}
};
}
}
#endif
71 changes: 34 additions & 37 deletions include/gz/transport/NetUtils.hh
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,46 @@
#include "gz/transport/config.hh"
#include "gz/transport/Export.hh"

namespace ignition
namespace ignition::transport
{
namespace transport
{
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
/// \brief Determine if an IP is private.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \param[in] _ip Input IP address.
/// \return true if the IP address is private.
bool isPrivateIP(const char *_ip);
// Inline bracket to help doxygen filtering.
inline namespace IGNITION_TRANSPORT_VERSION_NAMESPACE {
//
/// \brief Determine if an IP is private.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \param[in] _ip Input IP address.
/// \return true if the IP address is private.
bool isPrivateIP(const char *_ip);

/// \brief Determine if an IP is private.
/// \param[in] _hostname Hostname
/// \param[out] _ip IP associated to the input hostname.
/// \return 0 when success.
int hostnameToIp(char *_hostname, std::string &_ip);
/// \brief Determine if an IP is private.
/// \param[in] _hostname Hostname
/// \param[out] _ip IP associated to the input hostname.
/// \return 0 when success.
int hostnameToIp(char *_hostname, std::string &_ip);

/// \brief Determine IP or hostname.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \return The IP or hostname of this host.
std::string IGNITION_TRANSPORT_VISIBLE determineHost();
/// \brief Determine IP or hostname.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \return The IP or hostname of this host.
std::string IGNITION_TRANSPORT_VISIBLE determineHost();

/// \brief Determine the list of network interfaces for this machine.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \return The list of network interfaces.
std::vector<std::string> IGNITION_TRANSPORT_VISIBLE determineInterfaces();
/// \brief Determine the list of network interfaces for this machine.
/// Reference: https://github.com/ros/ros_comm/blob/hydro-devel/clients/
/// roscpp/src/libros/network.cpp
/// \return The list of network interfaces.
std::vector<std::string> IGNITION_TRANSPORT_VISIBLE determineInterfaces();

/// \brief Determine the computer's hostname.
/// \return The computer's hostname.
std::string IGNITION_TRANSPORT_VISIBLE hostname();
/// \brief Determine the computer's hostname.
/// \return The computer's hostname.
std::string IGNITION_TRANSPORT_VISIBLE hostname();

/// \brief Determine your login name.
/// \return Name used to gain access to the computer.
/// On linux and Mac only, if determination
/// of your login name failes then a string of the form "error-UUID"
/// is returned where UUID is a universally unique identifier.
std::string IGNITION_TRANSPORT_VISIBLE username();
}
/// \brief Determine your login name.
/// \return Name used to gain access to the computer.
/// On linux and Mac only, if determination
/// of your login name failes then a string of the form "error-UUID"
/// is returned where UUID is a universally unique identifier.
std::string IGNITION_TRANSPORT_VISIBLE username();
}
}

Expand Down
Loading