voxelTerrain
 All Classes Functions Variables Typedefs Enumerations Pages
receiver.hpp
1 #ifndef NETWORK_SYNC_VOXEL_ACCESSOR_TERRAIN_RECEIVER_HPP
2 #define NETWORK_SYNC_VOXEL_ACCESSOR_TERRAIN_RECEIVER_HPP
3 
4 #include "blub/async/predecl.hpp"
5 #include "blub/core/byteArray.hpp"
6 #include "blub/core/globals.hpp"
7 #include "blub/core/sharedPointer.hpp"
8 #include "blub/core/vector.hpp"
9 #include "blub/procedural/voxel/terrain/accessor.hpp"
10 #include "blub/procedural/voxel/terrain/base.hpp"
11 #include "blub/sync/voxel/accessor/multipleTiles/receiver.hpp"
12 
13 
14 namespace blub
15 {
16 namespace sync
17 {
18 namespace voxel
19 {
20 namespace accessor
21 {
22 namespace terrain
23 {
24 
25 
26 template <class voxelType>
27 class receiver : public procedural::voxel::terrain::base< sharedPointer<procedural::voxel::tile::accessor<voxelType> > >
28 {
29 public:
31  typedef t_multipleTiles* t_multipleTilesPtr;
32 
34 
37 
38  receiver(async::dispatcher *todoListenerMaster, const uint16 &numLod)
39  {
40  for (int32 ind = 0; ind < numLod; ++ind)
41  {
42  t_multipleTilesPtr lod(new t_multipleTiles(todoListenerMaster, ind));
43  t_base::m_lods.push_back(lod);
44  }
45  }
46  virtual ~receiver()
47  {
48  for (auto toDelete : t_base::m_lods)
49  {
50  delete toDelete;
51  }
52  t_base::m_lods.clear();
53  }
54 
55  // "receive sync"
56  void receivedTileData(const byteArray& data)
57  {
58  BASSERT((uint32)data.size() > sizeof(uint32));
59 
60  uint32 lodIndex;
61  byteArray restOftheData;
62 
63  std::istringstream input(std::string(data.data(), data.size()));
65 
66  format >> lodIndex;
67  format >> restOftheData;
68 
69  static_cast<t_multipleTilesPtr>(t_base::m_lods[lodIndex])->receivedTileData(restOftheData);
70  }
71  void receivedTilePtrData(t_tileDataPtr data)
72  {
73  receivedTileData(*data);
74  }
75 
76 private:
77 
78 
79 };
80 
81 
82 }
83 }
84 }
85 }
86 }
87 
88 
89 
90 #endif // NETWORK_SYNC_VOXEL_ACCESSOR_TERRAIN_RECEIVER_HPP
Definition: sharedPointer.hpp:12
Definition: dispatcher.hpp:29
Definition: byteArray.hpp:17
The base class gets derived by every class in the namesapce terrain. It holds various level of detail...
Definition: predecl.hpp:58
Definition: portable_binary_iarchive.hpp:68
Definition: deadlineTimer.hpp:10
Definition: customVertexInformation.cpp:177