]> git.mxchange.org Git - flightgear.git/commitdiff
HTTP subsystem has a default name.
authorJames Turner <zakalawe@mac.com>
Thu, 24 Mar 2016 15:08:38 +0000 (15:08 +0000)
committerJames Turner <zakalawe@mac.com>
Thu, 24 Mar 2016 15:08:38 +0000 (15:08 +0000)
Switch to using type-safe accessors now.

src/Canvas/FGCanvasSystemAdapter.cxx
src/Environment/realwx_ctrl.cxx
src/GUI/PathsDialog.cxx
src/GUI/QtLauncher.cxx
src/Main/fg_init.cxx
src/MultiPlayer/multiplaymgr.cxx
src/Network/HTTPClient.cxx
src/Network/HTTPClient.hxx
src/Scripting/NasalHTTP.cxx

index c85b0fa28250976e8e16cdccb9e389f9160e3377..e95f86efc33f47cdd6b39e2904c26bdd9d2ec5d2 100644 (file)
@@ -109,8 +109,7 @@ namespace canvas
   //----------------------------------------------------------------------------
   simgear::HTTP::Client* FGCanvasSystemAdapter::getHTTPClient() const
   {
-    FGHTTPClient* http =
-      static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+    FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
 
     if( http )
       return http->client();
index 104d7db5999a37c9b14f7ca5d0643ed6505af1ae..d0141979418680e4c3d21278b41bb2cd256aab5f 100644 (file)
@@ -479,7 +479,7 @@ void NoaaMetarRealWxController::requestMetar
     "NoaaMetarRealWxController::update(): "
     "spawning load request for station-id '" << upperId << "'"
   );
-  FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+  FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
   if (http) {
       http->makeRequest(new NoaaMetarGetRequest(metarDataHandler, upperId));
   }
index c68cc1ecfb6dbf72917c9200e3d9f739a2ad4738..1809c711426a301ac32ad42f1db6baa622399908 100644 (file)
@@ -182,7 +182,7 @@ void PathsDialog::onAddCatalog()
 void PathsDialog::onAddDefaultCatalog()
 {
     // check it's not a duplicate somehow
-    FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+    FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
     if (http->isDefaultCatalogInstalled())
         return;
 
@@ -199,7 +199,7 @@ void PathsDialog::onAddDefaultCatalog()
 void PathsDialog::onRemoveCatalog()
 {
     QModelIndex mi = m_ui->catalogsList->currentIndex();
-    FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+    FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
 
     if (mi.isValid()) {
         QString s = QString("Remove aircraft hangar '%1'? All installed aircraft from this "
@@ -260,6 +260,6 @@ void PathsDialog::updateUi()
     QString m = tr("Download location: %1").arg(s);
     m_ui->downloadLocation->setText(m);
 
-    FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+    FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
     m_ui->addDefaultCatalogButton->setEnabled(!http->isDefaultCatalogInstalled());
 }
index 6357e94b36c3dd3272634a88df5816abc1693010..c95fc907a46e6b2e813950d8e9dc08e976255e0c 100644 (file)
@@ -415,8 +415,8 @@ bool runLauncherDialog()
     fgInitPackageRoot();
 
     // startup the HTTP system now since packages needs it
-    FGHTTPClient* http = new FGHTTPClient;
-    globals->add_subsystem("http", http);
+    FGHTTPClient* http = globals->add_new_subsystem<FGHTTPClient>();
+    
     // we guard against re-init in the global phase; bind and postinit
     // will happen as normal
     http->init();
index 3febb590ce2d98f00e3ba0695b15ccb8dc6b8479..0c47e860b5962d0b53c06caf05d09e9dada1728d 100644 (file)
@@ -738,8 +738,8 @@ void fgCreateSubsystems(bool duringReset) {
     }
 
     // may exist already due to GUI startup
-    if (!globals->get_subsystem("http")) {
-        globals->add_subsystem( "http", new FGHTTPClient );
+    if (!globals->get_subsystem<FGHTTPClient>()) {
+        globals->add_new_subsystem<FGHTTPClient>();
     }
 
     ////////////////////////////////////////////////////////////////////
index 0883bc1bf891b623998db2f02745eb3e13a92c81..4cb5b6b4b4500cac0874af341799f8655f34be58 100644 (file)
@@ -435,7 +435,7 @@ static bool do_multiplayer_refreshserverlist(const SGPropertyNode * arg) {
                return false;
        }
 
-       FGHTTPClient* http = static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+    FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
        if (!http) {
                SG_LOG(SG_IO, SG_ALERT,
                                "do_multiplayer.refreshserverlist: HTTP client not running");
index e6d2b29d7fa9d957a1c7851886b348a308901e57..cf4b490dbf2c676f6b90af233a2d0c6928932df0 100644 (file)
@@ -342,6 +342,8 @@ void FGHTTPClient::shutdown()
 
     _packageDelegate.reset();
     _http.reset();
+
+    _inited = false;
 }
 
 void FGHTTPClient::update(double)
index 3a92ee1ef1a29a23d9cc6ad226257fdd47ab8066..fe239658578dc5de0983f1d89e141d52387062ec 100644 (file)
@@ -46,6 +46,8 @@ public:
 
     std::string getDefaultCatalogId() const;
     std::string getDefaultCatalogUrl() const;
+
+    static const char* subsystemName() { return "http"; } 
 private:
     class FGDelegate;
     
index 637e3a3ac07b2e7588190c5d83306257bafa856f..7556db72115fa78a31ffd62e92228148ef6b18f0 100644 (file)
@@ -39,8 +39,7 @@ typedef nasal::Ghost<simgear::HTTP::MemoryRequestRef> NasalMemoryRequest;
 
 FGHTTPClient& requireHTTPClient(naContext c)
 {
-  FGHTTPClient* http =
-    static_cast<FGHTTPClient*>(globals->get_subsystem("http"));
+  FGHTTPClient* http = globals->get_subsystem<FGHTTPClient>();
   if( !http )
     naRuntimeError(c, "Failed to get HTTP subsystem");