UGDK  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
component.h
Go to the documentation of this file.
1 
2 #ifndef UGDK_ACTION_3D_COMPONENT_H
3 #define UGDK_ACTION_3D_COMPONENT_H
4 
5 #include <memory>
6 #include <typeindex>
7 
8 namespace ugdk {
9 namespace action {
10 namespace mode3d {
11 
12 class Element;
13 
14 class Component {
15  public:
16  virtual ~Component() {}
17  virtual std::type_index type() const = 0;
18  std::shared_ptr<Element> owner() const;
19  protected:
20  Component() {}
22  virtual void OnTaken() = 0;
23  void Take(const std::weak_ptr<Element> &the_owner);
24  friend class Element;
25  private:
26  std::weak_ptr<Element> owner_;
27 };
28 
29 inline std::shared_ptr<Element> Component::owner() const {
30  return owner_.lock();
31 }
32 
33 namespace component {
34 
35 template <class T>
37  public:
38  const static bool is_valid = false;
39 };
40 
41 } // namespace component
42 } // namespace mode3d
43 } // namespace action
44 } // namespace ugdk
45 
46 #endif // UGDK_ACTION_3D_COMPONENT_H
A 3D Element.
Definition: element.h:26
Component()
Definition: component.h:20
Definition: animation.h:11
virtual std::type_index type() const =0
virtual void OnTaken()=0
TODO: Make this not accessible from Object.
Definition: component.h:14
void Take(const std::weak_ptr< Element > &the_owner)
std::shared_ptr< Element > owner() const
Definition: component.h:29
virtual ~Component()
Definition: component.h:16
static const bool is_valid
Definition: component.h:38