[32] | 1 | #pragma once |
---|
[221] | 2 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer |
---|
[32] | 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 | |
---|
[89] | 18 | #include <osg/Referenced> |
---|
[69] | 19 | #include <osgViewer/Viewer> |
---|
[32] | 20 | |
---|
| 21 | #include "dataIO_slot.h" |
---|
| 22 | |
---|
| 23 | #include "dataIO_transportContainer.h" |
---|
| 24 | |
---|
[183] | 25 | // XML Parser |
---|
| 26 | #include <stdio.h> |
---|
| 27 | #include <libxml/parser.h> |
---|
| 28 | #include <libxml/tree.h> |
---|
[32] | 29 | |
---|
[183] | 30 | |
---|
[32] | 31 | namespace osgVisual |
---|
| 32 | { |
---|
| 33 | |
---|
| 34 | /** |
---|
| 35 | * \brief This class is the interface definition class for valid cluster implementations. |
---|
| 36 | * |
---|
| 37 | * This class is an abstract class, thus cannot be instantiated. Derive this class for usage. |
---|
| 38 | * |
---|
| 39 | * @author Torben Dannhauer |
---|
| 40 | * @date Feb 2010 |
---|
| 41 | */ |
---|
| 42 | class dataIO_cluster : public osg::Referenced |
---|
| 43 | { |
---|
[88] | 44 | #include <leakDetection.h> |
---|
[32] | 45 | public: |
---|
| 46 | /** |
---|
[59] | 47 | * This enum defines the three modi of the cluster engine. |
---|
| 48 | */ |
---|
| 49 | enum clustermode {MASTER, SLAVE, STANDALONE}; |
---|
| 50 | |
---|
| 51 | /** |
---|
[32] | 52 | * \brief Empty constructor. |
---|
| 53 | * |
---|
| 54 | */ |
---|
[183] | 55 | dataIO_cluster():hardSync(false) {} |
---|
[32] | 56 | |
---|
| 57 | /** |
---|
| 58 | * \brief Empty destructor |
---|
| 59 | * |
---|
| 60 | * @return |
---|
| 61 | */ |
---|
| 62 | virtual ~dataIO_cluster() {} |
---|
| 63 | |
---|
| 64 | /** |
---|
| 65 | * \brief Pure virtual function for initialization. Must be implemented in derived class. |
---|
| 66 | * |
---|
| 67 | */ |
---|
[183] | 68 | virtual bool init( xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_) = 0; |
---|
[32] | 69 | |
---|
[185] | 70 | /** |
---|
[186] | 71 | * \brief Pure virtual function for XML configuration. Must be implemented in derived class. |
---|
[185] | 72 | * |
---|
| 73 | */ |
---|
[183] | 74 | virtual bool processXMLConfiguration(xmlNode* clusterConfig_) = 0; |
---|
[69] | 75 | |
---|
[185] | 76 | /** |
---|
| 77 | * \brief Acess function to retrieve whether hardSync is enabled. |
---|
| 78 | * |
---|
| 79 | * @return : True if hardsync is enabled |
---|
| 80 | */ |
---|
[69] | 81 | bool isHardSyncEnabled(){return hardSync;}; |
---|
[32] | 82 | |
---|
[185] | 83 | /** |
---|
[186] | 84 | * \brief Pure virtual function for shutdown. Must be implemented in derived class. |
---|
[185] | 85 | * |
---|
| 86 | */ |
---|
[32] | 87 | virtual void shutdown() = 0; |
---|
| 88 | |
---|
| 89 | /** |
---|
| 90 | * \brief This function sets the current transportContainer the cluster should send. |
---|
| 91 | * |
---|
| 92 | * The previous container is removed, if set. (smartpointer, will delete itself.). If the cluster is in slave mode, the send_container is ignored. |
---|
| 93 | * |
---|
| 94 | * @param sendContainer_ : New container to set. |
---|
| 95 | */ |
---|
| 96 | void setSendTransportContainer( osgVisual::dataIO_transportContainer* sendContainer_ ) {sendContainer=sendContainer_;} |
---|
| 97 | |
---|
| 98 | /** |
---|
| 99 | * \brief Pure virtual function for sending TO_OBJ values via cluster to slave. Must be implemented in derived class. |
---|
| 100 | * |
---|
[81] | 101 | * @param viewMatrix_ : Viewmatrix to send to the Slave. |
---|
[32] | 102 | * @return : See derived class. |
---|
| 103 | */ |
---|
[81] | 104 | virtual bool sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_) = 0; |
---|
[32] | 105 | |
---|
| 106 | /** |
---|
| 107 | * \brief Pure virtual function for reading TO_OBJ values from master. Must be implemented in derived class. |
---|
| 108 | * |
---|
| 109 | * @return : See derived class. |
---|
| 110 | */ |
---|
| 111 | virtual bool readTO_OBJvaluesFromMaster() = 0; |
---|
| 112 | |
---|
| 113 | /** |
---|
| 114 | * \brief Pure virtual function for reporting slave as ready to swap. Must be implemented in derived class. |
---|
| 115 | * |
---|
| 116 | */ |
---|
| 117 | virtual void reportAsReadyToSwap() = 0; |
---|
| 118 | |
---|
| 119 | /** |
---|
| 120 | * \brief Pure virtual function for waiting as slave for swap command. Must be implemented in derived class. |
---|
| 121 | * |
---|
| 122 | * @return : See derived class. |
---|
| 123 | */ |
---|
| 124 | virtual bool waitForSwap() = 0; |
---|
| 125 | |
---|
| 126 | /** |
---|
| 127 | * \brief Pure virtual function for waiting as master for all slaves reported as ready to swap. Must be implemented in derived class. |
---|
| 128 | * |
---|
| 129 | * @return : See derived class. |
---|
| 130 | */ |
---|
| 131 | virtual bool waitForAllReadyToSwap() = 0; |
---|
| 132 | |
---|
| 133 | /** |
---|
| 134 | * \brief Pure virtual function for sending swap command to all slaves. Must be implemented in derived class. |
---|
| 135 | * |
---|
| 136 | * @return : See derived class. |
---|
| 137 | */ |
---|
| 138 | virtual bool sendSwapCommand() = 0; |
---|
| 139 | |
---|
| 140 | |
---|
| 141 | |
---|
| 142 | protected: |
---|
[185] | 143 | /** |
---|
| 144 | * This variable only mirrors the variable of dataIO. will be set during initialize. |
---|
| 145 | */ |
---|
| 146 | osgVisual::dataIO_cluster::clustermode clusterMode; |
---|
| 147 | |
---|
| 148 | /** |
---|
| 149 | * Flag to indicate the cluster's initialization status |
---|
| 150 | */ |
---|
[67] | 151 | bool initialized; |
---|
[185] | 152 | |
---|
| 153 | /** |
---|
| 154 | * Port to use for the cluster network traffic |
---|
| 155 | */ |
---|
[67] | 156 | int port; |
---|
[185] | 157 | |
---|
| 158 | /** |
---|
| 159 | * Flag if hardSync is enabled |
---|
| 160 | */ |
---|
[69] | 161 | bool hardSync; |
---|
[67] | 162 | |
---|
[69] | 163 | /** |
---|
[185] | 164 | * // Flag if OSGs compression alorithm should be used. |
---|
| 165 | */ |
---|
| 166 | bool compressionEnabled; |
---|
| 167 | |
---|
| 168 | /** |
---|
[69] | 169 | * Referenced Pointer to the applications viewer. |
---|
| 170 | */ |
---|
| 171 | osg::ref_ptr<osgViewer::Viewer> viewer; |
---|
| 172 | |
---|
[185] | 173 | /** |
---|
| 174 | * Pointerto the send container of dataIO. |
---|
| 175 | */ |
---|
| 176 | osg::ref_ptr<osgVisual::dataIO_transportContainer> sendContainer; |
---|
| 177 | |
---|
| 178 | /** |
---|
| 179 | * Temporary buffer to store the data into which was recieved via cluster. |
---|
| 180 | */ |
---|
[69] | 181 | std::string receivedTransportContainer; |
---|
[32] | 182 | }; |
---|
| 183 | |
---|
| 184 | } // END NAMESPACE |
---|