source: osgVisual/include/dataIO/visual_dataIO.h @ 58

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

added support cluster implementation via Boost ASIO TCP iostreams.

Status: Skeleton, ready to implement.

Minor: changed Silverlining default clouds.

File size: 5.1 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/notify>
19#include <osg/referenced>
20#include <osg/ArgumentParser>
21
22#include <osgViewer/Viewer>
23
24// Cluster einbinden
25#ifdef USE_CLUSTER_ASIO_TCP_IOSTREAM
26        #include <dataIO_clusterAsioTcpIostream.h>
27#endif
28#ifdef USE_CLUSTER_DUMMY
29        #include <dataIO_clusterDummy.h>
30#endif
31#ifdef USE_CLUSTER_UDP
32        #include <dataIO_clusterUDP.h>
33#endif
34
35
36
37//ExtLink einbinden
38#ifdef USE_EXTLINK_DUMMY
39        #include <dataIO_extLinkDummy.h>
40#endif
41#ifdef USE_EXTLINK_VCL
42        #include <dataIO_extLinkVCL.h>
43#endif
44
45
46// slot and transportContainer definitions
47#include <dataIO_slot.h>
48#include <dataIO_transportContainer.h>
49
50#include <vector>
51
52
53
54
55namespace osgVisual {
56
57/**
58 * \brief Zentrale Klasse für Datenanbindung des Sichtsystemnodes an das Gesamtsichtsystem bzw. dem Simulator.
59 *
60 * Damit nur eine Klasse instantiiert werden kann, ist diese Klasse als Singleton realisiert.
61 *
62 *
63 * @author Torben Dannhauer
64 * @date  Nov 2009
65 */ 
66class visual_dataIO : public osg::Referenced
67{
68private:
69        class dataIO_eventCallback : public osg::NodeCallback
70        {
71        public: 
72                /**
73                 * \brief Constructor, for setting the member variables.
74                 *
75                 * @param viewer_ : Pointer to the viewer.
76                 * @param sceneCamera_ : Pointer to the scene camera.
77                 */ 
78                dataIO_eventCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
79
80                /**
81                 * \brief This function is execute d as callback during update traversal.
82                 *
83                 */ 
84                virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
85        private:
86                visual_dataIO* dataIO;
87        };
88        osg::ref_ptr<dataIO_eventCallback> eventCallback;
89
90
91        class dataIO_finalDrawCallback : public osg::Camera::DrawCallback
92        {
93        public:
94                /**
95                 * \brief Constructor
96                 *
97                 */ 
98                dataIO_finalDrawCallback::dataIO_finalDrawCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
99               
100                /**
101                 * \brief Operator executed at callback
102                 *
103                 */ 
104                virtual void operator () (const osg::Camera& camera) const;
105        private:
106                visual_dataIO* dataIO;
107        };
108
109        osg::ref_ptr<dataIO_finalDrawCallback> finalDrawCallback;
110
111        // Make Constructor private to prevent creating instances via ptr* = new ..().
112        visual_dataIO();
113        // Make Copy-Constructor private to prevent getting instances via copying dataIO instance.
114        visual_dataIO(const visual_dataIO& cc);
115
116        osg::ref_ptr<dataIO_extLink> extLink;
117        osg::ref_ptr<dataIO_cluster> cluster;
118
119        /**
120         * Referenced Pointer to the applications viewer.
121         */ 
122        osg::ref_ptr<osgViewer::Viewer> viewer;
123
124        osg::ref_ptr<osgVisual::dataIO_transportContainer> slotContainer;
125
126        /**
127         * List of SLOT variables dataIO provides.
128         */ 
129        std::vector<dataIO_slot> dataSlots;
130
131        friend dataIO_eventCallback;
132        friend dataIO_finalDrawCallback;
133
134public:
135        // Public destructor to allow singleton cleanup from extern
136        ~visual_dataIO();
137
138        /**
139         * \brief This function returns an pointer to the singleton instalce of dataIO. If now instance exist, it will be instantiated silently.
140         *
141         * After instantiation, dataIO still needs to bei initiialized to configure working mode etc!
142         *
143         * @return : Pointer to the instance.
144         */ 
145        static visual_dataIO* getInstance();
146
147        void init(osgViewer::Viewer* viewer_,osg::ArgumentParser& arguments_);
148        void shutdown();
149        bool isMaster(){if (clusterMode==osgVisual::dataIO_cluster::MASTER) return true; else return false;};
150        bool isSlave(){if (clusterMode==osgVisual::dataIO_cluster::SLAVE) return true; else return false;};
151        bool isStandalone(){if (clusterMode==osgVisual::dataIO_cluster::STANDALONE) return true; else return false;};
152
153
154// SLOT Access functions
155        void* getSlotPointer(std::string slotName_, osgVisual::dataIO_slot::dataDirection direction_, osgVisual::dataIO_slot::varType variableTyp_ );
156        double getSlotDataAsDouble(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
157        std::string getSlotDataAsString(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
158        void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, std::string sValue_ );
159        void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, double value_ );
160
161        int getSlotNum() {return dataSlots.size();}
162
163        osgVisual::dataIO_cluster::clustermode clusterMode;
164
165        bool initialized;
166};
167
168
169} // END namespace osgVisual
Note: See TracBrowser for help on using the repository browser.