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

Last change on this file since 49 was 32, checked in by Torben Dannhauer, 15 years ago

Adding first version of osgVisual!!

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