1 | #pragma once |
---|
2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
3 | * |
---|
4 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
5 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
6 | * (at your option) any later version. The full license is in LICENSE file |
---|
7 | * included with this distribution, and on the openscenegraph.org website. |
---|
8 | * |
---|
9 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
10 | * You have to aquire licenses for all used proprietary modules. |
---|
11 | * |
---|
12 | * This library is distributed in the hope that it will be useful, |
---|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
15 | * OpenSceneGraph Public License for more details. |
---|
16 | */ |
---|
17 | |
---|
18 | #include "dataIO_cluster.h" |
---|
19 | |
---|
20 | #include <osg/notify> |
---|
21 | #include <osg/ArgumentParser> |
---|
22 | |
---|
23 | #include <iostream> |
---|
24 | #include <string> |
---|
25 | #include <vector> |
---|
26 | #include <boost/asio.hpp> |
---|
27 | #include <boost/date_time/posix_time/posix_time.hpp> |
---|
28 | |
---|
29 | |
---|
30 | namespace osgVisual |
---|
31 | { |
---|
32 | |
---|
33 | /** |
---|
34 | * \brief This is a Boost ASIO iostream implementation of dataIO_cluster.. |
---|
35 | * |
---|
36 | * This class uses Boost ASIO and it iostream privider to fullfil the functions of dataIO_cluster. |
---|
37 | * It sends the clusterdata into the network to any connected client. |
---|
38 | * |
---|
39 | * |
---|
40 | * \todo Add getHorizonColor to transport it to slave for consistent fog. |
---|
41 | * @author Torben Dannhauer |
---|
42 | * @date May 2010 |
---|
43 | */ |
---|
44 | class dataIO_clusterAsioTcpIostream : public dataIO_cluster |
---|
45 | { |
---|
46 | |
---|
47 | public: |
---|
48 | |
---|
49 | dataIO_clusterAsioTcpIostream(); |
---|
50 | virtual ~dataIO_clusterAsioTcpIostream(); |
---|
51 | |
---|
52 | void init( osg::ArgumentParser& arguments_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ ); |
---|
53 | void shutdown(); |
---|
54 | bool sendTO_OBJvaluesToSlaves(); |
---|
55 | bool readTO_OBJvaluesFromMaster(); |
---|
56 | void reportAsReadyToSwap(); |
---|
57 | bool waitForSwap(); |
---|
58 | bool waitForAllReadyToSwap(); |
---|
59 | bool sendSwapCommand(); |
---|
60 | |
---|
61 | private: |
---|
62 | /** |
---|
63 | * This list contains the connections to communicate with in each frame. |
---|
64 | * |
---|
65 | * As slave, contains only one entry: connection to master. |
---|
66 | * As Master,contains the connection to all slaves which use this connection. |
---|
67 | */ |
---|
68 | std::vector<boost::asio::ip::tcp::iostream> clientlists; |
---|
69 | |
---|
70 | boost::asio::io_service io_service; |
---|
71 | }; |
---|
72 | |
---|
73 | } // END NAMESPACE |
---|