Skip to content

Commit

Permalink
Deprecated original functionality
Browse files Browse the repository at this point in the history
Signed-off-by: Stephen Brawner <[email protected]>
  • Loading branch information
brawner committed Dec 28, 2020
1 parent 6ef5385 commit 40a2561
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
54 changes: 54 additions & 0 deletions include/sdf/Root.hh
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,68 @@ namespace sdf
/// \brief Get the number of models that are immediate (not nested) children
/// of this Root object.
/// \return Number of models contained in this Root object.
public: uint64_t ModelCount() const SDF_DEPRECATED(11.0);

/// \brief Get a model based on an index.
/// \param[in] _index Index of the model. The index should be in the
/// range [0..ModelCount()).
/// \return Pointer to the model. Nullptr if the index does not exist.
/// \sa uint64_t ModelCount() const
public: const sdf::Model *ModelByIndex(const uint64_t _index) const
SDF_DEPRECATED(11.0);

/// \brief Get whether a model name exists.
/// \param[in] _name Name of the model to check.
/// \return True if there exists a model with the given name.
public: bool ModelNameExists(const std::string &_name) const
SDF_DEPRECATED(11.0);

/// \brief Get a pointer to the model object if it exists.
/// \return A pointer to the model, nullptr if it doesn't exist
public: const sdf::Model *Model() const;

/// \brief Get the number of lights.
/// \return Number of lights contained in this Root object.
public: uint64_t LightCount() const SDF_DEPRECATED(11.0);

/// \brief Get a light based on an index.
/// \param[in] _index Index of the light. The index should be in the
/// range [0..LightCount()).
/// \return Pointer to the light. Nullptr if the index does not exist.
/// \sa uint64_t LightCount() const
public: const sdf::Light *LightByIndex(const uint64_t _index) const
SDF_DEPRECATED(11.0);

/// \brief Get whether a light name exists.
/// \param[in] _name Name of the light to check.
/// \return True if there exists a light with the given name.
public: bool LightNameExists(const std::string &_name) const
SDF_DEPRECATED(11.0);

/// \brief Get a pointer to the light object if it exists.
/// \return A pointer to the light, nullptr if it doesn't exist
public: const sdf::Light *Light() const;

/// \brief Get the number of actors.
/// \return Number of actors contained in this Root object.
public: uint64_t ActorCount() const SDF_DEPRECATED(11.0);

/// \brief Get an actor based on an index.
/// \param[in] _index Index of the actor. The actor should be in the
/// range [0..ActorCount()).
/// \return Pointer to the actor. Nullptr if the index does not exist.
/// \sa uint64_t ActorCount() const
public: const sdf::Actor *ActorByIndex(const uint64_t _index) const
SDF_DEPRECATED(11.0);

/// \brief Get whether an actor name exists.
/// \param[in] _name Name of the actor to check.
/// \return True if there exists an actor with the given name.
public: bool ActorNameExists(const std::string &_name) const
SDF_DEPRECATED(11.0);

/// \brief Get a pointer to the actor object if it exists.
/// \return A pointer to the actor, nullptr if it doesn't exist
public: const sdf::Actor *Actor() const;

/// \brief Get a pointer to the SDF element that was generated during
Expand Down
65 changes: 65 additions & 0 deletions src/Root.cc
Original file line number Diff line number Diff line change
Expand Up @@ -354,18 +354,83 @@ bool Root::WorldNameExists(const std::string &_name) const
return false;
}

/////////////////////////////////////////////////
uint64_t Root::ModelCount() const
{
return static_cast<uint64_t>(nullptr != this->Model());
}

/////////////////////////////////////////////////
const Model *Root::ModelByIndex(const uint64_t _index) const
{
if (0u == _index)
{
return this->Model();
}
return nullptr;
}

/////////////////////////////////////////////////
bool Root::ModelNameExists(const std::string &_name) const
{
return nullptr != this->Model() && this->Model()->Name() == _name;
}

/////////////////////////////////////////////////
const Model *Root::Model() const
{
return this->dataPtr->model.get();
}

uint64_t Root::LightCount() const
{
return static_cast<uint64_t>(nullptr != this->Light());
}

/////////////////////////////////////////////////
const Light *Root::LightByIndex(const uint64_t _index) const
{
if (0u == _index)
{
return this->Light();
}
return nullptr;
}

/////////////////////////////////////////////////
bool Root::LightNameExists(const std::string &_name) const
{
return nullptr != this->Light() && this->Light()->Name() == _name;
}

/////////////////////////////////////////////////
const Light *Root::Light() const
{
return this->dataPtr->light.get();
}

/////////////////////////////////////////////////
uint64_t Root::ActorCount() const
{
return static_cast<uint64_t>(nullptr != this->Actor());
}

/////////////////////////////////////////////////
const Actor *Root::ActorByIndex(const uint64_t _index) const
{
if (0u == _index)
{
return this->Actor();
}
return nullptr;
}

/////////////////////////////////////////////////
bool Root::ActorNameExists(const std::string &_name) const
{
return nullptr != this->Actor() && this->Actor()->Name() == _name;
}

/////////////////////////////////////////////////
const Actor *Root::Actor() const
{
Expand Down
20 changes: 20 additions & 0 deletions src/Root_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,26 @@ TEST(DOMRoot, Construction)
EXPECT_EQ(nullptr, root.Model());
EXPECT_EQ(nullptr, root.Light());
EXPECT_EQ(nullptr, root.Actor());

SDF_SUPPRESS_DEPRECATED_BEGIN
EXPECT_FALSE(root.ModelNameExists("default"));
EXPECT_FALSE(root.ModelNameExists(""));
EXPECT_EQ(0u, root.ModelCount());
EXPECT_TRUE(root.ModelByIndex(0) == nullptr);
EXPECT_TRUE(root.ModelByIndex(1) == nullptr);

EXPECT_FALSE(root.LightNameExists("default"));
EXPECT_FALSE(root.LightNameExists(""));
EXPECT_EQ(0u, root.LightCount());
EXPECT_TRUE(root.LightByIndex(0) == nullptr);
EXPECT_TRUE(root.LightByIndex(1) == nullptr);

EXPECT_FALSE(root.ActorNameExists("default"));
EXPECT_FALSE(root.ActorNameExists(""));
EXPECT_EQ(0u, root.ActorCount());
EXPECT_TRUE(root.ActorByIndex(0) == nullptr);
EXPECT_TRUE(root.ActorByIndex(1) == nullptr);
SDF_SUPPRESS_DEPRECATED_END
}

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

0 comments on commit 40a2561

Please sign in to comment.