From c22c8b9ae2cb6761c485b30ce98dd5cdf9b86132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 16 Sep 2009 11:40:38 +0000 Subject: [PATCH] Added function to get a unique viewer id git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7092 383ad7c9-94d9-4d36-a494-682f7c89f535 --- BasePlugin/PluginFunctions.cc | 13 +++++++++++++ BasePlugin/PluginFunctions.hh | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/BasePlugin/PluginFunctions.cc b/BasePlugin/PluginFunctions.cc index 9b44aa49..0e9d1387 100644 --- a/BasePlugin/PluginFunctions.cc +++ b/BasePlugin/PluginFunctions.cc @@ -111,6 +111,10 @@ static ViewObjectMarker* defaultMarker_ = 0; */ static QGLWidget* shareGLWidget_ = 0; +/** This is a unique id for the running OpenFlipper instance. Use it to identify yourself on the network +*/ +static int viewerId_ = 0; + void setDataRoot( BaseObject* _root ) { objectRoot_ = _root; } @@ -119,9 +123,18 @@ int viewers( ) { return examiner_widgets_.size(); } +int viewerId() { + return viewerId_; +} + void setViewers( std::vector< glViewer* > _viewerWidgets ) { PluginFunctions::examiner_widgets_ = _viewerWidgets; PluginFunctions::examiner_widget_ = examiner_widgets_[0]; + + // Generate a (hopefully) unique viewer id + QTime time = QTime::currentTime(); + qsrand( time.hour() * 10 + time.minute() * 100 + time.second() * 1000 + time.msec() * 10000 ); + viewerId_ = qrand(); } void setViewerProperties( std::vector< Viewer::ViewerProperties* > _viewerProperties ) { diff --git a/BasePlugin/PluginFunctions.hh b/BasePlugin/PluginFunctions.hh index f3d5c353..16cb78bc 100644 --- a/BasePlugin/PluginFunctions.hh +++ b/BasePlugin/PluginFunctions.hh @@ -556,6 +556,15 @@ BaseObjectData* baseObjectData( BaseObject* _object ); /** @} */ + +/** \brief Return unique viewer id + * + * This function returns a id which is unique to all running Openflippers on that machine. + * This id changes when you restart the viewer! + */ +DLLEXPORT +int viewerId(); + /// Get the root of the object structure DLLEXPORT BaseObject*& objectRoot(); -- GitLab