[32] | 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 | |
---|
[69] | 18 | #include <osg/referenced> |
---|
| 19 | #include <osgViewer/Viewer> |
---|
[32] | 20 | |
---|
| 21 | #include "dataIO_slot.h" |
---|
| 22 | |
---|
| 23 | #include "dataIO_transportContainer.h" |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | namespace osgVisual |
---|
| 27 | { |
---|
| 28 | |
---|
| 29 | /** |
---|
| 30 | * \brief This class is the interface definition class for valid cluster implementations. |
---|
| 31 | * |
---|
| 32 | * This class is an abstract class, thus cannot be instantiated. Derive this class for usage. |
---|
| 33 | * |
---|
| 34 | * @author Torben Dannhauer |
---|
| 35 | * @date Feb 2010 |
---|
| 36 | */ |
---|
| 37 | class dataIO_cluster : public osg::Referenced |
---|
| 38 | { |
---|
| 39 | public: |
---|
| 40 | /** |
---|
[59] | 41 | * This enum defines the three modi of the cluster engine. |
---|
| 42 | */ |
---|
| 43 | enum clustermode {MASTER, SLAVE, STANDALONE}; |
---|
| 44 | |
---|
| 45 | /** |
---|
[32] | 46 | * \brief Empty constructor. |
---|
| 47 | * |
---|
| 48 | */ |
---|
| 49 | dataIO_cluster() {} |
---|
| 50 | |
---|
| 51 | /** |
---|
| 52 | * \brief Empty destructor |
---|
| 53 | * |
---|
| 54 | * @return |
---|
| 55 | */ |
---|
| 56 | virtual ~dataIO_cluster() {} |
---|
| 57 | |
---|
| 58 | /** |
---|
| 59 | * \brief Pure virtual function for initialization. Must be implemented in derived class. |
---|
| 60 | * |
---|
| 61 | */ |
---|
[69] | 62 | virtual void init( osg::ArgumentParser& arguments_, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool compressionEnabled_, bool asAscii_ ) = 0; |
---|
[32] | 63 | |
---|
[69] | 64 | void enableHardSync(bool hardSync_){hardSync=hardSync_;}; |
---|
| 65 | |
---|
| 66 | bool isHardSyncEnabled(){return hardSync;}; |
---|
[32] | 67 | |
---|
| 68 | virtual void shutdown() = 0; |
---|
| 69 | |
---|
| 70 | /** |
---|
| 71 | * \brief This function sets the current transportContainer the cluster should send. |
---|
| 72 | * |
---|
| 73 | * The previous container is removed, if set. (smartpointer, will delete itself.). If the cluster is in slave mode, the send_container is ignored. |
---|
| 74 | * |
---|
| 75 | * @param sendContainer_ : New container to set. |
---|
| 76 | */ |
---|
| 77 | void setSendTransportContainer( osgVisual::dataIO_transportContainer* sendContainer_ ) {sendContainer=sendContainer_;} |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | * \brief Pure virtual function for sending TO_OBJ values via cluster to slave. Must be implemented in derived class. |
---|
| 81 | * |
---|
[81] | 82 | * @param viewMatrix_ : Viewmatrix to send to the Slave. |
---|
[32] | 83 | * @return : See derived class. |
---|
| 84 | */ |
---|
[81] | 85 | virtual bool sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_) = 0; |
---|
[32] | 86 | |
---|
| 87 | /** |
---|
| 88 | * \brief Pure virtual function for reading TO_OBJ values from master. Must be implemented in derived class. |
---|
| 89 | * |
---|
| 90 | * @return : See derived class. |
---|
| 91 | */ |
---|
| 92 | virtual bool readTO_OBJvaluesFromMaster() = 0; |
---|
| 93 | |
---|
| 94 | /** |
---|
| 95 | * \brief Pure virtual function for reporting slave as ready to swap. Must be implemented in derived class. |
---|
| 96 | * |
---|
| 97 | */ |
---|
| 98 | virtual void reportAsReadyToSwap() = 0; |
---|
| 99 | |
---|
| 100 | /** |
---|
| 101 | * \brief Pure virtual function for waiting as slave for swap command. Must be implemented in derived class. |
---|
| 102 | * |
---|
| 103 | * @return : See derived class. |
---|
| 104 | */ |
---|
| 105 | virtual bool waitForSwap() = 0; |
---|
| 106 | |
---|
| 107 | /** |
---|
| 108 | * \brief Pure virtual function for waiting as master for all slaves reported as ready to swap. Must be implemented in derived class. |
---|
| 109 | * |
---|
| 110 | * @return : See derived class. |
---|
| 111 | */ |
---|
| 112 | virtual bool waitForAllReadyToSwap() = 0; |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * \brief Pure virtual function for sending swap command to all slaves. Must be implemented in derived class. |
---|
| 116 | * |
---|
| 117 | * @return : See derived class. |
---|
| 118 | */ |
---|
| 119 | virtual bool sendSwapCommand() = 0; |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | protected: |
---|
[69] | 124 | osgVisual::dataIO_cluster::clustermode clusterMode; // This variable only mirrors the variable of dataIO. will be set during initialize. |
---|
[67] | 125 | bool initialized; |
---|
| 126 | int port; |
---|
[69] | 127 | bool hardSync; |
---|
[67] | 128 | |
---|
[69] | 129 | /** |
---|
| 130 | * Referenced Pointer to the applications viewer. |
---|
| 131 | */ |
---|
| 132 | osg::ref_ptr<osgViewer::Viewer> viewer; |
---|
| 133 | |
---|
| 134 | osg::ref_ptr<osgVisual::dataIO_transportContainer> sendContainer; // Points to the send container of dataIO. |
---|
| 135 | std::string receivedTransportContainer; |
---|
[32] | 136 | }; |
---|
| 137 | |
---|
| 138 | } // END NAMESPACE |
---|