Switch to using type-safe accessors now.
//----------------------------------------------------------------------------
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();
"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));
}
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;
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 "
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());
}
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();
}
// 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>();
}
////////////////////////////////////////////////////////////////////
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");
_packageDelegate.reset();
_http.reset();
+
+ _inited = false;
}
void FGHTTPClient::update(double)
std::string getDefaultCatalogId() const;
std::string getDefaultCatalogUrl() const;
+
+ static const char* subsystemName() { return "http"; }
private:
class FGDelegate;
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");