Skip to content

Mark Component::Clone as const #1300

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

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 5 additions & 5 deletions include/ignition/gazebo/components/Component.hh
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ namespace components

/// \brief Clone the component.
/// \return A pointer to the component.
public: virtual std::unique_ptr<BaseComponent> Clone() = 0;
public: virtual std::unique_ptr<BaseComponent> Clone() const = 0;
};

/// \brief A component type that wraps any data type. The intention is for
Expand Down Expand Up @@ -347,7 +347,7 @@ namespace components
public: bool operator!=(const Component &_component) const;

// Documentation inherited
public: std::unique_ptr<BaseComponent> Clone() override;
public: std::unique_ptr<BaseComponent> Clone() const override;

// Documentation inherited
public: ComponentTypeId TypeId() const override;
Expand Down Expand Up @@ -416,7 +416,7 @@ namespace components
Serializer> &_component) const;

// Documentation inherited
public: std::unique_ptr<BaseComponent> Clone() override;
public: std::unique_ptr<BaseComponent> Clone() const override;

// Documentation inherited
public: ComponentTypeId TypeId() const override;
Expand Down Expand Up @@ -503,7 +503,7 @@ namespace components
//////////////////////////////////////////////////
template <typename DataType, typename Identifier, typename Serializer>
std::unique_ptr<BaseComponent>
Component<DataType, Identifier, Serializer>::Clone()
Component<DataType, Identifier, Serializer>::Clone() const
{
Component<DataType, Identifier, Serializer> clonedComp(this->Data());
return std::make_unique<Component<DataType, Identifier, Serializer>>(
Expand Down Expand Up @@ -536,7 +536,7 @@ namespace components
//////////////////////////////////////////////////
template <typename Identifier, typename Serializer>
std::unique_ptr<BaseComponent>
Component<NoData, Identifier, Serializer>::Clone()
Component<NoData, Identifier, Serializer>::Clone() const
{
return std::make_unique<Component<NoData, Identifier, Serializer>>();
}
Expand Down
2 changes: 1 addition & 1 deletion src/Component_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class NoSerialize : public components::BaseComponent
return 0;
}

public: std::unique_ptr<BaseComponent> Clone() override
public: std::unique_ptr<BaseComponent> Clone() const override
{
return nullptr;
}
Expand Down