OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
IComponent.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef ICOMPONENT_H
19 #define ICOMPONENT_H
20 
21 #include "index.h"
22 
23 namespace Engine
24 {
29  template< class Sender >
30  class IComponent
31  {
32  public:
33 
34  friend class ComponentManager;
35 
39  using IComponentList = std::list< IComponent<Sender> * >;
40 
46  IComponent(const std::string & component_name );
47  virtual ~IComponent(){}
48 
56  //virtual bool message( Sender * sender , Message * msg )=0;
57 
63  const std::string & getName(void) const;
64 
70  uint getID(void) const;
71 
77  void addComponent( IComponent < Sender > * component );
78 
85  bool hasComponent( const std::string & component_name );
86 
93  IComponent< Sender > * getComponent( const std::string & component_name );
94 
101  IComponentList getComponents( const std::string & component_name );
102 
108  void remove( IComponent < Sender > * component );
109 
110 
111  private:
112 
113  std::string mComponentName;
114 
115  protected:
116 
117  uint mComponentId;
118  IComponentList mComponentList;
119 
120  };
121 
122  #include "IComponent.template"
123 }
124 
125 #endif // ICOMPONENT_H
bool hasComponent(const std::string &component_name)
hasComponent
Definition: IComponent.h:38
uint getID(void) const
getID
Definition: IComponent.h:20
IComponent< Sender > * getComponent(const std::string &component_name)
getComponent
Definition: IComponent.h:50
Definition: element.h:23
void addComponent(IComponent< Sender > *component)
addComponent
Definition: IComponent.h:26
const std::string & getName(void) const
message
Definition: IComponent.h:14
IComponent(const std::string &component_name)
IComponent.
Definition: IComponent.h:7
IComponentList getComponents(const std::string &component_name)
getComponents
Definition: IComponent.h:62
The IComponent class.
Definition: IComponent.h:30
std::list< IComponent< Sender > * > IComponentList
Definition: IComponent.h:39