 |
Gorgon Game Engine
|
Go to the documentation of this file.
3 #include "../Animation.h"
27 basic_Instance(A_ &instance,
bool owner =
true) : instance(&instance), isowned(owner) { }
34 other.isowned =
false;
35 other.instance =
nullptr;
44 isowned = other.isowned;
45 instance = other.instance;
46 other.isowned =
false;
47 other.instance =
nullptr;
57 this->instance = &instance;
64 return instance !=
nullptr;
73 throw std::runtime_error(
"Instance contains no animation");
91 this->isowned = owner;
99 instance->DeleteAnimation();
107 auto temp = instance;
123 A_ *instance =
nullptr;
124 bool isowned =
false;
129 template<
class Target_,
class Original_>
133 if(!original.HasAnimation())
136 bool owned = original.
IsOwner();
137 Target_ *anim =
dynamic_cast<Target_*
>(original.Release());
139 throw std::runtime_error(
"Animation types are not compatible");
basic_Instance< Target_ > AnimationCast(basic_Instance< Original_ > &&original)
Moves one type of animation into another.
Definition: Instance.h:130
This class allows storing an animation instance regarless of its underlying type as a value.
Definition: Instance.h:20
void Remove()
Removes the animation stored in the container, if the container owns the animation,...
Definition: Instance.h:97
A_ & GetAnimation() const
Returns the animation stored in the object.
Definition: Instance.h:69
A_ * Release()
Removes the animation from the storage without destroying it.
Definition: Instance.h:106
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
bool IsOwner() const
Whether the stored animation is owned by this container.
Definition: Instance.h:117
basic_Instance(basic_Instance &&other)
Move constructor.
Definition: Instance.h:33
This is the base class for all animations.
Definition: Animation.h:306
basic_Instance()=default
Empty constructor.
void SetAnimation(A_ &value, bool owner=true)
Sets the animation stored in this container.
Definition: Instance.h:87
constexpr Type Animation
Definition: GID.h:187
A_ & operator*() const
Alias for GetAnimation.
Definition: Instance.h:77
basic_Instance(const basic_Instance &)=delete
Copy constructor is disabled for ownership reasons.
basic_Instance(A_ &instance, bool owner=true)
Filling constructor.
Definition: Instance.h:27
basic_Instance & operator=(const basic_Instance &)=delete
Copy assignment.
A_ * operator->() const
Alias for GetAnimation.
Definition: Instance.h:82
bool HasAnimation() const
Check if this instance has an animation.
Definition: Instance.h:63
Specializing this class allows code injection to animation instances.
Definition: Instance.h:11