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

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