diff --git a/include/gz/fuel_tools/WorldIdentifier.hh b/include/gz/fuel_tools/WorldIdentifier.hh index d4579248..0cc99faa 100644 --- a/include/gz/fuel_tools/WorldIdentifier.hh +++ b/include/gz/fuel_tools/WorldIdentifier.hh @@ -150,6 +150,16 @@ namespace gz /// \return World information string public: std::string AsPrettyString(const std::string &_prefix = "") const; + /// \brief Returns the privacy setting of the world. + /// \return True if the world is private, false if the world is + /// public. + public: bool Private() const; + + /// \brief Set the privacy setting of the world. + /// \param[in] _private True indicates the world is private, + /// false indicates the world is public. + public: void SetPrivate(bool _private); + /// \brief PIMPL private: std::unique_ptr dataPtr; }; diff --git a/src/WorldIdentifier.cc b/src/WorldIdentifier.cc index 9c9296a0..26b22244 100644 --- a/src/WorldIdentifier.cc +++ b/src/WorldIdentifier.cc @@ -43,8 +43,12 @@ class gz::fuel_tools::WorldIdentifierPrivate /// \brief World version. Valid versions start from 1, 0 means the tip. public: unsigned int version{0}; - /// \brief Path of this model in the local cache + /// \brief Path of this world in the local cache public: std::string localPath; + + /// \brief True indicates the world is private, false indicates the + /// world is public. + public: bool privacy{false}; }; ////////////////////////////////////////////////// @@ -229,3 +233,14 @@ std::string WorldIdentifier::AsPrettyString(const std::string &_prefix) const return out.str(); } +////////////////////////////////////////////////// +bool WorldIdentifier::Private() const +{ + return this->dataPtr->privacy; +} + +////////////////////////////////////////////////// +void WorldIdentifier::SetPrivate(bool _private) +{ + this->dataPtr->privacy = _private; +} diff --git a/src/WorldIdentifier_TEST.cc b/src/WorldIdentifier_TEST.cc index 947d8fd1..7ad7566e 100644 --- a/src/WorldIdentifier_TEST.cc +++ b/src/WorldIdentifier_TEST.cc @@ -37,6 +37,12 @@ TEST(WorldIdentifier, SetFields) EXPECT_EQ(std::string("hello"), id.Name()); EXPECT_EQ(std::string("acai"), id.Owner()); EXPECT_EQ(6u, id.Version()); + + EXPECT_FALSE(id.Private()); + id.SetPrivate(true); + EXPECT_TRUE(id.Private()); + id.SetPrivate(false); + EXPECT_FALSE(id.Private()); } /////////////////////////////////////////////////