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

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

XML configuration now works also with dataIO cluster

File size: 4.4 KB
Line 
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 <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        virtual bool processXMLConfiguration(xmlNode* clusterConfig_) = 0;
71       
72        bool isHardSyncEnabled(){return hardSync;};
73
74        virtual void shutdown() = 0;
75
76        /**
77         * \brief This function sets the current transportContainer the cluster should send.
78         *
79         * The previous container is removed, if set. (smartpointer, will delete itself.). If the cluster is in slave mode, the send_container is ignored.
80         *
81         * @param sendContainer_ : New container to set.
82         */ 
83        void setSendTransportContainer( osgVisual::dataIO_transportContainer* sendContainer_ ) {sendContainer=sendContainer_;}
84
85        /**
86         * \brief Pure virtual function for sending TO_OBJ values via cluster to slave. Must be implemented in derived class.
87         *
88         * @param viewMatrix_ :  Viewmatrix to send to the Slave.
89         * @return : See derived class.
90         */ 
91        virtual bool sendTO_OBJvaluesToSlaves(osg::Matrixd viewMatrix_) = 0;
92
93        /**
94         * \brief Pure virtual function for reading TO_OBJ values from master. Must be implemented in derived class.
95         *
96         * @return : See derived class.
97         */ 
98        virtual bool readTO_OBJvaluesFromMaster() = 0;
99
100        /**
101         * \brief Pure virtual function for reporting slave as ready to swap. Must be implemented in derived class.
102         *
103         */ 
104        virtual void reportAsReadyToSwap() = 0;
105
106        /**
107         * \brief Pure virtual function for waiting as slave for swap command. Must be implemented in derived class.
108         *
109         * @return : See derived class.
110         */ 
111        virtual bool waitForSwap() = 0;
112
113        /**
114         * \brief Pure virtual function for waiting as master for all slaves reported as ready to swap. Must be implemented in derived class.
115         *
116         * @return : See derived class.
117         */ 
118        virtual bool waitForAllReadyToSwap() = 0;
119
120        /**
121         * \brief Pure virtual function for sending swap command to all slaves. Must be implemented in derived class.
122         *
123         * @return : See derived class.
124         */ 
125        virtual bool sendSwapCommand() = 0;
126
127
128
129protected:
130        osgVisual::dataIO_cluster::clustermode clusterMode;     // This variable only mirrors the variable of dataIO. will be set during initialize.
131        bool initialized;
132        int port;
133        bool hardSync;
134        bool compressionEnabled; // to indicate if OSGs compression alorithm should be used.
135
136        /**
137         * Referenced Pointer to the applications viewer.
138         */ 
139        osg::ref_ptr<osgViewer::Viewer> viewer;
140
141        osg::ref_ptr<osgVisual::dataIO_transportContainer> sendContainer;       // Points to the send container of dataIO.
142        std::string receivedTransportContainer;
143};
144
145}       // END NAMESPACE
Note: See TracBrowser for help on using the repository browser.