1 #ifndef NETWORK_SYNC_VOXEL_ACCESSOR_MULTIPLETILES_RECEIVER_HPP
2 #define NETWORK_SYNC_VOXEL_ACCESSOR_MULTIPLETILES_RECEIVER_HPP
4 #include "blub/core/byteArray.hpp"
5 #include "blub/log/global.hpp"
6 #include "blub/core/sharedPointer.hpp"
7 #include "blub/async/dispatcher.hpp"
8 #include "blub/sync/voxel/accessor/multipleTiles/base.hpp"
9 #include "blub/procedural/voxel/simple/accessor.hpp"
10 #include "blub/procedural/voxel/simple/base.hpp"
11 #include "blub/procedural/voxel/tile/accessor.hpp"
13 #include <boost/iostreams/copy.hpp>
14 #include <boost/iostreams/filter/bzip2.hpp>
15 #include <boost/iostreams/filtering_stream.hpp>
16 #include <boost/iostreams/stream.hpp>
28 namespace multipleTiles
32 template <
class voxelType>
44 : t_base(*todoListenerMaster)
53 t_base::m_master.post(boost::bind(&receiver::receivedTileDataMaster,
this, data));
55 void receivedTilePtrData(t_tileDataPtr data)
57 BASSERT(!data.isNull());
59 t_base::m_master.post(boost::bind(&receiver::receivedTileDataPtrMaster,
this, data));
63 void receivedTileDataMaster(
const byteArray& data)
67 std::istringstream input(std::string(data.data(), data.size()));
71 if (type == sendType::lockForEdit)
73 #ifdef BLUB_LOG_VOXEL_ACCESSOR_SYNC
74 blub::BOUT(
"type == sendType::lockForEdit id:" + blub::string::number(
id));
79 if (type == sendType::unlockForEdit)
81 #ifdef BLUB_LOG_VOXEL_ACCESSOR_SYNC
82 blub::BOUT(
"type == sendType::unlockForEdit id:" + blub::string::number(
id));
91 if (type == sendType::removeTile)
93 #ifdef BLUB_LOG_VOXEL_ACCESSOR_SYNC
94 blub::BOUT(
"type == sendType::removeTile id:" + blub::string::number(
id));
100 BASSERT((uint32)data.size() >
sizeof(sendType) +
sizeof(t_tileId));
101 BASSERT(type == sendType::setTile);
102 #ifdef BLUB_LOG_VOXEL_ACCESSOR_SYNC
103 blub::BOUT(
"type == sendType::setTile id:" + blub::string::number(
id));
107 format >> toDecompress;
111 std::stringstream toReadFromBuffer;
114 boost::iostreams::stream<boost::iostreams::array_source> src(toDecompress.data(), toDecompress.size());
115 boost::iostreams::filtering_istream filterIn;
116 filterIn.push(boost::iostreams::bzip2_decompressor());
118 boost::iostreams::copy(filterIn, toReadFromBuffer);
123 toReadFrom >> *workTile.get();
127 void receivedTileDataPtrMaster(t_tileDataPtr data)
129 receivedTileDataMaster(*data.data());
149 #endif // NETWORK_SYNC_VOXEL_ACCESSOR_MULTIPLETILES_RECEIVER_HPP
The base class gets derived by every class in the namespace simple::*. It represends one level of det...
Definition: predecl.hpp:30
virtual void lockForEditMaster()
lockForEditMaster locks for write, or waits until possible. Call by master dispatcher.
Definition: base.hpp:228
virtual t_tilePtr createTile() const
createTile creates a new Tile. Uses callback set by setCreateTileCallback()
Definition: base.hpp:249
virtual void unlockForEditMaster()
unlockForEditMaster unlocks write. Call by master dispatcher.
Definition: base.hpp:236
Definition: sharedPointer.hpp:12
static t_base::pointer create()
create creates an instance.
Definition: accessor.hpp:63
void addToChangeList(const t_tileId &id, t_tilePtr toAdd)
addToChangeList adds a tile to the change-list.
Definition: base.hpp:210
Definition: receiver.hpp:33
Definition: dispatcher.hpp:29
The accessor class caches all voxel needed by tile::surface for an extremly optimized and fast calcul...
Definition: predecl.hpp:21
Definition: byteArray.hpp:17
Definition: portable_binary_iarchive.hpp:68
Definition: deadlineTimer.hpp:10
blub::async::strand m_master
m_master The master synchronises jobs for the worker-thread and writes to class member. The master calls all methods which end with *Master.
Definition: base.hpp:143
void setCreateTileCallback(const t_createTileCallback &callback)
setCreateTileCallback sets a callback for creating tiles. Use this method if you want to create custo...
Definition: base.hpp:204
Definition: customVertexInformation.cpp:177