#pragma once /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer * * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or * (at your option) any later version. The full license is in LICENSE file * included with this distribution, and on the openscenegraph.org website. * * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. * You have to aquire licenses for all used proprietary modules. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * OpenSceneGraph Public License for more details. */ #include #include #include #include // Cluster einbinden #ifdef USE_CLUSTER_DUMMY #include #endif #ifdef USE_CLUSTER_UDP #include #endif //ExtLink einbinden #ifdef USE_EXTLINK_DUMMY #include #endif #ifdef USE_EXTLINK_VCL #include #endif // slot and transportContainer definitions #include #include #include namespace osgVisual { /** * \brief Zentrale Klasse für Datenanbindung des Sichtsystemnodes an das Gesamtsichtsystem bzw. dem Simulator. * * Damit nur eine Klasse instantiiert werden kann, ist diese Klasse als Singleton realisiert. * * * @author Torben Dannhauer * @date Nov 2009 */ class visual_dataIO : public osg::Referenced { private: class dataIO_eventCallback : public osg::NodeCallback { public: /** * \brief Constructor, for setting the member variables. * * @param viewer_ : Pointer to the viewer. * @param sceneCamera_ : Pointer to the scene camera. */ dataIO_eventCallback(visual_dataIO* dataIO_):dataIO(dataIO_){}; /** * \brief This function is execute d as callback during update traversal. * */ virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); private: visual_dataIO* dataIO; }; osg::ref_ptr eventCallback; class dataIO_finalDrawCallback : public osg::Camera::DrawCallback { public: /** * \brief Constructor * */ dataIO_finalDrawCallback::dataIO_finalDrawCallback(visual_dataIO* dataIO_):dataIO(dataIO_){}; /** * \brief Operator executed at callback * */ virtual void operator () (const osg::Camera& camera) const; private: visual_dataIO* dataIO; }; osg::ref_ptr finalDrawCallback; // Make Constructor private to prevent creating instances via ptr* = new ..(). visual_dataIO(); // Make Copy-Constructor private to prevent getting instances via copying dataIO instance. visual_dataIO(const visual_dataIO& cc); osg::ref_ptr extLink; osg::ref_ptr cluster; /** * Referenced Pointer to the applications viewer. */ osg::ref_ptr viewer; osg::ref_ptr slotContainer; /** * List of SLOT variables dataIO provides. */ std::vector dataSlots; friend dataIO_eventCallback; friend dataIO_finalDrawCallback; public: // Public destructor to allow singleton cleanup from extern ~visual_dataIO(); /** * \brief This function returns an pointer to the singleton instalce of dataIO. If now instance exist, it will be instantiated silently. * * After instantiation, dataIO still needs to bei initiialized to configure working mode etc! * * @return : Pointer to the instance. */ static visual_dataIO* getInstance(); void init(osgViewer::Viewer* viewer_,osg::ArgumentParser& arguments_); void shutdown(); bool isMaster(){if (clusterMode==osgVisual::dataIO_cluster::MASTER) return true; else return false;}; bool isSlave(){if (clusterMode==osgVisual::dataIO_cluster::SLAVE) return true; else return false;}; bool isStandalone(){if (clusterMode==osgVisual::dataIO_cluster::STANDALONE) return true; else return false;}; // SLOT Access functions void* getSlotPointer(std::string slotName_, osgVisual::dataIO_slot::dataDirection direction_, osgVisual::dataIO_slot::varType variableTyp_ ); double getSlotDataAsDouble(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ ); std::string getSlotDataAsString(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_ ); void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, std::string sValue_ ); void setSlotData(std::string variableName_, osgVisual::dataIO_slot::dataDirection direction_, double value_ ); int getSlotNum() {return dataSlots.size();} osgVisual::dataIO_cluster::clustermode clusterMode; bool initialized; }; } // END namespace osgVisual