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

Last change on this file since 143 was 118, 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
[86]18#include <osg/Notify>
19#include <osg/Referenced>
[32]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
[85]28#ifdef USE_CLUSTER_ENET
29        #include <dataIO_clusterENet.h>
30#endif
[32]31#ifdef USE_CLUSTER_DUMMY
32        #include <dataIO_clusterDummy.h>
33#endif
34
[58]35
[32]36//ExtLink einbinden
37#ifdef USE_EXTLINK_DUMMY
38        #include <dataIO_extLinkDummy.h>
39#endif
40#ifdef USE_EXTLINK_VCL
41        #include <dataIO_extLinkVCL.h>
42#endif
43
44
45// slot and transportContainer definitions
46#include <dataIO_slot.h>
47#include <dataIO_transportContainer.h>
48
49#include <vector>
50
51
52
53
54namespace osgVisual {
55
56/**
57 * \brief Zentrale Klasse für Datenanbindung des Sichtsystemnodes an das Gesamtsichtsystem bzw. dem Simulator.
58 *
59 * Damit nur eine Klasse instantiiert werden kann, ist diese Klasse als Singleton realisiert.
60 *
61 *
62 * @author Torben Dannhauer
63 * @date  Nov 2009
64 */ 
65class visual_dataIO : public osg::Referenced
66{
[88]67        #include <leakDetection.h>
[32]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        class dataIO_finalDrawCallback : public osg::Camera::DrawCallback
91        {
92        public:
93                /**
94                 * \brief Constructor
95                 *
96                 */ 
[96]97                dataIO_finalDrawCallback(visual_dataIO* dataIO_):dataIO(dataIO_){};
[32]98               
99                /**
100                 * \brief Operator executed at callback
101                 *
102                 */ 
103                virtual void operator () (const osg::Camera& camera) const;
104        private:
105                visual_dataIO* dataIO;
106        };
107
108        osg::ref_ptr<dataIO_finalDrawCallback> finalDrawCallback;
109
110        // Make Constructor private to prevent creating instances via ptr* = new ..().
111        visual_dataIO();
112        // Make Copy-Constructor private to prevent getting instances via copying dataIO instance.
113        visual_dataIO(const visual_dataIO& cc);
114
[81]115        osg::Matrixd calcViewMatrix();
[32]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         */ 
[118]129        std::vector<dataIO_slot*> dataSlots;
[32]130
[96]131        friend class dataIO_eventCallback;
132        friend class dataIO_finalDrawCallback;
[32]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// SLOT Access functions
154        void* getSlotPointer(std::string slotName_, osgVisual::dataIO_slot::dataDirection direction_, osgVisual::dataIO_slot::varType variableTyp_ );
155        double getSlotDataAsDouble(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
156        std::string getSlotDataAsString(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ );
[116]157        osgVisual::dataIO_slot* setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, std::string sValue_ );
158        osgVisual::dataIO_slot* setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, double value_ );
[32]159
160        int getSlotNum() {return dataSlots.size();}
161
162        osgVisual::dataIO_cluster::clustermode clusterMode;
163
164        bool initialized;
165};
166
167
168} // END namespace osgVisual
Note: See TracBrowser for help on using the repository browser.