Emergency 20 Dokumentation  4.2.0
Observer-inl.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Includes ]
6 //[-------------------------------------------------------]
8 
9 
10 //[-------------------------------------------------------]
11 //[ Namespace ]
12 //[-------------------------------------------------------]
13 namespace em5
14 {
15 
16 
17  //[-------------------------------------------------------]
18  //[ Public methods ]
19  //[-------------------------------------------------------]
20  inline const std::string& Observer::getName() const
21  {
22  return mName;
23  }
24 
25  inline void Observer::setName(const std::string& name)
26  {
27  mName = name;
28  }
29 
30  template<typename T>
32  {
33  return static_cast<T&>(getParentEvent()->createObserverByTypeId(T::GAMELOGIC_TYPE_ID, entityId));
34  }
35 
36  template<typename T>
38  {
39  return static_cast<T*>(getParentEvent()->getObserverByTypeId(T::GAMELOGIC_TYPE_ID, entityId));
40  }
41 
42 
43 //[-------------------------------------------------------]
44 //[ Namespace ]
45 //[-------------------------------------------------------]
46 } // em5
Definition: ActionPriority.h:13
Observer * getObserverByTypeId(uint32 typeId, uint64 entityId)
Find an existing observer of the specified type ID, inside the given entity.
FreeplayEvent * getParentEvent() const
Get parent event.
uint64_t uint64
Definition: PlatformTypes.h:184
T & createObserver(uint64 entityId)
Create observer.
Definition: Observer-inl.h:31
Observer & createObserverByTypeId(uint32 typeId, uint64 entityId, const std::string &name=std::string())
Create a new observer of the specified type ID, inside the given entity.
T * getObserver(uint64 entityId)
Get observer.
Definition: Observer-inl.h:37
const std::string & getName() const
Get the observer's name.
Definition: Observer-inl.h:20
void setName(const std::string &name)
Set the observer's name; the name has no special meaning internally, use it as you like...
Definition: Observer-inl.h:25