]> git.mxchange.org Git - simgear.git/commitdiff
Give terrasync a buffered log.
authorJames Turner <zakalawe@mac.com>
Fri, 8 Feb 2013 19:37:47 +0000 (19:37 +0000)
committerJames Turner <zakalawe@mac.com>
Fri, 8 Feb 2013 19:37:47 +0000 (19:37 +0000)
simgear/scene/tsync/terrasync.cxx
simgear/scene/tsync/terrasync.hxx

index 2ddd895f66061d8a7d35051911a6b565644f8f57..d351fa3dde7172c06bedffed805a4fc7150c9318 100644 (file)
@@ -60,6 +60,7 @@
 #include <simgear/misc/strutils.hxx>
 #include <simgear/threads/SGQueue.hxx>
 #include <simgear/misc/sg_dir.hxx>
+#include <simgear/debug/BufferedLogCallback.hxx>
 
 #ifdef HAVE_SVN_CLIENT_H
 #  ifdef HAVE_LIBSVN_CLIENT_1
@@ -683,6 +684,10 @@ SGTerraSync::SGTerraSync(SGPropertyNode_ptr root) :
     _userCbData(NULL)
 {
     _svnThread = new SvnThread();
+    _log = new BufferedLogCallback(SG_TERRAIN, SG_INFO);
+    _log->truncateAt(255);
+    
+    sglog().addCallback(_log);
 }
 
 SGTerraSync::~SGTerraSync()
@@ -690,6 +695,8 @@ SGTerraSync::~SGTerraSync()
     _tiedProperties.Untie();
     delete _svnThread;
     _svnThread = NULL;
+    sglog().removeCallback(_log);
+    delete _log;
 }
 
 void SGTerraSync::init()
index 62ae9511b0c0640c3b3d1fae9365d1c191370a58..cdffd723027560cad4fab3827559563520ff51fe 100644 (file)
@@ -31,6 +31,8 @@ namespace simgear
 {
 const int NOWHERE = -9999;
 
+class BufferedLogCallback;
+
 typedef void (*SGTerraSyncCallback)(void* userData, long tileIndex);
 
 class SGTerraSync : public SGSubsystem
@@ -49,6 +51,10 @@ public:
     bool schedulePosition(int lat, int lon);
     void setTileRefreshCb(SGTerraSyncCallback refreshCb, void* userData = NULL);
 
+    /// retrive the associated log object, for displaying log
+    /// output somewhere (a UI, presumably)
+    BufferedLogCallback* log() const
+        { return _log; }
 protected:
     void syncAirportsModels();
     void syncArea(int lat, int lon);
@@ -67,6 +73,7 @@ private:
     SGTerraSyncCallback _refreshCb;
     void* _userCbData;
     simgear::TiedPropertyList _tiedProperties;
+    BufferedLogCallback* _log;
 };
 
 }