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

Add Private function to world identifier #414

Merged
merged 3 commits into from
Apr 16, 2024
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
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