1
0
Fork 0

HTTP subsystem has a default name.

Switch to using type-safe accessors now.
This commit is contained in:
James Turner 2016-03-24 15:08:38 +00:00
parent 88bfaca2b3
commit 733e3b3f0c
9 changed files with 15 additions and 13 deletions

View 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();

View 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));
}

View 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());
}

View 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();

View 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>();
}
////////////////////////////////////////////////////////////////////

View 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");

View file

@ -342,6 +342,8 @@ void FGHTTPClient::shutdown()
_packageDelegate.reset();
_http.reset();
_inited = false;
}
void FGHTTPClient::update(double)

View file

@ -46,6 +46,8 @@ public:
std::string getDefaultCatalogId() const;
std::string getDefaultCatalogUrl() const;
static const char* subsystemName() { return "http"; }
private:
class FGDelegate;

View 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");