source: osgVisual/trunk/include/cluster/dataIO_cluster.h @ 251

Last change on this file since 251 was 221, checked in by Torben Dannhauer, 14 years ago

Updated copyright NOTICE
(No code changes)

File size: 5.1 KB
Line 
1#pragma once
2/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 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 <osg/Referenced>
19#include <osgViewer/Viewer>
20
21#include "dataIO_slot.h"
22
23#include "dataIO_transportContainer.h"
24
25// XML Parser
26#include <stdio.h>
27#include <libxml/parser.h>
28#include <libxml/tree.h>
29
30
31namespace 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 */ 
42class dataIO_cluster :  public osg::Referenced
43{
44        #include <leakDetection.h>
45public:
46        /**
47         * This enum defines the three modi of the cluster engine.
48         */ 
49        enum clustermode {MASTER, SLAVE, STANDALONE};
50
51        /**
52         * \brief Empty constructor.
53         *
54         */ 
55        dataIO_cluster():hardSync(false) {}
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         */ 
68        virtual bool init( xmlNode* configurationNode, osgViewer::Viewer* viewer_, clustermode clusterMode_, osgVisual::dataIO_transportContainer* sendContainer_, bool asAscii_) = 0;
69
70        /**
71         * \brief Pure virtual function for XML configuration. Must be implemented in derived class.
72         *
73         */ 
74        virtual bool processXMLConfiguration(xmlNode* clusterConfig_) = 0;
75       
76        /**
77         * \brief Acess function to retrieve whether hardSync is enabled.
78         *
79         * @return : True if hardsync is enabled
80         */ 
81        bool isHardSyncEnabled(){return hardSync;};
82
83        /**
84         * \brief Pure virtual function for shutdown. Must be implemented in derived class.
85         *
86         */ 
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         *
101         * @param viewMatrix_ :  Viewmatrix to send to the Slave.
102         * @return : See derived class.
103         */ 
104        virtual bool sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_) = 0;
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
142protected:
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         */ 
151        bool initialized;
152
153        /**
154         * Port to use for the cluster network traffic
155         */ 
156        int port;
157
158        /**
159         * Flag if hardSync is enabled
160         */ 
161        bool hardSync;
162
163        /**
164         * // Flag if OSGs compression alorithm should be used.
165         */ 
166        bool compressionEnabled; 
167
168        /**
169         * Referenced Pointer to the applications viewer.
170         */ 
171        osg::ref_ptr<osgViewer::Viewer> viewer;
172
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         */ 
181        std::string receivedTransportContainer;
182};
183
184}       // END NAMESPACE
Note: See TracBrowser for help on using the repository browser.