From a653d67aaeab7e7ff5f015a38297ad46bdea014f Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 8 Feb 2018 19:22:46 +0100 Subject: [PATCH 1/4] canvas: Event improvements and new events (dragstart, dragend) --- simgear/canvas/CanvasEvent.hxx | 5 +++++ simgear/canvas/CanvasEventManager.cxx | 2 ++ simgear/canvas/CanvasEventTypes.hxx | 2 ++ simgear/canvas/CanvasWindow.cxx | 13 +++++++++++++ simgear/canvas/CanvasWindow.hxx | 2 ++ simgear/canvas/elements/CanvasElement.cxx | 3 +-- simgear/canvas/elements/CanvasImage.hxx | 2 +- simgear/canvas/events/CustomEvent.cxx | 8 ++++++++ simgear/canvas/events/CustomEvent.hxx | 2 ++ simgear/canvas/events/KeyboardEvent.cxx | 8 ++++++++ simgear/canvas/events/KeyboardEvent.hxx | 1 + simgear/canvas/events/MouseEvent.cxx | 8 ++++++++ simgear/canvas/events/MouseEvent.hxx | 1 + 13 files changed, 54 insertions(+), 3 deletions(-) diff --git a/simgear/canvas/CanvasEvent.hxx b/simgear/canvas/CanvasEvent.hxx index 23da1048..fcda8690 100644 --- a/simgear/canvas/CanvasEvent.hxx +++ b/simgear/canvas/CanvasEvent.hxx @@ -65,6 +65,11 @@ namespace canvas // of the actual event instances. virtual ~Event(); + /** + * Clone event and set to the given type (Same type if not specified) + */ + virtual Event* clone(int type = 0) const = 0; + /** * Get whether this events support bubbling */ diff --git a/simgear/canvas/CanvasEventManager.cxx b/simgear/canvas/CanvasEventManager.cxx index 38bc59f9..9d9df35d 100644 --- a/simgear/canvas/CanvasEventManager.cxx +++ b/simgear/canvas/CanvasEventManager.cxx @@ -114,6 +114,8 @@ namespace canvas return handled; } case Event::DRAG: + case Event::DRAG_START: + case Event::DRAG_END: if( !_last_mouse_down.valid() ) return false; else diff --git a/simgear/canvas/CanvasEventTypes.hxx b/simgear/canvas/CanvasEventTypes.hxx index 8e1d9f1e..bbe1fe71 100644 --- a/simgear/canvas/CanvasEventTypes.hxx +++ b/simgear/canvas/CanvasEventTypes.hxx @@ -25,6 +25,8 @@ ENUM_MAPPING(MOUSE_UP, "mouseup", MouseEvent) ENUM_MAPPING(CLICK, "click", MouseEvent) ENUM_MAPPING(DBL_CLICK, "dblclick", MouseEvent) ENUM_MAPPING(DRAG, "drag", MouseEvent) +ENUM_MAPPING(DRAG_START, "dragstart", MouseEvent) +ENUM_MAPPING(DRAG_END, "dragend", MouseEvent) ENUM_MAPPING(WHEEL, "wheel", MouseEvent) ENUM_MAPPING(MOUSE_MOVE, "mousemove", MouseEvent) ENUM_MAPPING(MOUSE_OVER, "mouseover", MouseEvent) diff --git a/simgear/canvas/CanvasWindow.cxx b/simgear/canvas/CanvasWindow.cxx index 0e6b52bd..6ffd40d0 100644 --- a/simgear/canvas/CanvasWindow.cxx +++ b/simgear/canvas/CanvasWindow.cxx @@ -212,6 +212,19 @@ namespace canvas _resize_left = getRegion().l() + offset.x(); } + //---------------------------------------------------------------------------- + bool Window::handleEvent(const EventPtr& event) + { + if( auto mouse_event = dynamic_cast(event.get()) ) + { + mouse_event->local_pos = + mouse_event->client_pos = + mouse_event->screen_pos - toOsg(getPosition()); + } + + return Image::handleEvent(event); + } + //---------------------------------------------------------------------------- void Window::parseDecorationBorder(const std::string& str) { diff --git a/simgear/canvas/CanvasWindow.hxx b/simgear/canvas/CanvasWindow.hxx index 1605164f..c4f569ab 100644 --- a/simgear/canvas/CanvasWindow.hxx +++ b/simgear/canvas/CanvasWindow.hxx @@ -96,6 +96,8 @@ namespace canvas void handleResize( uint8_t mode, const osg::Vec2f& offset = osg::Vec2f() ); + bool handleEvent(const EventPtr& event) override; + protected: enum Attributes diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 7efcd6f0..641fb876 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -271,8 +271,7 @@ namespace canvas //---------------------------------------------------------------------------- void Element::setFocus() { - CanvasPtr canvas = _canvas.lock(); - if( canvas ) + if( auto canvas = _canvas.lock() ) canvas->setFocusElement(this); } diff --git a/simgear/canvas/elements/CanvasImage.hxx b/simgear/canvas/elements/CanvasImage.hxx index 162349b1..8831b184 100644 --- a/simgear/canvas/elements/CanvasImage.hxx +++ b/simgear/canvas/elements/CanvasImage.hxx @@ -93,7 +93,7 @@ namespace canvas const SGRect& getRegion() const; - bool handleEvent(const EventPtr& event); + bool handleEvent(const EventPtr& event) override; /** * diff --git a/simgear/canvas/events/CustomEvent.cxx b/simgear/canvas/events/CustomEvent.cxx index 460c2f11..3aab6413 100644 --- a/simgear/canvas/events/CustomEvent.cxx +++ b/simgear/canvas/events/CustomEvent.cxx @@ -46,6 +46,14 @@ namespace canvas // assert( type_map.find(type_id) != type_map.end() ); } + //---------------------------------------------------------------------------- + CustomEvent* CustomEvent::clone(int type) const + { + auto event = new CustomEvent(*this); + event->type = type; + return event; + } + //---------------------------------------------------------------------------- void CustomEvent::setDetail(StringMap const& data) { diff --git a/simgear/canvas/events/CustomEvent.hxx b/simgear/canvas/events/CustomEvent.hxx index 50f5ff5a..dc139d46 100644 --- a/simgear/canvas/events/CustomEvent.hxx +++ b/simgear/canvas/events/CustomEvent.hxx @@ -58,6 +58,8 @@ namespace canvas bool bubbles = false, StringMap const& data = StringMap() ); + CustomEvent* clone(int type = 0) const override; + /** * Set user data */ diff --git a/simgear/canvas/events/KeyboardEvent.cxx b/simgear/canvas/events/KeyboardEvent.cxx index f5edbb09..2f6147c9 100644 --- a/simgear/canvas/events/KeyboardEvent.cxx +++ b/simgear/canvas/events/KeyboardEvent.cxx @@ -69,6 +69,14 @@ namespace canvas // // TODO what to do with wrong event type? } + //---------------------------------------------------------------------------- + KeyboardEvent* KeyboardEvent::clone(int type) const + { + auto event = new KeyboardEvent(*this); + event->type = type; + return event; + } + //---------------------------------------------------------------------------- void KeyboardEvent::setKey(uint32_t key) { diff --git a/simgear/canvas/events/KeyboardEvent.hxx b/simgear/canvas/events/KeyboardEvent.hxx index 9040437c..2a98ee6c 100644 --- a/simgear/canvas/events/KeyboardEvent.hxx +++ b/simgear/canvas/events/KeyboardEvent.hxx @@ -45,6 +45,7 @@ namespace canvas KeyboardEvent(); KeyboardEvent(const osgGA::GUIEventAdapter& ea); + KeyboardEvent* clone(int type = 0) const override; void setKey(uint32_t key); void setUnmodifiedKey(uint32_t key); diff --git a/simgear/canvas/events/MouseEvent.cxx b/simgear/canvas/events/MouseEvent.cxx index 3feccd28..e513f2da 100644 --- a/simgear/canvas/events/MouseEvent.cxx +++ b/simgear/canvas/events/MouseEvent.cxx @@ -48,6 +48,14 @@ namespace canvas button += 1; } + //---------------------------------------------------------------------------- + MouseEvent* MouseEvent::clone(int type) const + { + auto event = new MouseEvent(*this); + event->type = type; + return event; + } + //---------------------------------------------------------------------------- bool MouseEvent::canBubble() const { diff --git a/simgear/canvas/events/MouseEvent.hxx b/simgear/canvas/events/MouseEvent.hxx index f0a0b4a6..49377dbf 100644 --- a/simgear/canvas/events/MouseEvent.hxx +++ b/simgear/canvas/events/MouseEvent.hxx @@ -36,6 +36,7 @@ namespace canvas public: MouseEvent(); MouseEvent(const osgGA::GUIEventAdapter& ea); + MouseEvent* clone(int type = 0) const override; virtual bool canBubble() const; From cba07157d5589e485fc2376336cc18c93c8cdb40 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 28 Feb 2018 09:52:26 +0000 Subject: [PATCH 2/4] Packages: better version handling & migration Add test coverage for disabling a catalog due to version, and also for auto-migrating to a new version. Expose disabled catalogs on the Root, so they can be checked for. --- simgear/package/Catalog.cxx | 29 ++- simgear/package/Catalog.hxx | 6 + simgear/package/CatalogTest.cxx | 191 +++++++++++++++++++ simgear/package/Root.cxx | 68 ++++--- simgear/package/Root.hxx | 8 +- simgear/package/catalogTest1/catalog-v10.xml | 178 +++++++++++++++++ simgear/package/catalogTest1/catalog-v2.xml | 5 + simgear/package/catalogTest1/catalog-v9.xml | 178 +++++++++++++++++ 8 files changed, 623 insertions(+), 40 deletions(-) create mode 100644 simgear/package/catalogTest1/catalog-v10.xml create mode 100644 simgear/package/catalogTest1/catalog-v9.xml diff --git a/simgear/package/Catalog.cxx b/simgear/package/Catalog.cxx index 1fe5746c..21d25bb5 100644 --- a/simgear/package/Catalog.cxx +++ b/simgear/package/Catalog.cxx @@ -84,7 +84,7 @@ bool checkVersion(const std::string& aVersion, SGPropertyNode_ptr props) std::string redirectUrlForVersion(const std::string& aVersion, SGPropertyNode_ptr props) { - BOOST_FOREACH(SGPropertyNode* v, props->getChildren("alternate-version")) { + for (SGPropertyNode* v : props->getChildren("alternate-version")) { std::string s(v->getStringValue("version")); if (checkVersionString(aVersion, s)) { return v->getStringValue("url");; @@ -139,7 +139,7 @@ protected: std::string ver(m_owner->root()->applicationVersion()); if (!checkVersion(ver, props)) { - SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url() << ", version required " << ver); + SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url() << ", but version required " << ver); // check for a version redirect entry std::string url = redirectUrlForVersion(ver, props); @@ -169,7 +169,13 @@ protected: m_owner->writeTimestamp(); m_owner->refreshComplete(Delegate::STATUS_REFRESHED); } - + + void onFail() override + { + // network level failure + SG_LOG(SG_GENERAL, SG_WARN, "catalog network failure for:" << m_owner->url()); + m_owner->refreshComplete(Delegate::FAIL_DOWNLOAD); + } private: CatalogRef m_owner; @@ -215,7 +221,8 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath) bool versionCheckOk = checkVersion(aRoot->applicationVersion(), props); if (!versionCheckOk) { - SG_LOG(SG_GENERAL, SG_INFO, "catalog at:" << aPath << " failed version check: need" << aRoot->applicationVersion()); + SG_LOG(SG_GENERAL, SG_INFO, "catalog at:" << aPath << " failed version check: need version: " + << aRoot->applicationVersion()); // keep the catalog but mark it as needing an update } else { SG_LOG(SG_GENERAL, SG_DEBUG, "creating catalog from:" << aPath); @@ -540,6 +547,20 @@ Delegate::StatusCode Catalog::status() const return m_status; } +bool Catalog::isEnabled() const +{ + switch (m_status) { + case Delegate::STATUS_SUCCESS: + case Delegate::STATUS_REFRESHED: + case Delegate::STATUS_IN_PROGRESS: + // this is important so we can use Catalog aircraft in offline mode + case Delegate::FAIL_DOWNLOAD: + return true; + default: + return false; + } +} + } // of namespace pkg } // of namespace simgear diff --git a/simgear/package/Catalog.hxx b/simgear/package/Catalog.hxx index 8c6e2efc..513d5b43 100644 --- a/simgear/package/Catalog.hxx +++ b/simgear/package/Catalog.hxx @@ -134,6 +134,12 @@ public: SGPropertyNode* properties() const; Delegate::StatusCode status() const; + + /** + * is this Catalog usable? This may be false if the catalog is currently + * failing a version check or cannot be updated + */ + bool isEnabled() const; typedef boost::function Callback; diff --git a/simgear/package/CatalogTest.cxx b/simgear/package/CatalogTest.cxx index fd90ab86..4e3e8e1b 100644 --- a/simgear/package/CatalogTest.cxx +++ b/simgear/package/CatalogTest.cxx @@ -61,6 +61,7 @@ std::string readFileIntoString(const SGPath& path) SGPath global_serverFilesRoot; unsigned int global_catalogVersion = 0; +bool global_failRequests = false; class TestPackageChannel : public TestServerChannel { @@ -71,6 +72,10 @@ public: state = STATE_IDLE; SGPath localPath(global_serverFilesRoot); + if (global_failRequests) { + closeWhenDone(); + return; + } if (path == "/catalogTest1/catalog.xml") { if (global_catalogVersion > 0) { @@ -540,6 +545,186 @@ void testInstallTarPackage(HTTP::Client* cl) SG_VERIFY(p.exists()); } +void testDisableDueToVersion(HTTP::Client* cl) +{ + global_catalogVersion = 0; + SGPath rootPath(simgear::Dir::current().path()); + rootPath.append("cat_disable_at_version"); + simgear::Dir pd(rootPath); + pd.removeChildren(); + + { + pkg::RootRef root(new pkg::Root(rootPath, "8.1.2")); + root->setHTTPClient(cl); + + pkg::CatalogRef c = pkg::Catalog::createFromUrl(root.ptr(), "http://localhost:2000/catalogTest1/catalog.xml"); + waitForUpdateComplete(cl, root); + SG_VERIFY(c->isEnabled()); + + // install a package + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + pkg::InstallRef ins = p1->install(); + SG_VERIFY(ins->isQueued()); + waitForUpdateComplete(cl, root); + SG_VERIFY(p1->isInstalled()); + } + + // bump version and refresh + { + pkg::RootRef root(new pkg::Root(rootPath, "9.1.2")); + pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1"); + SG_CHECK_EQUAL(root->allCatalogs().size(), 1); + SG_VERIFY(!cat->isEnabled()); + SG_CHECK_EQUAL(root->catalogs().size(), 0); + + root->setHTTPClient(cl); + root->refresh(); + waitForUpdateComplete(cl, root); + SG_CHECK_EQUAL(root->allCatalogs().size(), 1); + + + SG_CHECK_EQUAL(cat->status(), pkg::Delegate::FAIL_VERSION); + SG_VERIFY(!cat->isEnabled()); + SG_CHECK_EQUAL(cat->id(), "org.flightgear.test.catalog1"); + + auto enabledCats = root->catalogs(); + auto it = std::find(enabledCats.begin(), enabledCats.end(), cat); + SG_VERIFY(it == enabledCats.end()); + SG_CHECK_EQUAL(enabledCats.size(), 0); + + auto allCats = root->allCatalogs(); + auto j = std::find(allCats.begin(), allCats.end(), cat); + SG_VERIFY(j != allCats.end()); + + SG_CHECK_EQUAL(allCats.size(), 1); + + // ensure existing package is still installed but not directly list + + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_VERIFY(p1 != pkg::PackageRef()); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + + auto packs = root->allPackages(); + auto k = std::find(packs.begin(), packs.end(), p1); + SG_VERIFY(k == packs.end()); + } +} + +void testVersionMigrate(HTTP::Client* cl) +{ + global_catalogVersion = 2; // version which has migration info + SGPath rootPath(simgear::Dir::current().path()); + rootPath.append("cat_migrate_version"); + simgear::Dir pd(rootPath); + pd.removeChildren(); + + { + pkg::RootRef root(new pkg::Root(rootPath, "8.1.2")); + root->setHTTPClient(cl); + + pkg::CatalogRef c = pkg::Catalog::createFromUrl(root.ptr(), "http://localhost:2000/catalogTest1/catalog.xml"); + waitForUpdateComplete(cl, root); + SG_VERIFY(c->isEnabled()); + + // install a package + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + pkg::InstallRef ins = p1->install(); + SG_VERIFY(ins->isQueued()); + waitForUpdateComplete(cl, root); + SG_VERIFY(p1->isInstalled()); + } + + // bump version and refresh + { + pkg::RootRef root(new pkg::Root(rootPath, "10.1.2")); + root->setHTTPClient(cl); + + // this should cause auto-migration + root->refresh(true); + waitForUpdateComplete(cl, root); + + pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1"); + SG_VERIFY(cat->isEnabled()); + SG_CHECK_EQUAL(cat->status(), pkg::Delegate::STATUS_REFRESHED); + SG_CHECK_EQUAL(cat->id(), "org.flightgear.test.catalog1"); + SG_CHECK_EQUAL(cat->url(), "http://localhost:2000/catalogTest1/catalog-v10.xml"); + + auto enabledCats = root->catalogs(); + auto it = std::find(enabledCats.begin(), enabledCats.end(), cat); + SG_VERIFY(it != enabledCats.end()); + + // ensure existing package is still installed + + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_VERIFY(p1 != pkg::PackageRef()); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + + auto packs = root->allPackages(); + auto k = std::find(packs.begin(), packs.end(), p1); + SG_VERIFY(k != packs.end()); + } +} + +void testOfflineMode(HTTP::Client* cl) +{ + global_catalogVersion = 0; + SGPath rootPath(simgear::Dir::current().path()); + rootPath.append("cat_offline_mode"); + simgear::Dir pd(rootPath); + pd.removeChildren(); + + { + pkg::RootRef root(new pkg::Root(rootPath, "8.1.2")); + root->setHTTPClient(cl); + + pkg::CatalogRef c = pkg::Catalog::createFromUrl(root.ptr(), "http://localhost:2000/catalogTest1/catalog.xml"); + waitForUpdateComplete(cl, root); + SG_VERIFY(c->isEnabled()); + + // install a package + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + pkg::InstallRef ins = p1->install(); + SG_VERIFY(ins->isQueued()); + waitForUpdateComplete(cl, root); + SG_VERIFY(p1->isInstalled()); + } + + global_failRequests = true; + + { + pkg::RootRef root(new pkg::Root(rootPath, "8.1.2")); + SG_CHECK_EQUAL(root->catalogs().size(), 1); + + root->setHTTPClient(cl); + root->refresh(true); + waitForUpdateComplete(cl, root); + SG_CHECK_EQUAL(root->catalogs().size(), 1); + + pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1"); + SG_VERIFY(cat->isEnabled()); + SG_CHECK_EQUAL(cat->status(), pkg::Delegate::FAIL_DOWNLOAD); + SG_CHECK_EQUAL(cat->id(), "org.flightgear.test.catalog1"); + + auto enabledCats = root->catalogs(); + auto it = std::find(enabledCats.begin(), enabledCats.end(), cat); + SG_VERIFY(it != enabledCats.end()); + + // ensure existing package is still installed + pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG"); + SG_VERIFY(p1 != pkg::PackageRef()); + SG_CHECK_EQUAL(p1->id(), "b737-NG"); + + auto packs = root->allPackages(); + auto k = std::find(packs.begin(), packs.end(), p1); + SG_VERIFY(k != packs.end()); + } + + global_failRequests = false; +} + int main(int argc, char* argv[]) { @@ -564,6 +749,12 @@ int main(int argc, char* argv[]) testInstallTarPackage(&cl); + testDisableDueToVersion(&cl); + + testOfflineMode(&cl); + + testVersionMigrate(&cl); + std::cout << "Successfully passed all tests!" << std::endl; return EXIT_SUCCESS; } diff --git a/simgear/package/Root.cxx b/simgear/package/Root.cxx index c8eac52a..e4c895a8 100644 --- a/simgear/package/Root.cxx +++ b/simgear/package/Root.cxx @@ -408,15 +408,11 @@ Root::Root(const SGPath& aPath, const std::string& aVersion) : } for (SGPath c : dir.children(Dir::TYPE_DIR | Dir::NO_DOT_OR_DOTDOT)) { - CatalogRef cat = Catalog::createFromPath(this, c); - if (cat) { - if (cat->status() == Delegate::STATUS_SUCCESS) { - d->catalogs[cat->id()] = cat; - } else { - // catalog has problems, such as needing an update - // keep it out of the main collection for now - d->disabledCatalogs.push_back(cat); - } + // note this will set the catalog status, which will insert into + // disabled catalogs automatically if necesary + auto cat = Catalog::createFromPath(this, c); + if (cat && cat->isEnabled()) { + d->catalogs.insert({cat->id(), cat}); } } // of child directories iteration } @@ -438,9 +434,15 @@ std::string Root::applicationVersion() const CatalogRef Root::getCatalogById(const std::string& aId) const { - CatalogDict::const_iterator it = d->catalogs.find(aId); + auto it = d->catalogs.find(aId); if (it == d->catalogs.end()) { - return NULL; + // check disabled catalog list + auto j = std::find_if(d->disabledCatalogs.begin(), d->disabledCatalogs.end(), + [aId](const CatalogRef& cat) { return cat->id() == aId; }); + if (j != d->disabledCatalogs.end()) { + return *j; + } + return nullptr; } return it->second; @@ -484,6 +486,13 @@ CatalogList Root::catalogs() const return r; } + +CatalogList Root::allCatalogs() const +{ + CatalogList r = catalogs(); + r.insert(r.end(), d->disabledCatalogs.begin(), d->disabledCatalogs.end()); + return r; +} PackageList Root::allPackages() const @@ -544,12 +553,9 @@ void Root::refresh(bool aForce) toRefresh.insert(toRefresh.end(), d->disabledCatalogs.begin(), d->disabledCatalogs.end()); - - - CatalogList::iterator j = toRefresh.begin(); - for (; j != toRefresh.end(); ++j) { - (*j)->refresh(); - didStartAny = true; + for (auto cat : toRefresh) { + cat->refresh(); + didStartAny = true; } if (!didStartAny) { @@ -677,23 +683,20 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason) d->catalogs.insert(catIt, CatalogDict::value_type(aCat->id(), aCat)); // catalog might have been previously disabled, let's remove in that case - CatalogList::iterator j = std::find(d->disabledCatalogs.begin(), - d->disabledCatalogs.end(), - aCat); + auto j = std::find(d->disabledCatalogs.begin(), + d->disabledCatalogs.end(), + aCat); if (j != d->disabledCatalogs.end()) { SG_LOG(SG_GENERAL, SG_INFO, "re-enabling disabled catalog:" << aCat->id()); d->disabledCatalogs.erase(j); } } - if ((aReason != Delegate::STATUS_REFRESHED) && - (aReason != Delegate::STATUS_IN_PROGRESS) && - (aReason != Delegate::STATUS_SUCCESS)) - { + if (!aCat->isEnabled()) { // catalog has errors, disable it - CatalogList::iterator j = std::find(d->disabledCatalogs.begin(), - d->disabledCatalogs.end(), - aCat); + auto j = std::find(d->disabledCatalogs.begin(), + d->disabledCatalogs.end(), + aCat); if (j == d->disabledCatalogs.end()) { SG_LOG(SG_GENERAL, SG_INFO, "disabling catalog:" << aCat->id()); d->disabledCatalogs.push_back(aCat); @@ -703,7 +706,7 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason) if (catIt != d->catalogs.end()) { d->catalogs.erase(catIt); } - } // of catalog has errors case + } // of catalog is disabled if (d->refreshing.empty()) { d->fireRefreshStatus(CatalogRef(), Delegate::STATUS_REFRESHED); @@ -718,13 +721,8 @@ bool Root::removeCatalogById(const std::string& aId) CatalogDict::iterator catIt = d->catalogs.find(aId); if (catIt == d->catalogs.end()) { // check the disabled list - CatalogList::iterator j = d->disabledCatalogs.begin(); - for (; j != d->disabledCatalogs.end(); ++j) { - if ((*j)->id() == aId) { - break; - } - } - + auto j = std::find_if(d->disabledCatalogs.begin(), d->disabledCatalogs.end(), + [aId](const CatalogRef& cat) { return cat->id() == aId; }); if (j == d->disabledCatalogs.end()) { SG_LOG(SG_GENERAL, SG_WARN, "removeCatalogById: no catalog with id:" << aId); return false; diff --git a/simgear/package/Root.hxx b/simgear/package/Root.hxx index 0a16e982..3f461740 100644 --- a/simgear/package/Root.hxx +++ b/simgear/package/Root.hxx @@ -69,7 +69,13 @@ public: std::string getLocale() const; CatalogList catalogs() const; - + + /** + * retrive all catalogs, including currently disabled ones + */ + CatalogList allCatalogs() const; + + void setMaxAgeSeconds(unsigned int seconds); unsigned int maxAgeSeconds() const; diff --git a/simgear/package/catalogTest1/catalog-v10.xml b/simgear/package/catalogTest1/catalog-v10.xml new file mode 100644 index 00000000..c86e8f79 --- /dev/null +++ b/simgear/package/catalogTest1/catalog-v10.xml @@ -0,0 +1,178 @@ + + + + org.flightgear.test.catalog1 + First test catalog + http://localhost:2000/catalogTest1/catalog-v10.xml + 4 + + 10.0.* + 10.1.* + + alpha + Alpha package + 8 + 593 + + a469c4b837f0521db48616cfe65ac1ea + http://localhost:2000/catalogTest1/alpha.zip + + alpha + + + + + c172p + Cessna 172-P + c172p + A plane made by Cessna on Jupiter + 42 + 860 + Standard author + + cessna + ga + piston + ifr + + + 3 + 4 + 5 + 4 + + + + + org.flightgear.test.catalog1.common-sounds + 10 + + + + exterior + thumb-exterior.png + http://foo.bar.com/thumb-exterior.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + thumb-something.png + http://foo.bar.com/thumb-something.png + + + + c172p-2d-panel + C172 with 2d panel only + + + + c172p-floats + C172 with floats + A plane with floats + Floats variant author + + + exterior + thumb-exterior-floats.png + http://foo.bar.com/thumb-exterior-floats.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + http://foo.bar.com/thumb-floats.png + thumb-floats.png + + + + c172p-skis + C172 with skis + A plane with skis + + c172p + + + exterior + thumb-exterior-skis.png + http://foo.bar.com/thumb-exterior-skis.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + + c172r + C172R + Equally good version of the C172 + _package_ + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + + c172r-floats + C172R-floats + Equally good version of the C172 with floats + c172r + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + ec0e2ffdf98d6a5c05c77445e5447ff5 + http://localhost:2000/catalogTest1/c172p.zip + + http://foo.bar.com/thumb-exterior.png + exterior.png + + + + b737-NG + Boeing 737 NG + b737NG + A popular twin-engined narrow body jet + 111 + 860 + + boeing + jet + ifr + + + 5 + 5 + 4 + 4 + + + a94ca5704f305b90767f40617d194ed6 + http://localhost:2000/catalogTest1/b737.tar.gz + + + + common-sounds + Common sound files for test catalog aircraft + 10 + sounds + http://localhost:2000/catalogTest1/common-sounds.zip + 360 + acf9eb89cf396eb42f8823d9cdf17584 + + diff --git a/simgear/package/catalogTest1/catalog-v2.xml b/simgear/package/catalogTest1/catalog-v2.xml index 2c8961ac..75a19c57 100644 --- a/simgear/package/catalogTest1/catalog-v2.xml +++ b/simgear/package/catalogTest1/catalog-v2.xml @@ -10,6 +10,11 @@ 8.0.0 8.2.0 + + 10.*.* + http://localhost:2000/catalogTest1/catalog-v10.xml + + alpha Alpha package diff --git a/simgear/package/catalogTest1/catalog-v9.xml b/simgear/package/catalogTest1/catalog-v9.xml new file mode 100644 index 00000000..2dcd789e --- /dev/null +++ b/simgear/package/catalogTest1/catalog-v9.xml @@ -0,0 +1,178 @@ + + + + org.flightgear.test.catalog1 + First test catalog + http://localhost:2000/catalogTest1/catalog.xml + 4 + + 9.1.* + + + alpha + Alpha package + 8 + 593 + + a469c4b837f0521db48616cfe65ac1ea + http://localhost:2000/catalogTest1/alpha.zip + + alpha + + + + + c172p + Cessna 172-P + c172p + A plane made by Cessna on Jupiter + 42 + 860 + Standard author + + cessna + ga + piston + ifr + + + 3 + 4 + 5 + 4 + + + + + org.flightgear.test.catalog1.common-sounds + 10 + + + + exterior + thumb-exterior.png + http://foo.bar.com/thumb-exterior.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + thumb-something.png + http://foo.bar.com/thumb-something.png + + + + c172p-2d-panel + C172 with 2d panel only + + + + c172p-floats + C172 with floats + A plane with floats + Floats variant author + + + exterior + thumb-exterior-floats.png + http://foo.bar.com/thumb-exterior-floats.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + http://foo.bar.com/thumb-floats.png + thumb-floats.png + + + + c172p-skis + C172 with skis + A plane with skis + + c172p + + + exterior + thumb-exterior-skis.png + http://foo.bar.com/thumb-exterior-skis.png + + + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + + c172r + C172R + Equally good version of the C172 + _package_ + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + + c172r-floats + C172R-floats + Equally good version of the C172 with floats + c172r + + panel + thumb-panel.png + http://foo.bar.com/thumb-panel.png + + + + ec0e2ffdf98d6a5c05c77445e5447ff5 + http://localhost:2000/catalogTest1/c172p.zip + + http://foo.bar.com/thumb-exterior.png + exterior.png + + + + b737-NG + Boeing 737 NG + b737NG + A popular twin-engined narrow body jet + 111 + 860 + + boeing + jet + ifr + + + 5 + 5 + 4 + 4 + + + a94ca5704f305b90767f40617d194ed6 + http://localhost:2000/catalogTest1/b737.tar.gz + + + + common-sounds + Common sound files for test catalog aircraft + 10 + sounds + http://localhost:2000/catalogTest1/common-sounds.zip + 360 + acf9eb89cf396eb42f8823d9cdf17584 + + From 711a4fe0c85b379f137f2e832ab0e706dc4e16cb Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Thu, 1 Mar 2018 09:03:25 +0100 Subject: [PATCH 3/4] canvas::Map: Preserve default values without new values Ensure default values are used (instead of 0) if no values are specified. --- simgear/canvas/elements/CanvasMap.cxx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/simgear/canvas/elements/CanvasMap.cxx b/simgear/canvas/elements/CanvasMap.cxx index 35763198..866954ac 100644 --- a/simgear/canvas/elements/CanvasMap.cxx +++ b/simgear/canvas/elements/CanvasMap.cxx @@ -199,10 +199,18 @@ namespace canvas _projection = std::make_shared(); _projection->setWorldPosition(_node->getDoubleValue(REF_LAT), - _node->getDoubleValue(REF_LON) ); - _projection->setOrientation(_node->getFloatValue(HDG)); - _projection->setScreenRange(_node->getDoubleValue(SCREEN_RANGE)); - _projection->setRange(_node->getDoubleValue(RANGE)); + _node->getDoubleValue(REF_LON)); + + // Only set existing properties to prevent using 0 instead of default values + + if( auto heading = _node->getChild(HDG) ) + _projection->setOrientation(heading->getFloatValue()); + + if( auto screen_range = _node->getChild(SCREEN_RANGE) ) + _projection->setScreenRange(screen_range->getDoubleValue()); + + if( auto range = _node->getChild(RANGE) ) + _projection->setRange(range->getDoubleValue()); _projection_dirty = true; } From 62ae6ca35e34f3663861daae4e020354ab667f56 Mon Sep 17 00:00:00 2001 From: Thomas Geymayer Date: Fri, 2 Mar 2018 09:07:01 +0100 Subject: [PATCH 4/4] Mostly canvas doxygen improvements and C++11 refactoring. --- simgear/canvas/Canvas.cxx | 3 +- simgear/canvas/Canvas.hxx | 20 +++++---- simgear/canvas/CanvasEvent.cxx | 9 +++-- simgear/canvas/CanvasEvent.hxx | 7 ++++ simgear/canvas/CanvasEventManager.cxx | 9 +++-- simgear/canvas/CanvasEventManager.hxx | 3 +- simgear/canvas/CanvasEventTypes.hxx | 3 +- simgear/canvas/CanvasEventVisitor.cxx | 8 ++-- simgear/canvas/CanvasEventVisitor.hxx | 5 ++- simgear/canvas/CanvasMgr.cxx | 6 +-- simgear/canvas/CanvasMgr.hxx | 5 ++- simgear/canvas/CanvasObjectPlacement.cxx | 3 +- simgear/canvas/CanvasObjectPlacement.hxx | 4 +- simgear/canvas/CanvasPlacement.cxx | 3 +- simgear/canvas/CanvasPlacement.hxx | 8 ++-- simgear/canvas/CanvasSystemAdapter.hxx | 7 +++- simgear/canvas/CanvasWindow.cxx | 3 +- simgear/canvas/CanvasWindow.hxx | 3 +- simgear/canvas/ODGauge.cxx | 9 +++-- simgear/canvas/ODGauge.hxx | 9 +++-- simgear/canvas/VGInitOperation.cxx | 3 +- simgear/canvas/VGInitOperation.hxx | 3 +- simgear/canvas/canvas_fwd.hxx | 3 +- simgear/canvas/elements/CanvasElement.cxx | 3 +- simgear/canvas/elements/CanvasElement.hxx | 14 +++---- simgear/canvas/elements/CanvasGroup.cxx | 4 +- simgear/canvas/elements/CanvasGroup.hxx | 22 +++++----- simgear/canvas/elements/CanvasImage.cxx | 3 +- simgear/canvas/elements/CanvasImage.hxx | 9 +++-- simgear/canvas/elements/CanvasMap.cxx | 5 ++- simgear/canvas/elements/CanvasMap.hxx | 17 ++++---- simgear/canvas/elements/CanvasPath.cxx | 20 +++++---- simgear/canvas/elements/CanvasPath.hxx | 12 +++--- simgear/canvas/elements/CanvasText.cxx | 11 ++--- simgear/canvas/elements/CanvasText.hxx | 3 +- simgear/canvas/elements/map/projection.hxx | 3 +- simgear/canvas/events/CustomEvent.cxx | 3 +- simgear/canvas/events/CustomEvent.hxx | 7 +++- simgear/canvas/events/DeviceEvent.cxx | 3 +- simgear/canvas/events/KeyboardEvent.cxx | 3 +- simgear/canvas/events/MouseEvent.cxx | 3 +- simgear/canvas/events/MouseEvent.hxx | 2 +- simgear/canvas/events/input_event_demo.cxx | 3 +- simgear/io/http_repo_sync.cxx | 2 - simgear/misc/strutils.hxx | 47 +++++++++++++--------- simgear/props/PropertyBasedMgr.cxx | 3 +- simgear/props/PropertyBasedMgr.hxx | 17 ++++---- simgear/sound/sample.hxx | 2 +- 48 files changed, 210 insertions(+), 147 deletions(-) diff --git a/simgear/canvas/Canvas.cxx b/simgear/canvas/Canvas.cxx index 9b3ae44c..74ae92b0 100644 --- a/simgear/canvas/Canvas.cxx +++ b/simgear/canvas/Canvas.cxx @@ -1,4 +1,5 @@ -// The canvas for rendering with the 2d API +///@file +/// The canvas for rendering with the 2d API // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/Canvas.hxx b/simgear/canvas/Canvas.hxx index 6e02b247..7e22275c 100644 --- a/simgear/canvas/Canvas.hxx +++ b/simgear/canvas/Canvas.hxx @@ -71,18 +71,18 @@ namespace canvas public osg::NodeCallback { public: - CullCallback(const CanvasWeakPtr& canvas); + explicit CullCallback(const CanvasWeakPtr& canvas); private: CanvasWeakPtr _canvas; - virtual void operator()(osg::Node* node, osg::NodeVisitor* nv); + void operator()(osg::Node* node, osg::NodeVisitor* nv) override; }; typedef osg::ref_ptr CullCallbackPtr; - Canvas(SGPropertyNode* node); + explicit Canvas(SGPropertyNode* node); virtual ~Canvas(); - virtual void onDestroy(); + void onDestroy() override; void setCanvasMgr(CanvasMgr* canvas_mgr); CanvasMgr* getCanvasMgr() const; @@ -184,11 +184,9 @@ namespace canvas bool propagateEvent( EventPtr const& event, EventPropagationPath const& path ); - virtual void childAdded( SGPropertyNode * parent, - SGPropertyNode * child ); - virtual void childRemoved( SGPropertyNode * parent, - SGPropertyNode * child ); - virtual void valueChanged (SGPropertyNode * node); + void childAdded(SGPropertyNode* parent, SGPropertyNode* child) override; + void childRemoved(SGPropertyNode* parent, SGPropertyNode* child) override; + void valueChanged(SGPropertyNode * node) override; osg::Texture2D* getTexture() const; @@ -254,8 +252,8 @@ namespace canvas static SystemAdapterPtr _system_adapter; - Canvas(const Canvas&); // = delete; - Canvas& operator=(const Canvas&); // = delete; + Canvas(const Canvas&) = delete; + Canvas& operator=(const Canvas&) = delete; }; } // namespace canvas diff --git a/simgear/canvas/CanvasEvent.cxx b/simgear/canvas/CanvasEvent.cxx index bf54a90a..2540b907 100644 --- a/simgear/canvas/CanvasEvent.cxx +++ b/simgear/canvas/CanvasEvent.cxx @@ -1,4 +1,5 @@ -// Canvas Event for event model similar to DOM Level 3 Event Model +///@file +/// Canvas Event for event model similar to DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // @@ -125,10 +126,10 @@ namespace canvas //---------------------------------------------------------------------------- std::string Event::typeToStr(int type) { - TypeMap const& type_map = getTypeMap(); + auto const& map_by_id = getTypeMap().by(); - TypeMap::map_by::const_iterator it = type_map.by().find(type); - if( it == type_map.by().end() ) + auto it = map_by_id.find(type); + if( it == map_by_id.end() ) return "unknown"; return it->second; } diff --git a/simgear/canvas/CanvasEvent.hxx b/simgear/canvas/CanvasEvent.hxx index fcda8690..58532e53 100644 --- a/simgear/canvas/CanvasEvent.hxx +++ b/simgear/canvas/CanvasEvent.hxx @@ -115,7 +115,14 @@ namespace canvas */ bool defaultPrevented() const; + /** + * Register a new type string or get the id of an existing type string + * + * @param type Type string + * @return Id of the given @a type + */ static int getOrRegisterType(const std::string& type); + static int strToType(const std::string& type); static std::string typeToStr(int type); diff --git a/simgear/canvas/CanvasEventManager.cxx b/simgear/canvas/CanvasEventManager.cxx index 9d9df35d..0e68bdd9 100644 --- a/simgear/canvas/CanvasEventManager.cxx +++ b/simgear/canvas/CanvasEventManager.cxx @@ -1,4 +1,5 @@ -// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model +///@file +/// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // @@ -17,9 +18,11 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #include + #include "CanvasEventManager.hxx" -#include -#include +#include "elements/CanvasElement.hxx" +#include "events/MouseEvent.hxx" + #include namespace simgear diff --git a/simgear/canvas/CanvasEventManager.hxx b/simgear/canvas/CanvasEventManager.hxx index 5e3738c8..e29d7498 100644 --- a/simgear/canvas/CanvasEventManager.hxx +++ b/simgear/canvas/CanvasEventManager.hxx @@ -1,4 +1,5 @@ -// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model +///@file +/// Manage event handling inside a Canvas similar to the DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/CanvasEventTypes.hxx b/simgear/canvas/CanvasEventTypes.hxx index bbe1fe71..51efea40 100644 --- a/simgear/canvas/CanvasEventTypes.hxx +++ b/simgear/canvas/CanvasEventTypes.hxx @@ -1,4 +1,5 @@ -// Mapping between canvas gui Event types and their names +///@file +/// Mapping between canvas gui Event types and their names // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/CanvasEventVisitor.cxx b/simgear/canvas/CanvasEventVisitor.cxx index eb7cdbf0..738a6b6c 100644 --- a/simgear/canvas/CanvasEventVisitor.cxx +++ b/simgear/canvas/CanvasEventVisitor.cxx @@ -1,5 +1,6 @@ -// Visitor for traversing a canvas element hierarchy similar to the traversal -// of the DOM Level 3 Event Model +///@file +/// Visitor for traversing a canvas element hierarchy similar to the traversal +/// of the DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // @@ -18,9 +19,10 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #include + #include "CanvasEvent.hxx" #include "CanvasEventVisitor.hxx" -#include +#include "elements/CanvasElement.hxx" namespace simgear { diff --git a/simgear/canvas/CanvasEventVisitor.hxx b/simgear/canvas/CanvasEventVisitor.hxx index 84b304a5..ee8ab846 100644 --- a/simgear/canvas/CanvasEventVisitor.hxx +++ b/simgear/canvas/CanvasEventVisitor.hxx @@ -1,5 +1,6 @@ -// Visitor for traversing a canvas element hierarchy similar to the traversal -// of the DOM Level 3 Event Model +///@file +/// Visitor for traversing a canvas element hierarchy similar to the traversal +/// of the DOM Level 3 Event Model // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/CanvasMgr.cxx b/simgear/canvas/CanvasMgr.cxx index 0d2fa1ea..43e70ac3 100644 --- a/simgear/canvas/CanvasMgr.cxx +++ b/simgear/canvas/CanvasMgr.cxx @@ -1,4 +1,5 @@ -// Canvas with 2D rendering API +///@file +/// Canvas with 2D rendering API // // Copyright (C) 2012 Thomas Geymayer // @@ -17,12 +18,11 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #include + #include "CanvasMgr.hxx" #include "Canvas.hxx" #include "CanvasEventManager.hxx" -#include - namespace simgear { namespace canvas diff --git a/simgear/canvas/CanvasMgr.hxx b/simgear/canvas/CanvasMgr.hxx index 51ffa576..3255d4bc 100644 --- a/simgear/canvas/CanvasMgr.hxx +++ b/simgear/canvas/CanvasMgr.hxx @@ -1,4 +1,5 @@ -// Canvas with 2D rendering API +///@file +/// Canvas with 2D rendering API // // Copyright (C) 2012 Thomas Geymayer // @@ -61,7 +62,7 @@ namespace canvas protected: - virtual void elementCreated(PropertyBasedElementPtr element); + void elementCreated(PropertyBasedElementPtr element) override; }; } // namespace canvas diff --git a/simgear/canvas/CanvasObjectPlacement.cxx b/simgear/canvas/CanvasObjectPlacement.cxx index 94b07330..678d7a27 100644 --- a/simgear/canvas/CanvasObjectPlacement.cxx +++ b/simgear/canvas/CanvasObjectPlacement.cxx @@ -1,4 +1,5 @@ -// Canvas placement for placing a canvas texture onto osg objects. +///@file +/// Canvas placement for placing a canvas texture onto osg objects // // It also provides a SGPickCallback for passing mouse events to the canvas and // manages emissive lighting of the placed canvas. diff --git a/simgear/canvas/CanvasObjectPlacement.hxx b/simgear/canvas/CanvasObjectPlacement.hxx index a97aeb6e..4806fffb 100644 --- a/simgear/canvas/CanvasObjectPlacement.hxx +++ b/simgear/canvas/CanvasObjectPlacement.hxx @@ -1,5 +1,5 @@ ///@file -/// Placement for putting a canvas texture onto OpenSceneGraph objects. +/// Placement for putting a canvas texture onto OpenSceneGraph objects /// /// It also provides a SGPickCallback for passing mouse events to the canvas and /// manages emissive lighting of the placed canvas. @@ -60,7 +60,7 @@ namespace canvas */ void setCaptureEvents(bool enable); - virtual bool childChanged(SGPropertyNode* child); + bool childChanged(SGPropertyNode* child) override; protected: typedef SGSharedPtr PickCallbackPtr; diff --git a/simgear/canvas/CanvasPlacement.cxx b/simgear/canvas/CanvasPlacement.cxx index 95a3bdb8..d300926e 100644 --- a/simgear/canvas/CanvasPlacement.cxx +++ b/simgear/canvas/CanvasPlacement.cxx @@ -1,4 +1,5 @@ -// Base class for canvas placements +///@file +/// Base class for canvas placements // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/CanvasPlacement.hxx b/simgear/canvas/CanvasPlacement.hxx index cda36795..c11af97b 100644 --- a/simgear/canvas/CanvasPlacement.hxx +++ b/simgear/canvas/CanvasPlacement.hxx @@ -1,4 +1,5 @@ -// Base class for canvas placements +///@file +/// Base class for canvas placements // // Copyright (C) 2012 Thomas Geymayer // @@ -40,9 +41,8 @@ namespace canvas protected: SGPropertyNode_ptr _node; - private: - Placement(const Placement&) /* = delete */; - Placement& operator=(const Placement&) /* = delete */; + Placement(const Placement&) = delete; + Placement& operator=(const Placement&) = delete; }; } // namespace canvas diff --git a/simgear/canvas/CanvasSystemAdapter.hxx b/simgear/canvas/CanvasSystemAdapter.hxx index 43b3f780..b29e0a13 100644 --- a/simgear/canvas/CanvasSystemAdapter.hxx +++ b/simgear/canvas/CanvasSystemAdapter.hxx @@ -1,4 +1,5 @@ -// Adapter for using the canvas with different applications +///@file +/// Adapter for using the canvas with different applications // // Copyright (C) 2012 Thomas Geymayer // @@ -29,6 +30,10 @@ namespace HTTP { class Client; } namespace canvas { + /** + * Provides access to different required systems of the application to the + * Canvas + */ class SystemAdapter { public: diff --git a/simgear/canvas/CanvasWindow.cxx b/simgear/canvas/CanvasWindow.cxx index 6ffd40d0..526c8787 100644 --- a/simgear/canvas/CanvasWindow.cxx +++ b/simgear/canvas/CanvasWindow.cxx @@ -1,4 +1,5 @@ -// Window for placing a Canvas onto it (for dialogs, menus, etc.) +///@file +/// Window for placing a Canvas onto it (for dialogs, menus, etc.) // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/CanvasWindow.hxx b/simgear/canvas/CanvasWindow.hxx index c4f569ab..db24bb9c 100644 --- a/simgear/canvas/CanvasWindow.hxx +++ b/simgear/canvas/CanvasWindow.hxx @@ -1,4 +1,5 @@ -// Window for placing a Canvas onto it (for dialogs, menus, etc.) +///@file +/// Window for placing a Canvas onto it (for dialogs, menus, etc.) // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/ODGauge.cxx b/simgear/canvas/ODGauge.cxx index 4a2b7fac..f7e95c4d 100644 --- a/simgear/canvas/ODGauge.cxx +++ b/simgear/canvas/ODGauge.cxx @@ -1,4 +1,5 @@ -// Owner Drawn Gauge helper class +///@file +/// Owner Drawn Gauge helper class // // Written by Harald JOHNSEN, started May 2005. // @@ -6,9 +7,9 @@ // // Ported to OSG by Tim Moore - Jun 2007 // -// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April 2012 -// Supports now multisampling/mipmapping, usage of the stencil buffer and placing -// the texture in the scene by certain filter criteria +// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April +// 2012 Supports now multisampling/mipmapping, usage of the stencil buffer and +// placing the texture in the scene by certain filter criteria. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public diff --git a/simgear/canvas/ODGauge.hxx b/simgear/canvas/ODGauge.hxx index 413c9d57..e303c4e3 100644 --- a/simgear/canvas/ODGauge.hxx +++ b/simgear/canvas/ODGauge.hxx @@ -1,4 +1,5 @@ -// Owner Drawn Gauge helper class +///@file +/// Owner Drawn Gauge helper class // // Written by Harald JOHNSEN, started May 2005. // @@ -6,9 +7,9 @@ // // Ported to OSG by Tim Moore - Jun 2007 // -// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April 2012 -// Supports now multisampling/mipmapping, usage of the stencil buffer and placing -// the texture in the scene by certain filter criteria +// Heavily modified to be usable for the 2d Canvas by Thomas Geymayer - April +// 2012 Supports now multisampling/mipmapping, usage of the stencil buffer and +// placing the texture in the scene by certain filter criteria. // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Library General Public diff --git a/simgear/canvas/VGInitOperation.cxx b/simgear/canvas/VGInitOperation.cxx index 4d5d1734..ac5f8af2 100644 --- a/simgear/canvas/VGInitOperation.cxx +++ b/simgear/canvas/VGInitOperation.cxx @@ -1,4 +1,5 @@ -// osg::Operation to initialize the OpenVG context used for path rendering +///@file +/// osg::Operation to initialize the OpenVG context used for path rendering // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/VGInitOperation.hxx b/simgear/canvas/VGInitOperation.hxx index 3b9c6436..f21a25f9 100644 --- a/simgear/canvas/VGInitOperation.hxx +++ b/simgear/canvas/VGInitOperation.hxx @@ -1,4 +1,5 @@ -// osg::Operation to initialize the OpenVG context used for path rendering +///@file +/// osg::Operation to initialize the OpenVG context used for path rendering // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/canvas_fwd.hxx b/simgear/canvas/canvas_fwd.hxx index 3b1b4646..640c2ffa 100644 --- a/simgear/canvas/canvas_fwd.hxx +++ b/simgear/canvas/canvas_fwd.hxx @@ -1,4 +1,5 @@ -// Canvas forward declarations +///@file +/// Canvas forward declarations // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/elements/CanvasElement.cxx b/simgear/canvas/elements/CanvasElement.cxx index 641fb876..7b564737 100644 --- a/simgear/canvas/elements/CanvasElement.cxx +++ b/simgear/canvas/elements/CanvasElement.cxx @@ -1,4 +1,5 @@ -// Interface for 2D Canvas element +///@file +/// Interface for 2D Canvas element // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/elements/CanvasElement.hxx b/simgear/canvas/elements/CanvasElement.hxx index fe22aa3c..c993b5d0 100644 --- a/simgear/canvas/elements/CanvasElement.hxx +++ b/simgear/canvas/elements/CanvasElement.hxx @@ -95,7 +95,7 @@ namespace canvas * */ virtual ~Element() = 0; - virtual void onDestroy(); + void onDestroy() override; ElementPtr getParent() const; CanvasWeakPtr getCanvas() const; @@ -105,7 +105,7 @@ namespace canvas * * @param dt Frame time in seconds */ - virtual void update(double dt); + void update(double dt) override; bool addEventListener(const std::string& type, const EventListener& cb); virtual void clearEventListener(); @@ -154,11 +154,9 @@ namespace canvas */ osg::Vec2f posToLocal(const osg::Vec2f& pos) const; - virtual void childAdded( SGPropertyNode * parent, - SGPropertyNode * child ); - virtual void childRemoved( SGPropertyNode * parent, - SGPropertyNode * child ); - virtual void valueChanged(SGPropertyNode * child); + void childAdded(SGPropertyNode* parent, SGPropertyNode* child) override; + void childRemoved(SGPropertyNode* parent, SGPropertyNode* child) override; + void valueChanged(SGPropertyNode* child) override; virtual bool setStyle( const SGPropertyNode* child, const StyleInfo* style_info = 0 ); @@ -597,7 +595,7 @@ namespace canvas osg::ref_ptr _drawable; - Element(const Element&);// = delete + Element(const Element&) = delete; template static Derived& derived_cast(Element& el) diff --git a/simgear/canvas/elements/CanvasGroup.cxx b/simgear/canvas/elements/CanvasGroup.cxx index 02696cde..6755f6d5 100644 --- a/simgear/canvas/elements/CanvasGroup.cxx +++ b/simgear/canvas/elements/CanvasGroup.cxx @@ -1,4 +1,5 @@ -// A group of 2D Canvas elements +///@file +/// A group of 2D Canvas elements // // Copyright (C) 2012 Thomas Geymayer // @@ -168,6 +169,7 @@ namespace canvas if( !_scene_group.valid() ) return warnSceneGroupExpired("clearEventListener"); + // TODO should this be recursive? for(size_t i = 0; i < _scene_group->getNumChildren(); ++i) getChildByIndex(i)->clearEventListener(); } diff --git a/simgear/canvas/elements/CanvasGroup.hxx b/simgear/canvas/elements/CanvasGroup.hxx index 2352aab4..33687637 100644 --- a/simgear/canvas/elements/CanvasGroup.hxx +++ b/simgear/canvas/elements/CanvasGroup.hxx @@ -1,4 +1,5 @@ -// A group of 2D Canvas elements +///@file +/// A group of 2D Canvas elements // // Copyright (C) 2012 Thomas Geymayer // @@ -86,14 +87,15 @@ namespace canvas */ ElementPtr getElementById(const std::string& id); - virtual void clearEventListener(); + void clearEventListener() override; - virtual bool traverse(EventVisitor& visitor); + bool traverse(EventVisitor& visitor) override; - virtual bool setStyle( const SGPropertyNode* child, - const StyleInfo* style_info = 0 ); + bool setStyle( const SGPropertyNode* child, + const StyleInfo* style_info = 0 ) override; - virtual osg::BoundingBox getTransformedBounds(const osg::Matrix& m) const; + osg::BoundingBox + getTransformedBounds(const osg::Matrix& m) const override; protected: @@ -105,11 +107,11 @@ namespace canvas */ virtual ElementFactory getChildFactory(const std::string& type) const; - virtual void updateImpl(double dt); + void updateImpl(double dt) override; - virtual void childAdded(SGPropertyNode * child); - virtual void childRemoved(SGPropertyNode * child); - virtual void childChanged(SGPropertyNode * child); + void childAdded(SGPropertyNode * child) override; + void childRemoved(SGPropertyNode * child) override; + void childChanged(SGPropertyNode * child) override; void handleZIndexChanged(ElementPtr child, int z_index = 0); diff --git a/simgear/canvas/elements/CanvasImage.cxx b/simgear/canvas/elements/CanvasImage.cxx index 4c3aaec9..fbd2cf9f 100644 --- a/simgear/canvas/elements/CanvasImage.cxx +++ b/simgear/canvas/elements/CanvasImage.cxx @@ -1,4 +1,5 @@ -// An image on the Canvas +///@file +/// An image on the Canvas // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/elements/CanvasImage.hxx b/simgear/canvas/elements/CanvasImage.hxx index 8831b184..9641c489 100644 --- a/simgear/canvas/elements/CanvasImage.hxx +++ b/simgear/canvas/elements/CanvasImage.hxx @@ -1,4 +1,5 @@ -// An image on the Canvas +///@file +/// An image on the Canvas // // Copyright (C) 2012 Thomas Geymayer // @@ -53,7 +54,7 @@ namespace canvas ElementWeakPtr parent = 0 ); virtual ~Image(); - virtual void valueChanged(SGPropertyNode* child); + void valueChanged(SGPropertyNode* child) override; void setSrcCanvas(CanvasPtr canvas); CanvasWeakPtr getSrcCanvas() const; @@ -108,9 +109,9 @@ namespace canvas SRC_CANVAS = DEST_SIZE << 1 }; - virtual void updateImpl(double dt); + void updateImpl(double dt) override; - virtual void childChanged(SGPropertyNode * child); + void childChanged(SGPropertyNode * child) override; void setupDefaultDimensions(); SGRect getTextureDimensions() const; diff --git a/simgear/canvas/elements/CanvasMap.cxx b/simgear/canvas/elements/CanvasMap.cxx index 866954ac..a7c43a51 100644 --- a/simgear/canvas/elements/CanvasMap.cxx +++ b/simgear/canvas/elements/CanvasMap.cxx @@ -1,5 +1,6 @@ -// A group of 2D Canvas elements which get automatically transformed according -// to the map parameters. +///@file +/// A group of 2D Canvas elements which get automatically transformed according +/// to the map parameters. // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/elements/CanvasMap.hxx b/simgear/canvas/elements/CanvasMap.hxx index ca0521f0..e2959bcf 100644 --- a/simgear/canvas/elements/CanvasMap.hxx +++ b/simgear/canvas/elements/CanvasMap.hxx @@ -1,5 +1,6 @@ -// A group of 2D Canvas elements which get automatically transformed according -// to the map parameters. +///@file +/// A group of 2D Canvas elements which get automatically transformed according +/// to the map parameters. // // Copyright (C) 2012 Thomas Geymayer // @@ -46,16 +47,14 @@ namespace canvas virtual ~Map(); protected: - virtual void updateImpl(double dt); + void updateImpl(double dt) override; void updateProjection(SGPropertyNode* type_node); - virtual void childAdded( SGPropertyNode* parent, - SGPropertyNode* child ); - virtual void childRemoved( SGPropertyNode* parent, - SGPropertyNode* child ); - virtual void valueChanged(SGPropertyNode* child); - virtual void childChanged(SGPropertyNode* child); + void childAdded(SGPropertyNode* parent, SGPropertyNode* child) override; + void childRemoved(SGPropertyNode* parent, SGPropertyNode* child) override; + void valueChanged(SGPropertyNode* child) override; + void childChanged(SGPropertyNode* child) override; using GeoNodes = std::unordered_map>; diff --git a/simgear/canvas/elements/CanvasPath.cxx b/simgear/canvas/elements/CanvasPath.cxx index 7d11a426..c23f1e49 100644 --- a/simgear/canvas/elements/CanvasPath.cxx +++ b/simgear/canvas/elements/CanvasPath.cxx @@ -1,4 +1,5 @@ -// An OpenVG path on the Canvas +///@file +/// An OpenVG path on the Canvas // // Copyright (C) 2012 Thomas Geymayer // @@ -230,9 +231,12 @@ namespace canvas vgDestroyPaint(_paint_fill); } - virtual const char* className() const { return "PathDrawable"; } - virtual osg::Object* cloneType() const { return new PathDrawable(_path_element); } - virtual osg::Object* clone(const osg::CopyOp&) const { return new PathDrawable(_path_element); } + const char* className() const override + { return "PathDrawable"; } + osg::Object* cloneType() const override + { return new PathDrawable(_path_element); } + osg::Object* clone(const osg::CopyOp&) const override + { return new PathDrawable(_path_element); } /** * Replace the current path segments with the new ones @@ -383,7 +387,7 @@ namespace canvas /** * Draw callback */ - virtual void drawImplementation(osg::RenderInfo& renderInfo) const + void drawImplementation(osg::RenderInfo& renderInfo) const override { if( _attributes_dirty & PATH ) return; @@ -555,13 +559,13 @@ namespace canvas /** * Compute the bounding box */ - virtual osg::BoundingBox + osg::BoundingBox #if OSG_VERSION_LESS_THAN(3,3,2) computeBound() #else computeBoundingBox() #endif - const + const override { if( _path == VG_INVALID_HANDLE || (_attributes_dirty & PATH) ) return osg::BoundingBox(); @@ -667,7 +671,7 @@ namespace canvas struct PathUpdateCallback: public osg::Drawable::UpdateCallback { - virtual void update(osg::NodeVisitor*, osg::Drawable* drawable) + void update(osg::NodeVisitor*, osg::Drawable* drawable) override { static_cast(drawable)->update(); } diff --git a/simgear/canvas/elements/CanvasPath.hxx b/simgear/canvas/elements/CanvasPath.hxx index c6edf30e..125c81cd 100644 --- a/simgear/canvas/elements/CanvasPath.hxx +++ b/simgear/canvas/elements/CanvasPath.hxx @@ -1,4 +1,5 @@ -// An OpenVG path on the Canvas +///@file +/// An OpenVG path on the Canvas // // Copyright (C) 2012 Thomas Geymayer // @@ -40,7 +41,8 @@ namespace canvas ElementWeakPtr parent = 0 ); virtual ~Path(); - virtual osg::BoundingBox getTransformedBounds(const osg::Matrix& m) const; + osg::BoundingBox + getTransformedBounds(const osg::Matrix& m) const override; /** Add a segment with the given command and coordinates */ Path& addSegment(uint8_t cmd, std::initializer_list coords = {}); @@ -86,10 +88,10 @@ namespace canvas bool _hasRect : 1; SGRectf _rect; - virtual void updateImpl(double dt); + void updateImpl(double dt) override; - virtual void childRemoved(SGPropertyNode * child); - virtual void childChanged(SGPropertyNode * child); + void childRemoved(SGPropertyNode * child) override; + void childChanged(SGPropertyNode * child) override; void parseRectToVGPath(); }; diff --git a/simgear/canvas/elements/CanvasText.cxx b/simgear/canvas/elements/CanvasText.cxx index 1ac81e5d..ab226be3 100644 --- a/simgear/canvas/elements/CanvasText.cxx +++ b/simgear/canvas/elements/CanvasText.cxx @@ -1,4 +1,5 @@ -// A text on the Canvas +///@file +/// A text on the Canvas // // Copyright (C) 2012 Thomas Geymayer // @@ -17,6 +18,7 @@ // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA #include + #include "CanvasText.hxx" #include #include @@ -56,21 +58,20 @@ namespace canvas SGVec2i sizeForWidth(int w) const; - virtual osg::BoundingBox + osg::BoundingBox #if OSG_VERSION_LESS_THAN(3,3,2) computeBound() #else computeBoundingBox() #endif - const; + const override; protected: - friend class TextLine; canvas::Text *_text_element; - virtual void computePositions(unsigned int contextID) const; + void computePositions(unsigned int contextID) const override; }; class TextLine diff --git a/simgear/canvas/elements/CanvasText.hxx b/simgear/canvas/elements/CanvasText.hxx index a04ba4e5..9abb5105 100644 --- a/simgear/canvas/elements/CanvasText.hxx +++ b/simgear/canvas/elements/CanvasText.hxx @@ -1,4 +1,5 @@ -// A text on the Canvas +///@file +/// A text on the Canvas // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/elements/map/projection.hxx b/simgear/canvas/elements/map/projection.hxx index e58b9f94..9f9434da 100644 --- a/simgear/canvas/elements/map/projection.hxx +++ b/simgear/canvas/elements/map/projection.hxx @@ -1,4 +1,5 @@ -// Geographic projections for Canvas map element +///@file +/// Geographic projections for Canvas map element // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/canvas/events/CustomEvent.cxx b/simgear/canvas/events/CustomEvent.cxx index 3aab6413..8c289ab1 100644 --- a/simgear/canvas/events/CustomEvent.cxx +++ b/simgear/canvas/events/CustomEvent.cxx @@ -1,4 +1,5 @@ -// Canvas user defined event +///@file +/// Canvas user defined event // // Copyright (C) 2014 Thomas Geymayer // diff --git a/simgear/canvas/events/CustomEvent.hxx b/simgear/canvas/events/CustomEvent.hxx index dc139d46..465f028c 100644 --- a/simgear/canvas/events/CustomEvent.hxx +++ b/simgear/canvas/events/CustomEvent.hxx @@ -38,6 +38,7 @@ namespace canvas public: /** + * @brief Construct a user defined event from a type string * * @param type_str Event type name (if name does not exist yet it will * be registered as new event type) @@ -49,6 +50,10 @@ namespace canvas StringMap const& data = StringMap() ); /** + * @brief Construct a user defined event from a (previously registered) + * type id + * + * @see getOrRegisterType() * * @param type_id Event type id * @param bubbles If this event should take part in the bubbling phase @@ -76,7 +81,7 @@ namespace canvas * @see #bubbles * @see CustomEvent() */ - virtual bool canBubble() const { return bubbles; } + bool canBubble() const override { return bubbles; } StringMap detail; //!< User data map bool bubbles; //!< Whether the event supports bubbling diff --git a/simgear/canvas/events/DeviceEvent.cxx b/simgear/canvas/events/DeviceEvent.cxx index 27075bb6..b45348f7 100644 --- a/simgear/canvas/events/DeviceEvent.cxx +++ b/simgear/canvas/events/DeviceEvent.cxx @@ -1,4 +1,5 @@ -// Input device event +///@file +/// Input device event // // Copyright (C) 2014 Thomas Geymayer // diff --git a/simgear/canvas/events/KeyboardEvent.cxx b/simgear/canvas/events/KeyboardEvent.cxx index 2f6147c9..3a74de52 100644 --- a/simgear/canvas/events/KeyboardEvent.cxx +++ b/simgear/canvas/events/KeyboardEvent.cxx @@ -1,4 +1,5 @@ -// Keyboard event +///@file +/// Keyboard event // // Copyright (C) 2014 Thomas Geymayer // diff --git a/simgear/canvas/events/MouseEvent.cxx b/simgear/canvas/events/MouseEvent.cxx index e513f2da..5952d86c 100644 --- a/simgear/canvas/events/MouseEvent.cxx +++ b/simgear/canvas/events/MouseEvent.cxx @@ -1,4 +1,5 @@ -// Mouse event +///@file +/// Mouse event // // Copyright (C) 2014 Thomas Geymayer // diff --git a/simgear/canvas/events/MouseEvent.hxx b/simgear/canvas/events/MouseEvent.hxx index 49377dbf..e5d0e1b0 100644 --- a/simgear/canvas/events/MouseEvent.hxx +++ b/simgear/canvas/events/MouseEvent.hxx @@ -38,7 +38,7 @@ namespace canvas MouseEvent(const osgGA::GUIEventAdapter& ea); MouseEvent* clone(int type = 0) const override; - virtual bool canBubble() const; + bool canBubble() const override; osg::Vec2f getScreenPos() const { return screen_pos; } osg::Vec2f getClientPos() const { return client_pos; } diff --git a/simgear/canvas/events/input_event_demo.cxx b/simgear/canvas/events/input_event_demo.cxx index 27e172b9..69a549c2 100644 --- a/simgear/canvas/events/input_event_demo.cxx +++ b/simgear/canvas/events/input_event_demo.cxx @@ -1,4 +1,5 @@ -// Keyboard event demo. Press some keys and get some info... +///@file +/// Keyboard event demo. Press some keys and get some info... // // Copyright (C) 2014 Thomas Geymayer // diff --git a/simgear/io/http_repo_sync.cxx b/simgear/io/http_repo_sync.cxx index 47f0db99..4d46c3c2 100644 --- a/simgear/io/http_repo_sync.cxx +++ b/simgear/io/http_repo_sync.cxx @@ -5,8 +5,6 @@ #include #include -#include - #include #include diff --git a/simgear/misc/strutils.hxx b/simgear/misc/strutils.hxx index b6126cd5..ec464a5e 100644 --- a/simgear/misc/strutils.hxx +++ b/simgear/misc/strutils.hxx @@ -72,10 +72,10 @@ namespace simgear { std::string strip( const std::string& s ); /** - * Return a new string with any trailing \r and \n characters removed. + * Return a new string with any trailing \\r and \\n characters removed. * Typically useful to clean a CR-terminated line obtained from - * std::getline() which, upon reading CRLF (\r\n), discards the Line - * Feed character (\n) but leaves the Carriage Return (\r) in the + * std::getline() which, upon reading CRLF (\\r\\n), discards the Line + * Feed character (\\n) but leaves the Carriage Return (\\r) in the * string. * @param s Input string * @return The cleaned string @@ -83,7 +83,7 @@ namespace simgear { std::string stripTrailingNewlines(const std::string& s); /** - * Strip any trailing \r and \n characters from a string. + * Strip any trailing \\r and \\n characters from a string. * Should have slightly less overhead than stripTrailingNewlines(). * @param s Input string (modified in-place) */ @@ -112,11 +112,12 @@ namespace simgear { * Produces a result similar to the perl and python functions of the * same name. * - * @param s The string to split into words, - * @param sep Word delimiters. If not specified then any whitespace is a separator, - * @param maxsplit If given, splits at no more than maxsplit places, - * resulting in at most maxsplit+1 words. - * @return Array of words. + * @param s The string to split into words + * @param sep Word delimiters. If not specified then any whitespace is + * a separator + * @param maxsplit If given, splits at no more than maxsplit places, + * resulting in at most maxsplit+1 words + * @return Array of words */ string_list split( const std::string& s, @@ -124,11 +125,11 @@ namespace simgear { int maxsplit = 0 ); /** - * split a string on any of several characters. Commonly used to deal + * Split a string on any of several characters. Commonly used to deal * with strings containing whitespace, newlines. To parse CSS style - * string, use with '\n\t ,' as the seperator list. + * string, use with '\\n\\t ,' as the separator list. * - * Note consecutive seperators will not produce empty entries in the + * @note Consecutive separators will not produce empty entries in the * the result, i.e splitting 'a,b,,c,d' with a ',' will produce a result * with four entries, not five. */ @@ -226,14 +227,22 @@ namespace simgear { bool to_bool(const std::string& s); /** - * Like strcmp(), but for dotted versions strings NN.NN.NN - * any number of terms are supported. - * @return 0 if versions match, -ve number if v1 is lower, +ve if v1 - * is greater - * @param maxComponents is the maximum number of components to look at. - * This can be used to ignore (say) the patch level by setting it to 2 + * Compare dotted versions strings NN.NN.NN (analogous to strcmp()) + * + * @note Any number of terms are supported. + * + * @param v1 First version + * @param v2 Second version + * @param maxComponents The maximum number of components to look at. This + * can be used to ignore (say) the patch level by + * setting it to 2 + * @return 0 if versions match, + * -ve number if @a v1 is lower, + * +ve if @a v1 is greater */ - int compare_versions(const std::string& v1, const std::string& v2, int maxComponents = 0); + int compare_versions( const std::string& v1, + const std::string& v2, + int maxComponents = 0 ); /** * Convert a string to upper case. diff --git a/simgear/props/PropertyBasedMgr.cxx b/simgear/props/PropertyBasedMgr.cxx index 91217fd5..a279219a 100644 --- a/simgear/props/PropertyBasedMgr.cxx +++ b/simgear/props/PropertyBasedMgr.cxx @@ -1,4 +1,5 @@ -// Base class for property controlled subsystems +///@file +/// Base class for property controlled subsystems // // Copyright (C) 2012 Thomas Geymayer // diff --git a/simgear/props/PropertyBasedMgr.hxx b/simgear/props/PropertyBasedMgr.hxx index 15205038..9a14dab5 100644 --- a/simgear/props/PropertyBasedMgr.hxx +++ b/simgear/props/PropertyBasedMgr.hxx @@ -1,4 +1,5 @@ -// Base class for property controlled subsystems +///@file +/// Base class for property controlled subsystems // // Copyright (C) 2012 Thomas Geymayer // @@ -33,10 +34,10 @@ namespace simgear public SGPropertyChangeListener { public: - virtual void init(); - virtual void shutdown(); + void init() override; + void shutdown() override; - virtual void update (double delta_time_sec); + void update (double delta_time_sec) override; /** * Create a new PropertyBasedElement @@ -88,10 +89,10 @@ namespace simgear ElementFactory element_factory ); virtual ~PropertyBasedMgr() = 0; - virtual void childAdded( SGPropertyNode * parent, - SGPropertyNode * child ); - virtual void childRemoved( SGPropertyNode * parent, - SGPropertyNode * child ); + void childAdded( SGPropertyNode * parent, + SGPropertyNode * child ) override; + void childRemoved( SGPropertyNode * parent, + SGPropertyNode * child ) override; virtual void elementCreated(PropertyBasedElementPtr element) {} diff --git a/simgear/sound/sample.hxx b/simgear/sound/sample.hxx index 4134e9d3..4329a273 100644 --- a/simgear/sound/sample.hxx +++ b/simgear/sound/sample.hxx @@ -23,7 +23,7 @@ // $Id$ /** - * \file audio sample.hxx + * \file * Provides a audio sample encapsulation */