Skip to content

Commit

Permalink
Add Private function to world identifier (#414)
Browse files Browse the repository at this point in the history
* Add Private function to world identifier

Signed-off-by: Nate Koenig <[email protected]>

* Update include/gz/fuel_tools/WorldIdentifier.hh

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Signed-off-by: Nate Koenig <[email protected]>

* Wrap line

Signed-off-by: Nate Koenig <[email protected]>

---------

Signed-off-by: Nate Koenig <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
nkoenig and ahcorde authored Apr 16, 2024
1 parent 6cbce88 commit 6880aec
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
10 changes: 10 additions & 0 deletions include/gz/fuel_tools/WorldIdentifier.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<WorldIdentifierPrivate> dataPtr;
};
Expand Down
17 changes: 16 additions & 1 deletion src/WorldIdentifier.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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};
};

//////////////////////////////////////////////////
Expand Down Expand Up @@ -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;
}
6 changes: 6 additions & 0 deletions src/WorldIdentifier_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

/////////////////////////////////////////////////
Expand Down

0 comments on commit 6880aec

Please sign in to comment.