Emergency 20 Dokumentation  4.2.0
DataCacheItemFactory.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
15 #include <boost/noncopyable.hpp>
16 
17 #include <memory> // for std::unique_ptr
18 
19 
20 //[-------------------------------------------------------]
21 //[ Forward declarations ]
22 //[-------------------------------------------------------]
23 namespace qsf
24 {
25  class Map;
26  class Entity;
27  namespace game
28  {
29  class BitStream;
30  }
31 }
32 namespace em5
33 {
34  namespace multiplayer
35  {
36  class DataCacheBase;
37  }
38 }
39 
40 
41 //[-------------------------------------------------------]
42 //[ Namespace ]
43 //[-------------------------------------------------------]
44 namespace em5
45 {
46  namespace multiplayer
47  {
48 
49 
50  //[-------------------------------------------------------]
51  //[ Classes ]
52  //[-------------------------------------------------------]
57  class EM5_API_EXPORT DataCacheItemFactory : public boost::noncopyable
58  {
59 
60 
61  //[-------------------------------------------------------]
62  //[ Public definitions ]
63  //[-------------------------------------------------------]
64  public:
66  {
67  Hidden,
68  Transform,
69  Movable,
70  Fire,
71  Damage,
72  Health,
73  Navigation,
74  Inventory,
75  Link,
76  BoneToBoneLink,
77  GameLogic,
78  TimeOfDay,
79  MeshAnimation,
80  VehicleCrane,
81  Waterjet,
82  BoneLink,
83  WaterCannon,
84  Mesh,
85  Door,
86  EventId,
87  Tree,
88  DlkLadder,
89  Helicopter,
90  Swing,
91  Boat,
92  Action,
93  Ghost,
94  BuildingOverlay,
95  StatusOverlay,
96  Particles,
97  Building,
98  Person,
99  PersonMagnet,
100  Vehicle,
101  BarrierTape,
102  RescueBus,
103  SupportLegs,
104  UsableByEngineer,
105  SpeakToPerson,
106  PoliceDogTarget,
107  Bury,
108  Weather,
109  _NumTypes
110 
111  // Plugins may add additional component types in order to allow for their own "DataCacheBase" sub-classes.
112  // These will not be part of this enum, of course, but have to be defined as constant uint8 values.
113  // When doing this, please consider:
114  // - New component type IDs must not interfere with existing ones, so use at least a value of "TrackedComponentType::_NumTypes".
115  // - It is not a requirement to start with "TrackedComponentType::_NumTypes", higher values are okay as well.
116  // - There is a maximum allowed value of 63, as types are sent usings 6 bits.
117  // - Different plugins using the same component type IDs for different custom components will not work together.
118  };
119 
120  typedef boost::container::flat_map<uint8, std::unique_ptr<DataCacheBase>> ComponentCacheMap;
121 
122 
127  class Listener : public boost::noncopyable
128  {
129  public:
130  virtual std::string componentIdToString(uint8 componentId) { return std::string(); }
131  virtual bool isEntityCacheRelevant(qsf::Entity& entity) { return false; }
132  virtual void createCacheItemsForEntity(qsf::Entity& entity, ComponentCacheMap& componentCacheMap) {}
133  virtual void createCacheItemsForCoreEntity(const qsf::Entity& entity, ComponentCacheMap& componentCacheMap) {}
134  };
135 
136 
137  //[-------------------------------------------------------]
138  //[ Public static methods ]
139  //[-------------------------------------------------------]
140  public:
141  static std::string componentIdToString(uint8 componentId);
142  static bool isEntityCacheRelevant(qsf::Entity& entity);
143  static void createCacheItemsForEntity(qsf::Entity& entity, ComponentCacheMap& componentCacheMap);
144  static void createCacheItemsForCoreEntity(const qsf::Entity& entity, ComponentCacheMap& componentCacheMap);
145 
146  static void addListener(Listener& listener);
147  static void removeListener(Listener& listener);
148 
149 
150  //[-------------------------------------------------------]
151  //[ Private static data ]
152  //[-------------------------------------------------------]
153  private:
154  static std::vector<Listener*> mListeners;
155 
156 
157  };
158 
159 
160 //[-------------------------------------------------------]
161 //[ Namespace ]
162 //[-------------------------------------------------------]
163  } // multiplayer
164 } // em5
Definition: ActionPriority.h:13
Interface class definition for multiplayer data cache item factory listeners.
Definition: DataCacheItemFactory.h:127
Entity class.
Definition: Entity.h:46
virtual std::string componentIdToString(uint8 componentId)
Definition: DataCacheItemFactory.h:130
#define EM5_API_EXPORT
Definition: Export.h:28
Definition: PickupPersonByParamedicAction.h:21
EMERGENCY 5 multiplayer data cache item factory.
Definition: DataCacheItemFactory.h:57
virtual void createCacheItemsForEntity(qsf::Entity &entity, ComponentCacheMap &componentCacheMap)
Definition: DataCacheItemFactory.h:132
boost::container::flat_map< uint8, std::unique_ptr< DataCacheBase > > ComponentCacheMap
Definition: DataCacheItemFactory.h:120
virtual void createCacheItemsForCoreEntity(const qsf::Entity &entity, ComponentCacheMap &componentCacheMap)
Definition: DataCacheItemFactory.h:133
virtual bool isEntityCacheRelevant(qsf::Entity &entity)
Definition: DataCacheItemFactory.h:131
TrackedComponentType
Definition: DataCacheItemFactory.h:65
unsigned char uint8
Definition: PlatformTypes.h:175