Divide Framework 0.1
A free and open-source 3D Framework under heavy development
Loading...
Searching...
No Matches
IComponent.h
Go to the documentation of this file.
1/*
2 Author : Tobias Stein
3 Date : 3rd July, 2016
4 File : IComponent.h
5
6 Interface class for component class
7
8 All Rights Reserved. (c) Copyright 2016.
9*/
10
11#pragma once
12#ifndef ECS__I_COMPONENT_H__
13#define ECS__I_COMPONENT_H__
14
15#include "IEntity.h"
16
17namespace ECS
18{
19 struct CustomEvent;
20
23
25
26 template<class T>
27 class Component;
28
30 {
31 friend class ComponentManager;
32
33 protected:
34
36
38
40
42
43 public:
44
45 IComponent();
46
47 virtual ~IComponent();
48
49
50 // COMPARE
51 inline bool operator==(const IComponent& other) const { return m_HashValue == other.m_HashValue; }
52 inline bool operator!=(const IComponent& other) const { return m_HashValue == other.m_HashValue; }
53
54
55 // ACCESSOR
56
57 inline ComponentId GetComponentId() const { return this->m_ComponentID; }
58
59 inline EntityId GetOwner() const { return this->m_Owner; }
60
61 inline void SetActive(bool state) { this->m_Enabled = state; }
62 inline bool IsActive() const { return this->m_Enabled; }
63
64 virtual void OnData(const CustomEvent& data) = 0;
65 };
66}
67
68#endif // ECS__I_COMPONENT_H__
#define ECS_API
Definition: Platform.h:16
ComponentId GetComponentId() const
Definition: IComponent.h:57
bool IsActive() const
Definition: IComponent.h:62
EntityId GetOwner() const
Definition: IComponent.h:59
bool operator!=(const IComponent &other) const
Definition: IComponent.h:52
void SetActive(bool state)
Definition: IComponent.h:61
ComponentId m_ComponentID
Definition: IComponent.h:37
bool operator==(const IComponent &other) const
Definition: IComponent.h:51
virtual void OnData(const CustomEvent &data)=0
ComponentId m_HashValue
Definition: IComponent.h:35
EntityId m_Owner
Definition: IComponent.h:39
static const ComponentId INVALID_COMPONENT_ID
Definition: IComponent.h:24
size_t TypeID
Definition: Platform.h:67
ObjectID ComponentId
Definition: IComponent.h:21
size_t ObjectID
Definition: Platform.h:66
TypeID ComponentTypeId
Definition: IComponent.h:22
static const ObjectID INVALID_OBJECT_ID
Definition: Platform.h:69