Skip to content

Commit

Permalink
Fix ABI failure and linter
Browse files Browse the repository at this point in the history
Signed-off-by: Addisu Z. Taddese <addisu@openrobotics.org>
  • Loading branch information
azeey committed Mar 20, 2024
1 parent 5bcb60f commit b36e874
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
8 changes: 7 additions & 1 deletion include/gz/transport/NodeShared.hh
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,14 @@ namespace gz
{
/// \brief NodeShared is a singleton. This method gets the
/// NodeShared instance shared between all the nodes.
/// Note: This is deprecated. Please use \sa SharedInstance
/// \return Pointer to the current NodeShared instance.
public: static std::shared_ptr<NodeShared> Instance();
public: static NodeShared *Instance() GZ_DEPRECATED(13);

/// \brief NodeShared is a singleton. This method gets the
/// a reference counted NodeShared instance shared between all the nodes.
/// \return A shared_ptr to the current NodeShared instance.
public: static std::shared_ptr<NodeShared> SharedInstance();

/// \brief Receive data and control messages.
public: void RunReceptionTask();
Expand Down
2 changes: 1 addition & 1 deletion log/src/Recorder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Recorder::Implementation::Implementation()
this->OnMessageReceived(_data, _len, _info);
};

auto shared = NodeShared::Instance();
auto shared = NodeShared::SharedInstance();

this->discovery = std::make_unique<MsgDiscovery>(
Uuid().ToString(), shared->discoveryIP, shared->msgDiscPort);
Expand Down
8 changes: 4 additions & 4 deletions src/Node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ namespace gz
//////////////////////////////////////////////////
int rcvHwm()
{
return NodeShared::Instance()->RcvHwm();
return NodeShared::SharedInstance()->RcvHwm();
}

//////////////////////////////////////////////////
int sndHwm()
{
return NodeShared::Instance()->SndHwm();
return NodeShared::SharedInstance()->SndHwm();
}

//////////////////////////////////////////////////
Expand All @@ -104,14 +104,14 @@ namespace gz
{
/// \brief Default constructor.
public: PublisherPrivate()
: shared(NodeShared::Instance())
: shared(NodeShared::SharedInstance())
{
}

/// \brief Constructor
/// \param[in] _publisher The message publisher.
public: explicit PublisherPrivate(const MessagePublisher &_publisher)
: shared(NodeShared::Instance()),
: shared(NodeShared::SharedInstance()),
publisher(_publisher)
{
}
Expand Down
4 changes: 3 additions & 1 deletion src/NodePrivate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef GZ_TRANSPORT_NODEPRIVATE_HH_
#define GZ_TRANSPORT_NODEPRIVATE_HH_

#include <memory>
#include <string>
#include <unordered_set>

Expand All @@ -32,6 +33,7 @@ namespace gz
{
inline namespace GZ_TRANSPORT_VERSION_NAMESPACE
{
class NodeShared;

/// \internal
/// \brief Private data for Node class.
Expand Down Expand Up @@ -66,7 +68,7 @@ namespace gz

/// \brief Pointer to the object shared between all the nodes within the
/// same process.
public: std::shared_ptr<NodeShared> shared = NodeShared::Instance();
public: std::shared_ptr<NodeShared> shared = NodeShared::SharedInstance();

/// \brief Partition for this node.
public: std::string partition = hostname() + ":" + username();
Expand Down
12 changes: 11 additions & 1 deletion src/NodeShared.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,17 @@ void sendAuthErrorHelper(zmq::socket_t &_socket, const std::string &_err)
}

//////////////////////////////////////////////////
std::shared_ptr<NodeShared> NodeShared::Instance()
NodeShared *NodeShared::Instance()
{
// This is a deprecated function, but since it's public, the following ensures
// backward compatibility by instantiating a shared_ptr that never gets
// deleted.
static std::shared_ptr<NodeShared> nodeShared = NodeShared::SharedInstance();
return nodeShared.get();

Check warning on line 161 in src/NodeShared.cc

View check run for this annotation

Codecov / codecov/patch

src/NodeShared.cc#L160-L161

Added lines #L160 - L161 were not covered by tests
}

//////////////////////////////////////////////////
std::shared_ptr<NodeShared> NodeShared::SharedInstance()
{
// Create an instance of NodeShared per process so the ZMQ context
// is not shared between different processes.
Expand Down

0 comments on commit b36e874

Please sign in to comment.