Gazebo Physics

API Reference

8.0.0~pre2
Cloneable.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018 Open Source Robotics Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16*/
17
18#ifndef GZ_PHYSICS_CLONEABLE_HH_
19#define GZ_PHYSICS_CLONEABLE_HH_
20
21#include <memory>
22
23namespace gz
24{
25 namespace physics
26 {
30 class Cloneable
31 {
33 public: Cloneable() = default;
34
36 public: virtual ~Cloneable() = default;
37
40 public: Cloneable(const Cloneable &_doNotCopy) = delete;
41
44 public: Cloneable& operator=(const Cloneable &_doNotCopy) = delete;
45
49 public: virtual std::unique_ptr<Cloneable> Clone() const = 0;
50
56 public: virtual void Copy(const Cloneable &_other) = 0;
57
62 public: virtual void Copy(Cloneable &&_other) = 0;
63 };
64
74 template <typename T>
75 class MakeCloneable final : public T, public Cloneable
76 {
80 public: template <typename... Args>
81 // This constructor is not marked as explicit because we want it to
82 // allow implicit conversions by design
83 MakeCloneable(Args&&... _args); // NOLINT
84
88 public: MakeCloneable(const MakeCloneable &_other);
89
94 public: MakeCloneable(MakeCloneable &&_other);
95
100 public: MakeCloneable &operator=(const MakeCloneable &_other);
101
107 public: MakeCloneable& operator=(MakeCloneable &&_other);
108
109 // Documentation inherited
110 public: std::unique_ptr<Cloneable> Clone() const final;
111
112 // Documentation inherited
113 public: void Copy(const Cloneable &_other) final;
114
115 // Documentation inherited
116 public: void Copy(Cloneable &&_other) final;
117 };
118 }
119}
120
121#include "gz/physics/detail/Cloneable.hh"
122
123#endif