diff --git a/simgear/debug/BufferedLogCallback.cxx b/simgear/debug/BufferedLogCallback.cxx index 12b9065c..21c8e972 100644 --- a/simgear/debug/BufferedLogCallback.cxx +++ b/simgear/debug/BufferedLogCallback.cxx @@ -18,18 +18,17 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // - + #include #include - -#include - + #include #include #include // for malloc +#include #include - + namespace simgear { @@ -41,7 +40,7 @@ public: unsigned int m_stamp; unsigned int m_maxLength; }; - + BufferedLogCallback::BufferedLogCallback(sgDebugClass c, sgDebugPriority p) : simgear::LogCallback(c,p), d(new BufferedLogCallbackPrivate) @@ -52,19 +51,19 @@ BufferedLogCallback::BufferedLogCallback(sgDebugClass c, sgDebugPriority p) : BufferedLogCallback::~BufferedLogCallback() { - BOOST_FOREACH(unsigned char* msg, d->m_buffer) { + for (auto msg : d->m_buffer) { free(msg); } } - -void BufferedLogCallback::operator()(sgDebugClass c, sgDebugPriority p, + +void BufferedLogCallback::operator()(sgDebugClass c, sgDebugPriority p, const char* file, int line, const std::string& aMessage) { SG_UNUSED(file); SG_UNUSED(line); - + if (!shouldLog(c, p)) return; - + vector_cstring::value_type msg; if (aMessage.size() >= d->m_maxLength) { msg = (vector_cstring::value_type) malloc(d->m_maxLength); @@ -73,17 +72,17 @@ void BufferedLogCallback::operator()(sgDebugClass c, sgDebugPriority p, } else { msg = (vector_cstring::value_type) strdup(aMessage.c_str()); } - + std::lock_guard g(d->m_mutex); d->m_buffer.push_back(msg); d->m_stamp++; } - + unsigned int BufferedLogCallback::stamp() const { return d->m_stamp; } - + unsigned int BufferedLogCallback::threadsafeCopy(vector_cstring& aOutput) { std::lock_guard g(d->m_mutex); @@ -91,11 +90,11 @@ unsigned int BufferedLogCallback::threadsafeCopy(vector_cstring& aOutput) aOutput.resize(sz); memcpy(aOutput.data(), d->m_buffer.data(), sz * sizeof(vector_cstring::value_type)); return d->m_stamp; -} - +} + void BufferedLogCallback::truncateAt(unsigned int t) { d->m_maxLength = t; } - + } // of namespace simgear diff --git a/simgear/debug/logstream.cxx b/simgear/debug/logstream.cxx index 02cd3ffc..5b736eff 100644 --- a/simgear/debug/logstream.cxx +++ b/simgear/debug/logstream.cxx @@ -24,14 +24,13 @@ #include "logstream.hxx" +#include #include #include #include #include #include -#include - #include #include #include @@ -63,7 +62,7 @@ LogCallback::LogCallback(sgDebugClass c, sgDebugPriority p) : bool LogCallback::shouldLog(sgDebugClass c, sgDebugPriority p) const { - + if ((c & m_class) != 0 && p >= m_priority) return true; if (c == SG_OSG) // always have OSG logging as it OSG logging is configured separately. @@ -164,10 +163,10 @@ public: /* can be -ve to indicate that m_fileLine was false, but we want to show file:line information regardless of m_fileLine. */ m_file - << file - << ":" + << file + << ":" << abs(line) - << ": " + << ": " ; } m_file @@ -202,7 +201,7 @@ public: { if (!shouldLog(c, p)) return; //fprintf(stderr, "%s\n", aMessage.c_str()); - + if (file && line > 0) { fprintf(stderr, "%8.2f %s:%i: [%.8s]:%-10s %s\n", logTimer.elapsedMSec()/1000.0, file, line, debugPriorityToString(p), debugClassToString(c), aMessage.c_str()); } @@ -303,10 +302,10 @@ public: * window; stdout/stderr will not appear (except in logfiles as they do now) * 4) When started from the Console (with --console) open a new console window * 5) Ensure that IO redirection still works when started from the console - * + * * Notes: * 1) fgfs needs to be a GUI subsystem app - which it already is - * 2) What can't be done is to make the cmd prompt run fgfs synchronously; + * 2) What can't be done is to make the cmd prompt run fgfs synchronously; * this is only something that can be done via "start /wait fgfs". */ @@ -330,7 +329,7 @@ public: } } else { /* - * Attempt to attach to the console process of the parent process; when launched from cmd.exe this should be the console, + * Attempt to attach to the console process of the parent process; when launched from cmd.exe this should be the console, * when launched via the RUN menu explorer, or another GUI app that wasn't started from the console this will fail. * When it fails we will redirect to the NUL device. This is to ensure that we have valid streams. * Later on in the initialisation sequence the --console option will be processed and this will cause the requestConsole() to @@ -360,7 +359,7 @@ public: if (!stdout_isNull){ if (!m_stdout_isRedirectedAlready) freopen("conout$", "w", stdout); - else + else /* * for already redirected streams we need to attach the stream to the OS handle that is open. * - this comes from part of the answer http://stackoverflow.com/a/13841522 @@ -379,7 +378,7 @@ public: } } //http://stackoverflow.com/a/25927081 - //Clear the error state for each of the C++ standard stream objects. + //Clear the error state for each of the C++ standard stream objects. std::wcout.clear(); std::cout.clear(); std::wcerr.clear(); @@ -532,7 +531,7 @@ public: PauseThread pause(this); m_logPriority = p; m_logClass = c; - BOOST_FOREACH(simgear::LogCallback* cb, m_consoleCallbacks) { + for (auto cb : m_consoleCallbacks) { cb->setLogLevels(c, p); } } @@ -542,7 +541,7 @@ public: // Testing mode, so always log. if (m_testMode) return true; - // SG_OSG (OSG notify) - will always be displayed regardless of FG log settings as OSG log level is configured + // SG_OSG (OSG notify) - will always be displayed regardless of FG log settings as OSG log level is configured // separately and thus it makes more sense to allow these message through. if (static_cast(p) == static_cast(SG_OSG)) return true; @@ -822,7 +821,7 @@ namespace simgear { void requestConsole() -{ +{ sglog().requestConsole(); } diff --git a/simgear/io/HTTPClient.cxx b/simgear/io/HTTPClient.cxx index d354bacc..1126691c 100644 --- a/simgear/io/HTTPClient.cxx +++ b/simgear/io/HTTPClient.cxx @@ -35,7 +35,6 @@ #include #include -#include #include #include @@ -125,7 +124,7 @@ Client::Client() : static bool didInitCurlGlobal = false; static std::mutex initMutex; - + std::lock_guard g(initMutex); if (!didInitCurlGlobal) { curl_global_init(CURL_GLOBAL_ALL); @@ -183,15 +182,15 @@ void Client::update(int waitTimeout) &curlWriteFDs, &curlErrorFDs, &maxFD); - + struct timeval timeout; long t; - + curl_multi_timeout(d->curlMulti, &t); if ((t < 0) || (t > waitTimeout)) { t = waitTimeout; } - + timeout.tv_sec = t / 1000; timeout.tv_usec = (t % 1000) * 1000; ::select(maxFD, &curlReadFDs, &curlWriteFDs, &curlErrorFDs, &timeout); @@ -489,7 +488,7 @@ bool isRedirectStatus(int code) { return ((code >= 300) && (code < 400)); } - + size_t Client::requestHeaderCallback(char *rawBuffer, size_t size, size_t nitems, void *userdata) { size_t byteSize = size * nitems; @@ -504,7 +503,7 @@ size_t Client::requestHeaderCallback(char *rawBuffer, size_t size, size_t nitems return byteSize; } } - + if (req->readyState() == HTTP::Request::OPENED) { req->responseStart(h); return byteSize; diff --git a/simgear/io/httpget.cxx b/simgear/io/httpget.cxx index 9ae3064d..1e87cf60 100644 --- a/simgear/io/httpget.cxx +++ b/simgear/io/httpget.cxx @@ -5,8 +5,6 @@ #include #include -#include - #include #include @@ -29,17 +27,17 @@ public: _complete(false), _file(NULL) { - + } - + void setFile(SGFile* f) { _file = f; } - + bool complete() const { return _complete; } - + void addHeader(const string& h) { int colonPos = h.find(':'); @@ -47,22 +45,22 @@ public: cerr << "malformed header: " << h << endl; return; } - + string key = h.substr(0, colonPos); requestHeader(key) = h.substr(colonPos + 1); } - + protected: virtual void onDone() { _complete = true; - } + } virtual void gotBodyData(const char* s, int n) { _file->write(s, n); } -private: +private: bool _complete; SGFile* _file; }; @@ -74,7 +72,7 @@ int main(int argc, char* argv[]) string proxy, proxyAuth; string_list headers; string url; - + for (int a=0; aaddHeader(h); } - + req->setFile(outFile); cl.makeRequest(req); - + while (!req->complete()) { cl.update(); SGTimeStamp::sleepForMSec(100); } - + if (req->responseCode() != 200) { cerr << "got response:" << req->responseCode() << endl; cerr << "\treason:" << req->responseReason() << endl; return EXIT_FAILURE; } - + return EXIT_SUCCESS; } diff --git a/simgear/misc/sg_dir.cxx b/simgear/misc/sg_dir.cxx index 0836a49b..1ea314db 100644 --- a/simgear/misc/sg_dir.cxx +++ b/simgear/misc/sg_dir.cxx @@ -41,7 +41,6 @@ #include #include -#include #include #include @@ -122,7 +121,7 @@ Dir Dir::tempDir(const std::string& templ) "mkdtemp failed: " << simgear::strutils::error_string(errno)); return Dir(); } - + return Dir(SGPath(buf)); #else #if defined(SG_WINDOWS) @@ -138,7 +137,7 @@ Dir Dir::tempDir(const std::string& templ) SG_LOG(SG_IO, SG_WARN, "failed to create temporary directory at " << p); return Dir(); } - + return t; #endif } @@ -154,7 +153,7 @@ PathList Dir::children(int types, const std::string& nameFilter) const if (types == 0) { types = TYPE_FILE | TYPE_DIR | NO_DOT_OR_DOTDOT; } - + #if defined(SG_WINDOWS) std::wstring search(_path.wstr()); if (nameFilter.empty()) { @@ -162,18 +161,18 @@ PathList Dir::children(int types, const std::string& nameFilter) const } else { search += simgear::strutils::convertUtf8ToWString("\\*" + nameFilter); } - + WIN32_FIND_DATAW fData; HANDLE find = FindFirstFileW(search.c_str(), &fData); if (find == INVALID_HANDLE_VALUE) { int err = GetLastError(); if (err != ERROR_FILE_NOT_FOUND) { - SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << + SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: FindFirstFile failed:" << _path << " with error:" << err); } return result; } - + bool done = false; for (bool done = false; !done; done = (FindNextFileW(find, &fData) == 0)) { if (fData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) { @@ -181,7 +180,7 @@ PathList Dir::children(int types, const std::string& nameFilter) const continue; } } - + std::string utf8File = simgear::strutils::convertWStringToUtf8(fData.cFileName); if (fData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (types & NO_DOT_OR_DOTDOT) { @@ -212,32 +211,32 @@ PathList Dir::children(int types, const std::string& nameFilter) const SG_LOG(SG_GENERAL, SG_WARN, "Dir::children: opendir failed:" << _path); return result; } - + int filterLen = nameFilter.size(); - + while (true) { struct dirent* entry = readdir(dp); if (!entry) { break; // done iteration } - + // skip hidden files (names beginning with '.') unless requested if (!(types & INCLUDE_HIDDEN) && (entry->d_name[0] == '.') && strcmp(entry->d_name, ".") && strcmp(entry->d_name, "..")) { continue; } - + SGPath f = file(entry->d_name); if (!f.exists()) { continue; // stat() failed } - + if (f.isDir()) { // directory handling if (!(types & TYPE_DIR)) { continue; } - + if (types & NO_DOT_OR_DOTDOT) { if (!strcmp(entry->d_name, ".") || !strcmp(entry->d_name, "..")) { continue; @@ -258,17 +257,17 @@ PathList Dir::children(int types, const std::string& nameFilter) const if (nameLen < filterLen) { continue; // name is shorter than the filter } - + char* nameSuffix = entry->d_name + (nameLen - filterLen); if (strcmp(nameSuffix, nameFilter.c_str())) { continue; } } - + // passed all criteria, add to our result vector result.push_back(file(entry->d_name)); } - + closedir(dp); #endif @@ -316,7 +315,7 @@ SGPath Dir::file(const std::string& name) const SGPath childPath = _path; childPath.set_cached(true); childPath.append(name); - return childPath; + return childPath; } bool Dir::create(mode_t mode) @@ -324,7 +323,7 @@ bool Dir::create(mode_t mode) if (exists()) { return false; // already exists } - + // recursively create parent directories Dir pr(parent()); if (!pr.path().isNull() && !pr.exists()) { @@ -333,7 +332,7 @@ bool Dir::create(mode_t mode) return false; } } - + // finally, create ourselves #if defined(SG_WINDOWS) std::wstring ps = _path.wstr(); @@ -347,7 +346,7 @@ bool Dir::create(mode_t mode) "directory creation failed for '" << _path.utf8Str() << "': " << simgear::strutils::error_string(errno)); } - + return (err == 0); } @@ -359,20 +358,20 @@ bool Dir::removeChildren() const bool ok; PathList cs = children(NO_DOT_OR_DOTDOT | INCLUDE_HIDDEN | TYPE_FILE | TYPE_DIR); - BOOST_FOREACH(SGPath path, cs) { + for (auto path : cs) { if (path.isDir()) { Dir childDir(path); ok = childDir.remove(true); } else { ok = path.remove(); } - + if (!ok) { SG_LOG(SG_IO, SG_WARN, "failed to remove:" << path); return false; } } // of child iteration - + return true; } @@ -382,7 +381,7 @@ bool Dir::remove(bool recursive) SG_LOG(SG_IO, SG_WARN, "attempt to remove non-existant dir:" << _path); return false; } - + if (recursive) { if (!removeChildren()) { SG_LOG(SG_IO, SG_WARN, "Dir at:" << _path << " failed to remove children"); diff --git a/simgear/package/Catalog.cxx b/simgear/package/Catalog.cxx index 89d9eddf..d56975c0 100644 --- a/simgear/package/Catalog.cxx +++ b/simgear/package/Catalog.cxx @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -49,7 +48,7 @@ bool checkVersion(const std::string& aVersion, SGPropertyNode_ptr props) } return false; } - + SGPropertyNode_ptr alternateForVersion(const std::string& aVersion, SGPropertyNode_ptr props) { for (auto v : props->getChildren("alternate-version")) { @@ -59,7 +58,7 @@ SGPropertyNode_ptr alternateForVersion(const std::string& aVersion, SGPropertyNo } } } - + return {}; } @@ -131,7 +130,7 @@ protected: return; } // of version check failed - + // validate what we downloaded, in case it's now corrupted // (i.e someone uploaded bad XML data) if (!m_owner->validatePackages()) { @@ -150,7 +149,7 @@ protected: m_owner->writeTimestamp(); m_owner->refreshComplete(Delegate::STATUS_REFRESHED); } - + void onFail() override { // network level failure @@ -206,17 +205,17 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath) } else { SG_LOG(SG_GENERAL, SG_DEBUG, "creating catalog from:" << aPath); } - + // check for the marker file we write, to mark a catalog as disabled const SGPath disableMarkerFile = aPath / "_disabled_"; CatalogRef c = new Catalog(aRoot); c->m_installRoot = aPath; - + if (disableMarkerFile.exists()) { c->m_userEnabled = false; } - + c->parseProps(props); c->parseTimestamp(); @@ -233,7 +232,7 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath) return c; } - + bool Catalog::validatePackages() const { for (auto pack : packages()) { @@ -242,7 +241,7 @@ bool Catalog::validatePackages() const return false; } } - + return true; } @@ -285,10 +284,10 @@ bool Catalog::removeDirectory() Dir d(m_installRoot); if (!m_installRoot.exists()) return true; - + return d.remove(true /* recursive */); } - + PackageList const& Catalog::packages() const { @@ -299,7 +298,7 @@ PackageList Catalog::packagesMatching(const SGPropertyNode* aFilter) const { PackageList r; - BOOST_FOREACH(PackageRef p, m_packages) { + for (auto p : m_packages) { if (p->matches(aFilter)) { r.push_back(p); } @@ -311,7 +310,7 @@ PackageList Catalog::packagesNeedingUpdate() const { PackageList r; - BOOST_FOREACH(PackageRef p, m_packages) { + for (auto p : m_packages) { if (!p->isInstalled()) { continue; } @@ -327,7 +326,7 @@ PackageList Catalog::installedPackages() const { PackageList r; - BOOST_FOREACH(PackageRef p, m_packages) { + for (auto p : m_packages) { if (p->isInstalled()) { r.push_back(p); } @@ -570,7 +569,7 @@ bool Catalog::isEnabled() const { if (!m_userEnabled) return false; - + switch (m_status) { case Delegate::STATUS_SUCCESS: case Delegate::STATUS_REFRESHED: @@ -592,7 +591,7 @@ void Catalog::setUserEnabled(bool b) { if (m_userEnabled == b) return; - + m_userEnabled = b; SGPath disableMarkerFile = installRoot() / "_disabled_"; if (m_userEnabled) { @@ -604,15 +603,15 @@ void Catalog::setUserEnabled(bool b) SG_LOG(SG_GENERAL, SG_ALERT, "Failed to remove catalog-disable marker file:" << disableMarkerFile); } } - + Delegate::StatusCode effectiveStatus = m_status; if ((m_status == Delegate::STATUS_SUCCESS) && !m_userEnabled) { effectiveStatus = Delegate::USER_DISABLED; } - + m_root->catalogRefreshStatus(this, effectiveStatus); } - + void Catalog::processAlternate(SGPropertyNode_ptr alt) { std::string altId; @@ -620,19 +619,19 @@ void Catalog::processAlternate(SGPropertyNode_ptr alt) if (idPtr) { altId = std::string(idPtr); } - + std::string altUrl; if (alt->getStringValue("url")) { altUrl = std::string(alt->getStringValue("url")); } - + CatalogRef existing; if (!altId.empty()) { existing = root()->getCatalogById(altId); } else { existing = root()->getCatalogByUrl(altUrl); } - + if (existing && (existing != this)) { // we already have the alternate, so just go quiet here changeStatus(Delegate::FAIL_VERSION); @@ -650,13 +649,13 @@ void Catalog::processAlternate(SGPropertyNode_ptr alt) changeStatus(Delegate::FAIL_VERSION); return; } - + SG_LOG(SG_GENERAL, SG_INFO, "Migrating catalog " << id() << " to new URL:" << altUrl); setUrl(altUrl); Downloader* dl = new Downloader(this, altUrl); root()->makeHTTPRequest(dl); } - + } // of namespace pkg } // of namespace simgear diff --git a/simgear/package/Package.cxx b/simgear/package/Package.cxx index 3dc0e73d..a5fca6ce 100644 --- a/simgear/package/Package.cxx +++ b/simgear/package/Package.cxx @@ -20,7 +20,6 @@ #include #include -#include #include #include @@ -144,19 +143,19 @@ bool Package::matches(const SGPropertyNode* aFilter) const return false; } - + bool Package::matchesDescription(const std::string &search) const { std::string n(search); boost::to_lower(n); - + bool localized; auto d = getLocalisedString(m_props, "description", &localized); boost::to_lower(d); if (d.find(n) != std::string::npos) { return true; } - + // try non-localized description too, if the abovce was a localized one if (localized) { const std::string baseDesc = m_props->getStringValue("description"); @@ -165,7 +164,7 @@ bool Package::matchesDescription(const std::string &search) const return true; } } - + // try each variant's description for (auto var : m_props->getChildren("variant")) { auto vd = getLocalisedString(var, "description", &localized); @@ -175,7 +174,7 @@ bool Package::matchesDescription(const std::string &search) const return true; } } - + if (localized) { // try non-localized variant description std::string vd = var->getStringValue("description"); @@ -185,7 +184,7 @@ bool Package::matchesDescription(const std::string &search) const } } } // of variant iteration - + return false; } @@ -298,7 +297,7 @@ string_set Package::tags() const { return m_tags; } - + bool Package::hasTag(const std::string& tag) const { return m_tags.find(tag) != m_tags.end(); @@ -344,11 +343,11 @@ std::string Package::getLocalisedString(const SGPropertyNode* aRoot, const char* // we now check first in /sim/localized//name first const auto& locale = m_catalog->root()->getLocale(); if (isLocalized) *isLocalized = false; - + if (locale.empty()) { return aRoot->getStringValue(aName); } - + const SGPropertyNode* localeRoot; if (aRoot->hasChild("localized")) { localeRoot = aRoot->getChild("localized")->getChild(locale); @@ -369,7 +368,7 @@ PackageList Package::dependencies() const { PackageList result; - BOOST_FOREACH(SGPropertyNode* dep, m_props->getChildren("depends")) { + for (auto dep : m_props->getChildren("depends")) { std::string depName = dep->getStringValue("id"); unsigned int rev = dep->getIntValue("revision", 0); @@ -410,7 +409,7 @@ std::string Package::nameForVariant(const std::string& vid) const return name(); } - BOOST_FOREACH(SGPropertyNode* var, m_props->getChildren("variant")) { + for (auto var : m_props->getChildren("variant")) { if (vid == var->getStringValue("id")) { return var->getStringValue("name"); } @@ -546,19 +545,19 @@ bool Package::validate() const { if (m_id.empty()) return false; - + std::string nm(m_props->getStringValue("name")); if (nm.empty()) return false; - + std::string dir(m_props->getStringValue("dir")); if (dir.empty()) return false; - + return true; } - + } // of namespace pkg } // of namespace simgear diff --git a/simgear/package/Root.cxx b/simgear/package/Root.cxx index d064751f..07ac6ff2 100755 --- a/simgear/package/Root.cxx +++ b/simgear/package/Root.cxx @@ -19,7 +19,6 @@ #include -#include #include #include #include @@ -50,7 +49,7 @@ namespace { return strutils::encodeHex(sha1_result(&info), HASH_LENGTH); } } // of anonymous namespace - + namespace pkg { typedef std::map CatalogDict; @@ -70,7 +69,7 @@ public: m_realUrl = aUrl; } } - + std::string realUrl() const { return m_realUrl; @@ -105,7 +104,7 @@ public: d->installStatusChanged(install, status); } } - + void fireStartInstall(InstallRef install) { for (auto d : delegates) { @@ -151,7 +150,7 @@ public: std::string u = dl->realUrl(); if (status == Delegate::STATUS_SUCCESS) { thumbnailCache[u].requestPending = false; - + // if this was a network load, rather than a re-load from the disk cache, // then persist to disk now. if (strutils::starts_with(request->url(), "http")) { @@ -201,7 +200,7 @@ public: std::string u = pendingThumbnails.front(); pendingThumbnails.pop_front(); - + thumbnailDownloadRequest = new Root::ThumbnailDownloader(this, u); if (http) { @@ -217,7 +216,7 @@ public: d->finishUninstall(pkg); } } - + SGPath pathInCache(const std::string& url) const { const auto hash = hashForUrl(url); @@ -226,7 +225,7 @@ public: if (pos == std::string::npos) { return SGPath(); } - + return path / "ThumbnailCache" / (hash + url.substr(pos)); } @@ -243,14 +242,14 @@ public: assert(it != thumbnailCache.end()); it->second.pathOnDisk = cachePath; } - + bool checkPersistentCache(const std::string& url) { SGPath cachePath = pathInCache(url); if (!cachePath.exists()) { return false; } - + // check age, if it's too old, expire and download again int age = time(nullptr) - cachePath.modTime(); const int cacheMaxAge = SECONDS_PER_DAY * 7; @@ -259,15 +258,15 @@ public: // cache refresh might fail return false; } - + loadFromPersistentCache(url, cachePath); return true; } - + void loadFromPersistentCache(const std::string& url, const SGPath& path) { assert(path.exists()); - + auto it = thumbnailCache.find(url); if (it == thumbnailCache.end()) { ThumbnailCacheEntry entry; @@ -276,12 +275,12 @@ public: } else { assert(it->second.pathOnDisk.isNull() || (it->second.pathOnDisk == path)); } - + sg_ifstream thumbnailStream(path, std::ios::in | std::ios::binary); string bytes = thumbnailStream.read_all(); fireDataForThumbnail(url, reinterpret_cast(bytes.data()), bytes.size()); } - + DelegateVec delegates; SGPath path; @@ -299,14 +298,14 @@ public: HTTP::Request_ptr thumbnailDownloadRequest; StringDeque pendingThumbnails; - + struct ThumbnailCacheEntry { int retryCount = 0; bool requestPending = false; SGPath pathOnDisk; }; - + std::map thumbnailCache; typedef std::map InstallCache; @@ -320,7 +319,7 @@ void Root::ThumbnailDownloader::onDone() m_owner->thumbnailDownloadComplete(this, Delegate::STATUS_SUCCESS, m_buffer); return; } - + if (responseCode() != 200) { auto status = (responseCode() == 403) ? Delegate::FAIL_HTTP_FORBIDDEN : Delegate::FAIL_DOWNLOAD; SG_LOG(SG_NETWORK, SG_INFO, "thumbnail download failure: " << url() << " with reason " << responseCode()); @@ -349,7 +348,7 @@ unsigned int Root::maxAgeSeconds() const void Root::setHTTPClient(HTTP::Client* aHTTP) { d->http = aHTTP; - BOOST_FOREACH(HTTP::Request_ptr req, d->httpPendingRequests) { + for (auto req : d->httpPendingRequests) { d->http->makeRequest(req); } @@ -398,7 +397,7 @@ Root::Root(const SGPath& aPath, const std::string& aVersion) : if (!thumbsCacheDir.exists()) { thumbsCacheDir.create(0755); } - + for (SGPath c : dir.children(Dir::TYPE_DIR | Dir::NO_DOT_OR_DOTDOT)) { // note this will set the catalog status, which will insert into // disabled catalogs automatically if necesary @@ -449,10 +448,10 @@ CatalogRef Root::getCatalogByUrl(const std::string& aUrl) const { return (v.second->url() == aUrl); }); if (it == d->catalogs.end()) return {}; - + return it->second; } - + PackageRef Root::getPackageById(const std::string& aName) const { size_t lastDot = aName.rfind('.'); @@ -491,7 +490,7 @@ CatalogList Root::catalogs() const return r; } - + CatalogList Root::allCatalogs() const { CatalogList r = catalogs(); @@ -597,7 +596,7 @@ void Root::scheduleToUpdate(InstallRef aInstall) if (!aInstall) { throw sg_exception("missing argument to scheduleToUpdate"); } - + auto it = std::find(d->updateDeque.begin(), d->updateDeque.end(), aInstall); if (it != d->updateDeque.end()) { // already scheduled to update @@ -724,17 +723,17 @@ void Root::catalogRefreshStatus(CatalogRef aCat, Delegate::StatusCode aReason) d->firePackagesChanged(); } } - + bool Root::removeCatalog(CatalogRef cat) { if (!cat) return false; - + // normal remove path if (!cat->id().empty()) { return removeCatalogById(cat->id()); } - + if (!cat->removeDirectory()) { SG_LOG(SG_GENERAL, SG_WARN, "removeCatalog: failed to remove directory " << cat->installRoot()); } @@ -744,10 +743,10 @@ bool Root::removeCatalog(CatalogRef cat) if (it != d->disabledCatalogs.end()) { d->disabledCatalogs.erase(it); } - + // notify that a catalog is being removed d->firePackagesChanged(); - + return true; } diff --git a/simgear/package/pkgutil.cxx b/simgear/package/pkgutil.cxx index 1088d001..fccb185b 100644 --- a/simgear/package/pkgutil.cxx +++ b/simgear/package/pkgutil.cxx @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -98,7 +97,7 @@ void printPackageInfo(pkg::Package* pkg) if (pkg->properties()->hasChild("author")) { cout << "Authors:" << endl; - BOOST_FOREACH(SGPropertyNode* author, pkg->properties()->getChildren("author")) { + for (auto author : pkg->properties()->getChildren("author")) { if (author->hasChild("name")) { cout << "\t" << author->getStringValue("name") << endl; @@ -174,7 +173,7 @@ int main(int argc, char** argv) pkg->install()->uninstall(); } else if (!strcmp(argv[1], "update-all")) { pkg::PackageList updates = root->packagesNeedingUpdate(); - BOOST_FOREACH(pkg::Package* p, updates) { + for (auto p : updates) { root->scheduleToUpdate(p->install()); } } else if (!strcmp(argv[1], "list-updated")) { @@ -185,7 +184,7 @@ int main(int argc, char** argv) } cout << updates.size() << " packages have updates" << endl; - BOOST_FOREACH(pkg::Package* p, updates) { + for (auto p : updates) { cout << "\t" << p->id() << " " << p->getLocalisedProp("name") << endl; } } else if (!strcmp(argv[1], "info")) { diff --git a/simgear/props/PropertyBasedMgr.cxx b/simgear/props/PropertyBasedMgr.cxx index a279219a..b07f895e 100644 --- a/simgear/props/PropertyBasedMgr.cxx +++ b/simgear/props/PropertyBasedMgr.cxx @@ -21,8 +21,6 @@ #include "PropertyBasedMgr.hxx" -#include - #include #include @@ -78,7 +76,7 @@ namespace simgear if( name.empty() ) return PropertyBasedElementPtr(); - BOOST_FOREACH(PropertyBasedElementPtr el, _elements) + for (auto el : _elements) if( el && el->getProps()->getStringValue("name") == name ) return el; diff --git a/simgear/scene/dem/SGDem.cxx b/simgear/scene/dem/SGDem.cxx index d5c8c773..64d7a803 100644 --- a/simgear/scene/dem/SGDem.cxx +++ b/simgear/scene/dem/SGDem.cxx @@ -22,8 +22,6 @@ #include #include -#include - #include // for CPLMalloc() #include "ogr_spatialref.h" @@ -96,7 +94,7 @@ int SGDem::addRoot( const SGPath& root ) std::istringstream iss( p.file() ); getline(iss, prefix, '_'); - if ( ((iss.rdstate() & std::ifstream::failbit ) == 0 ) && + if ( ((iss.rdstate() & std::ifstream::failbit ) == 0 ) && (prefix == "level" ) ) { iss >> level; @@ -234,7 +232,7 @@ SGDemSession SGDem::openSession( const SGGeod& min, const SGGeod& max, const SGP int max_lat = (int)(ceil(max.getLatitudeDeg()+FP_ROUNDOFF_OUTSIDE)); // Create the session - SG_LOG( SG_TERRAIN, SG_INFO, "SGDem::OpenSession - create sesion obj - req from " << + SG_LOG( SG_TERRAIN, SG_INFO, "SGDem::OpenSession - create sesion obj - req from " << min.getLongitudeDeg() << ", " << min.getLatitudeDeg() << " to " << max.getLongitudeDeg() << ", " << max.getLatitudeDeg() << " - getting " << min_lon << ", " << min_lat << " to " << max_lon << ", " << max_lat ); @@ -251,7 +249,7 @@ SGDemSession SGDem::openSession( const SGGeod& min, const SGGeod& max, const SGP SG_LOG( SG_TERRAIN, SG_INFO, "SGDem::OpenSession - Traverse tiles"); for (int lon = min_lon; lon < max_lon; lon += w) { for (int lat = min_lat; lat < max_lat; lat += h) { - SG_LOG( SG_TERRAIN, SG_INFO, "SGDem::OpenSession - Create tile " << + SG_LOG( SG_TERRAIN, SG_INFO, "SGDem::OpenSession - Create tile " << lon << ", " << lat << " from dir " << input ); unsigned wo = (lon+180)*8; @@ -291,7 +289,7 @@ unsigned short SGDem::getAlt( const SGDemSession& s, const SGGeod& loc ) const int lvlIndex = s.getLvlIndex(); if ( lvlIndex >= 0 ) { - // be careful with coordinates that lie on session boundaries - + // be careful with coordinates that lie on session boundaries - // on min, ok. // on max - make sure we select the tile in the session... int lvlWidth = levels[lvlIndex].getWidth(); diff --git a/simgear/scene/dem/SGDemTile_gdal.cxx b/simgear/scene/dem/SGDemTile_gdal.cxx index bcc9f08d..d187fc86 100644 --- a/simgear/scene/dem/SGDemTile_gdal.cxx +++ b/simgear/scene/dem/SGDemTile_gdal.cxx @@ -8,7 +8,7 @@ * Author: Frank Warmerdam * ****************************************************************************** - * Copyright (c) 2002, i3 - information integration and imaging + * Copyright (c) 2002, i3 - information integration and imaging * Fort Collin, CO * Copyright (c) 2007-2013, Even Rouault * @@ -34,8 +34,6 @@ #include #include -#include - #include // for CPLMalloc() #include "ogr_spatialref.h" @@ -163,14 +161,14 @@ GDALDatasetH SGDemTile::createTile( char **papszSrcFiles, const char *pszFilenam { const char *pszMethod = CSLFetchNameValue( papszTO, "METHOD" ); - if( GDALGetProjectionRef( hSrcDS ) != NULL + if( GDALGetProjectionRef( hSrcDS ) != NULL && strlen(GDALGetProjectionRef( hSrcDS )) > 0 && (pszMethod == NULL || EQUAL(pszMethod,"GEOTRANSFORM")) ) { pszThisSourceSRS = GDALGetProjectionRef( hSrcDS ); } else if( GDALGetGCPProjection( hSrcDS ) != NULL - && strlen(GDALGetGCPProjection(hSrcDS)) > 0 - && GDALGetGCPCount( hSrcDS ) > 1 + && strlen(GDALGetGCPProjection(hSrcDS)) > 0 + && GDALGetGCPCount( hSrcDS ) > 1 && (pszMethod == NULL || EQUALN(pszMethod,"GCP_",4)) ) { pszThisSourceSRS = GDALGetGCPProjection( hSrcDS ); } else if( pszMethod != NULL && EQUAL(pszMethod,"RPC") ) { @@ -229,7 +227,7 @@ GDALDatasetH SGDemTile::createTile( char **papszSrcFiles, const char *pszFilenam nPixels = nForcePixels; nLines = nForceLines; } - else + else { fprintf(stderr, "UHOH - need force pixels/lines\n"); } @@ -238,7 +236,7 @@ GDALDatasetH SGDemTile::createTile( char **papszSrcFiles, const char *pszFilenam /* Create the output file. */ /* -------------------------------------------------------------------- */ char** papszCreateOptions = CSLAddString( NULL, "COMPRESS=DEFLATE" ); - hDstDS = GDALCreate( hDriver, pszFilename, nPixels, nLines, + hDstDS = GDALCreate( hDriver, pszFilename, nPixels, nLines, nDstBandCount, eDT, papszCreateOptions ); CSLDestroy( papszCreateOptions ); @@ -361,17 +359,17 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** CSLDestroy(papszMetadataNew); /* copy band-level metadata and other info */ - if ( GDALGetRasterCount( hSrcDS ) == GDALGetRasterCount( hDstDS ) ) + if ( GDALGetRasterCount( hSrcDS ) == GDALGetRasterCount( hDstDS ) ) { for ( int iBand = 0; iBand < GDALGetRasterCount( hSrcDS ); iBand++ ) { hSrcBand = GDALGetRasterBand( hSrcDS, iBand + 1 ); hDstBand = GDALGetRasterBand( hDstDS, iBand + 1 ); /* copy metadata, except stats (#5319) */ - papszMetadata = GDALGetMetadata( hSrcBand, NULL); + papszMetadata = GDALGetMetadata( hSrcBand, NULL); if ( CSLCount(papszMetadata) > 0 ) { - //GDALSetMetadata( hDstBand, papszMetadata, NULL ); + //GDALSetMetadata( hDstBand, papszMetadata, NULL ); char** papszMetadataNew = NULL; for( int i = 0; papszMetadata != NULL && papszMetadata[i] != NULL; i++ ) { @@ -385,23 +383,23 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** if ( bCopyBandInfo ) { pszSrcInfo = GDALGetDescription( hSrcBand ); if( pszSrcInfo != NULL && strlen(pszSrcInfo) > 0 ) - GDALSetDescription( hDstBand, pszSrcInfo ); + GDALSetDescription( hDstBand, pszSrcInfo ); pszSrcInfo = GDALGetRasterUnitType( hSrcBand ); if( pszSrcInfo != NULL && strlen(pszSrcInfo) > 0 ) - GDALSetRasterUnitType( hDstBand, pszSrcInfo ); + GDALSetRasterUnitType( hDstBand, pszSrcInfo ); } } } } /* remove metadata that conflicts between datasets */ - else + else { CPLDebug("WARP", "Removing conflicting metadata from destination dataset (source #%d)", iSrc ); /* remove conflicting dataset-level metadata */ RemoveConflictingMetadata( hDstDS, GDALGetMetadata( hSrcDS, NULL ), pszMDConflictValue ); /* remove conflicting copy band-level metadata and other info */ - if ( GDALGetRasterCount( hSrcDS ) == GDALGetRasterCount( hDstDS ) ) + if ( GDALGetRasterCount( hSrcDS ) == GDALGetRasterCount( hDstDS ) ) { for ( int iBand = 0; iBand < GDALGetRasterCount( hSrcDS ); iBand++ ) { @@ -416,13 +414,13 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** if( ! ( pszSrcInfo != NULL && strlen(pszSrcInfo) > 0 && pszDstInfo != NULL && strlen(pszDstInfo) > 0 && EQUAL( pszSrcInfo, pszDstInfo ) ) ) - GDALSetDescription( hDstBand, "" ); + GDALSetDescription( hDstBand, "" ); pszSrcInfo = GDALGetRasterUnitType( hSrcBand ); pszDstInfo = GDALGetRasterUnitType( hDstBand ); if( ! ( pszSrcInfo != NULL && strlen(pszSrcInfo) > 0 && pszDstInfo != NULL && strlen(pszDstInfo) > 0 && EQUAL( pszSrcInfo, pszDstInfo ) ) ) - GDALSetRasterUnitType( hDstBand, "" ); + GDALSetRasterUnitType( hDstBand, "" ); } } } @@ -465,7 +463,7 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** /* -------------------------------------------------------------------- */ /* Warp the transformer with a linear approximator */ /* -------------------------------------------------------------------- */ - hTransformArg = GDALCreateApproxTransformer( GDALGenImgProjTransform, + hTransformArg = GDALCreateApproxTransformer( GDALGenImgProjTransform, hTransformArg, dfErrorThreshold); pfnTransformer = GDALApproxTransform; GDALApproxTransformerOwnsSubtransformer(hTransformArg, TRUE); @@ -474,7 +472,7 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** /* Clear temporary INIT_DEST settings after the first image. */ /* -------------------------------------------------------------------- */ if( iSrc == 1 ) - papszWarpOptions = CSLSetNameValue( papszWarpOptions, + papszWarpOptions = CSLSetNameValue( papszWarpOptions, "INIT_DEST", NULL ); /* -------------------------------------------------------------------- */ @@ -518,13 +516,13 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** if( bEnableSrcAlpha ) psWO->nSrcAlphaBand = GDALGetRasterCount(hSrcDS); - if( !bEnableDstAlpha - && GDALGetRasterCount(hDstDS) == psWO->nBandCount+1 - && GDALGetRasterColorInterpretation( - GDALGetRasterBand(hDstDS,GDALGetRasterCount(hDstDS))) + if( !bEnableDstAlpha + && GDALGetRasterCount(hDstDS) == psWO->nBandCount+1 + && GDALGetRasterColorInterpretation( + GDALGetRasterBand(hDstDS,GDALGetRasterCount(hDstDS))) == GCI_AlphaBand ) { - printf( "Using band %d of destination image as alpha.\n", + printf( "Using band %d of destination image as alpha.\n", GDALGetRasterCount(hDstDS) ); bEnableDstAlpha = TRUE; @@ -551,9 +549,9 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** printf( "Using internal nodata values (e.g. %g) for image %s.\n", dfReal, pszSrcFile ); - psWO->padfSrcNoDataReal = (double *) + psWO->padfSrcNoDataReal = (double *) CPLMalloc(psWO->nBandCount*sizeof(double)); - psWO->padfSrcNoDataImag = (double *) + psWO->padfSrcNoDataImag = (double *) CPLMalloc(psWO->nBandCount*sizeof(double)); for( int i = 0; i < psWO->nBandCount; i++ ) @@ -578,9 +576,9 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** /* else try to fill dstNoData from source bands */ if ( psWO->padfSrcNoDataReal != NULL ) { - psWO->padfDstNoDataReal = (double *) + psWO->padfDstNoDataReal = (double *) CPLMalloc(psWO->nBandCount*sizeof(double)); - psWO->padfDstNoDataImag = (double *) + psWO->padfDstNoDataImag = (double *) CPLMalloc(psWO->nBandCount*sizeof(double)); printf( "Copying nodata values from source %s \n", pszSrcFile ); @@ -597,13 +595,13 @@ void SGDemTile::doWarp( int iSrc, char* pszSrcFile, GDALDatasetH hDstDS, char** { psWO->padfDstNoDataReal[i] = psWO->padfSrcNoDataReal[i]; psWO->padfDstNoDataImag[i] = psWO->padfSrcNoDataImag[i]; - CPLDebug("WARP", "srcNoData=%f dstNoData=%f", + CPLDebug("WARP", "srcNoData=%f dstNoData=%f", psWO->padfSrcNoDataReal[i], psWO->padfDstNoDataReal[i] ); } CPLDebug("WARP", "calling GDALSetRasterNoDataValue() for band#%d", i ); - GDALSetRasterNoDataValue( - GDALGetRasterBand( hDstDS, psWO->panDstBands[i] ), + GDALSetRasterNoDataValue( + GDALGetRasterBand( hDstDS, psWO->panDstBands[i] ), psWO->padfDstNoDataReal[i] ); } } diff --git a/simgear/scene/material/Effect.cxx b/simgear/scene/material/Effect.cxx index 63a4b22e..d10d6b83 100644 --- a/simgear/scene/material/Effect.cxx +++ b/simgear/scene/material/Effect.cxx @@ -36,7 +36,6 @@ #include #include -#include #include #include #include @@ -106,7 +105,7 @@ bool loadShaderFromUTF8File(osg::Shader* shader, const std::string& fileName) sg_ifstream inStream(SGPath::fromUtf8(fileName), std::ios::in | std::ios::binary); if (!inStream.is_open()) return false; - + shader->setShaderSource(inStream.read_all()); return true; } @@ -261,8 +260,7 @@ int Effect::getGenerator(Effect::Generator what) const Technique* Effect::chooseTechnique(RenderInfo* info, const std::string &scheme) { - BOOST_FOREACH(ref_ptr& technique, techniques) - { + for (auto& technique : techniques) { if (technique->valid(info) == Technique::VALID && technique->getScheme() == scheme) return technique.get(); @@ -272,16 +270,14 @@ Technique* Effect::chooseTechnique(RenderInfo* info, const std::string &scheme) void Effect::resizeGLObjectBuffers(unsigned int maxSize) { - BOOST_FOREACH(const ref_ptr& technique, techniques) - { + for (const auto& technique : techniques) { technique->resizeGLObjectBuffers(maxSize); } } void Effect::releaseGLObjects(osg::State* state) const { - BOOST_FOREACH(const ref_ptr& technique, techniques) - { + for (const auto& technique : techniques) { technique->releaseGLObjects(state); } } @@ -929,8 +925,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, // resolvedProgramMap for a program using those shaders. ProgramKey resolvedKey; resolvedKey.attributes = prgKey.attributes; - BOOST_FOREACH(const ShaderKey& shaderKey, prgKey.shaders) - { + for (const auto& shaderKey : prgKey.shaders) { // FIXME orig: const string& shaderName = shaderKey.first; string shaderName = shaderKey.first; Shader::Type stype = (Shader::Type)shaderKey.second; @@ -957,8 +952,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, return; } program = new Program; - BOOST_FOREACH(const ShaderKey& skey, resolvedKey.shaders) - { + for (const auto& skey : resolvedKey.shaders) { const string& fileName = skey.first; Shader::Type stype = (Shader::Type)skey.second; ShaderMap::iterator sitr = shaderMap.find(skey); @@ -973,7 +967,7 @@ void ShaderProgramBuilder::buildAttribute(Effect* effect, Pass* pass, } } } - BOOST_FOREACH(const ProgramKey::AttribKey& key, prgKey.attributes) { + for (const auto& key : prgKey.attributes) { program->addBindAttribLocation(key.first, key.second); } const SGPropertyNode* pGeometryVerticesOut @@ -1551,7 +1545,7 @@ bool Effect_writeLocalData(const Object& obj, osgDB::Output& fw) const Effect& effect = static_cast(obj); fw.indent() << "techniques " << effect.techniques.size() << "\n"; - BOOST_FOREACH(const ref_ptr& technique, effect.techniques) { + for (const auto& technique : effect.techniques) { fw.writeObject(*technique); } return true; diff --git a/simgear/scene/material/Technique.cxx b/simgear/scene/material/Technique.cxx index c240391a..30f8db74 100644 --- a/simgear/scene/material/Technique.cxx +++ b/simgear/scene/material/Technique.cxx @@ -7,8 +7,6 @@ #include "Pass.hxx" #include "EffectCullVisitor.hxx" -#include - #include #include #include @@ -177,8 +175,7 @@ Technique::processDrawables(const EffectGeode::DrawablesIterator& begin, } EffectCullVisitor* ecv = dynamic_cast( cv ); EffectGeode::DrawablesIterator drawablesEnd = itr; - BOOST_FOREACH(ref_ptr& pass, passes) - { + for (auto& pass : passes) { osg::ref_ptr ss = pass; if (ecv && ( ! pass->getBufferUnitList().empty() || ! pass->getPositionedUniformMap().empty() ) ) { ss = static_cast( @@ -220,7 +217,7 @@ void Technique::resizeGLObjectBuffers(unsigned int maxSize) { if (_shadowingStateSet.valid()) _shadowingStateSet->resizeGLObjectBuffers(maxSize); - BOOST_FOREACH(ref_ptr& pass, passes) { + for (auto& pass : passes) { pass->resizeGLObjectBuffers(maxSize); } _contextMap.resize(maxSize); @@ -230,8 +227,7 @@ void Technique::releaseGLObjects(osg::State* state) const { if (_shadowingStateSet.valid()) _shadowingStateSet->releaseGLObjects(state); - BOOST_FOREACH(const ref_ptr& pass, passes) - { + for (const auto& pass : passes) { pass->releaseGLObjects(state); } if (state == 0) { @@ -384,7 +380,7 @@ Expression* glslSupportedParser(const SGPropertyNode* exp, expression::ExpParserRegistrar glslSupportedRegistrar("glsl-supported", glslSupportedParser); - + void Technique::setGLExtensionsPred(float glVersion, const std::vector& extensions) { @@ -444,7 +440,7 @@ bool Technique_writeLocalData(const Object& obj, osgDB::Output& fw) fw.writeObject(*tniq.getShadowingStateSet()); } fw.indent() << "num_passes " << tniq.passes.size() << "\n"; - BOOST_FOREACH(const ref_ptr& pass, tniq.passes) { + for (const auto& pass : tniq.passes) { fw.writeObject(*pass); } return true; diff --git a/simgear/scene/material/mat.cxx b/simgear/scene/material/mat.cxx index 6bedbdcd..d2b1d9cc 100644 --- a/simgear/scene/material/mat.cxx +++ b/simgear/scene/material/mat.cxx @@ -33,7 +33,6 @@ #include #include -#include #include "mat.hxx" #include @@ -520,8 +519,7 @@ void SGMaterial::buildEffectProperties(const SGReaderWriterOptions* options) makeChild(binProp, "bin-number")->setIntValue(TRANSPARENT_BIN); makeChild(binProp, "bin-name")->setStringValue("DepthSortedBin"); } - BOOST_FOREACH(_internal_state& matState, _status) - { + for (auto& matState : _status) { SGPropertyNode_ptr effectProp = new SGPropertyNode(); copyProperties(propRoot, effectProp); SGPropertyNode* effectParamProp = effectProp->getChild("parameters", 0); diff --git a/simgear/scene/model/SGLightAnimation.cxx b/simgear/scene/model/SGLightAnimation.cxx index fffc4742..76976067 100644 --- a/simgear/scene/model/SGLightAnimation.cxx +++ b/simgear/scene/model/SGLightAnimation.cxx @@ -34,7 +34,6 @@ #include #include #include -#include typedef std::map > EffectMap; static EffectMap lightEffectMap; @@ -68,8 +67,8 @@ public: params->getNode("ambient")->setValue(_ambient * dim); params->getNode("diffuse")->setValue(_diffuse * dim); params->getNode("specular")->setValue(_specular * dim); - BOOST_FOREACH(osg::ref_ptr & technique, effect->techniques) { - BOOST_FOREACH(osg::ref_ptr & pass, technique->passes) { + for (auto& technique : effect->techniques) { + for (auto& pass : technique->passes) { osg::Uniform* amb = pass->getUniform("Ambient"); if (amb) amb->set(osg::Vec4f(_ambient.x() * dim, _ambient.y() * dim, _ambient.z() * dim, _ambient.w() * dim)); diff --git a/simgear/scene/model/model.cxx b/simgear/scene/model/model.cxx index 008fdeb5..81f4e9e0 100644 --- a/simgear/scene/model/model.cxx +++ b/simgear/scene/model/model.cxx @@ -9,8 +9,6 @@ #include -#include - #include #include #include @@ -349,7 +347,7 @@ ref_ptr instantiateEffects(osg::Node* modelGroup, SGPropertyNode* defaultNode = configNode->getChild("default"); if (defaultNode && defaultNode->getValue()) defaultEffectPropRoot = configNode; - BOOST_FOREACH(SGPropertyNode_ptr objNameNode, objectNames) { + for (auto objNameNode : objectNames) { emap.insert(make_pair(objNameNode->getStringValue(), configNode)); } configNode->removeChild("default"); diff --git a/simgear/scene/tgdb/SGBuildingBin.cxx b/simgear/scene/tgdb/SGBuildingBin.cxx index dd2b66a1..3dbd7c5b 100644 --- a/simgear/scene/tgdb/SGBuildingBin.cxx +++ b/simgear/scene/tgdb/SGBuildingBin.cxx @@ -29,7 +29,6 @@ #include #include -#include #include #include diff --git a/simgear/scene/tgdb/apt_signs.cxx b/simgear/scene/tgdb/apt_signs.cxx index e04ddc67..9343fbd0 100644 --- a/simgear/scene/tgdb/apt_signs.cxx +++ b/simgear/scene/tgdb/apt_signs.cxx @@ -25,7 +25,6 @@ #endif #include -#include #include #include @@ -101,19 +100,19 @@ struct GlyphGeometry osg::Vec2Array* uvs; osg::Vec3Array* vertices; osg::Vec3Array* normals; - + void addGlyph(SGMaterialGlyph* glyph, double x, double y, double width, double height, const osg::Matrix& xform) { - + vertices->push_back(xform.preMult(osg::Vec3(thick, x, y))); vertices->push_back(xform.preMult(osg::Vec3(thick, x + width, y))); vertices->push_back(xform.preMult(osg::Vec3(thick, x + width, y + height))); vertices->push_back(xform.preMult(osg::Vec3(thick, x, y + height))); - + // texture coordinates double xoffset = glyph->get_left(); double texWidth = glyph->get_width(); - + uvs->push_back(osg::Vec2(xoffset, 0)); uvs->push_back(osg::Vec2(xoffset + texWidth, 0)); uvs->push_back(osg::Vec2(xoffset + texWidth, 1)); @@ -122,10 +121,10 @@ struct GlyphGeometry // normals for (int i=0; i<4; ++i) normals->push_back(xform.preMult(osg::Vec3(0, -1, 0))); - + quads->setCount(vertices->size()); } - + void addSignCase(double caseWidth, double caseHeight, const osg::Matrix& xform) { int last = vertices->size(); @@ -141,7 +140,7 @@ struct GlyphGeometry uvs->push_back(osg::Vec2(0.75, 1)); uvs->push_back(osg::Vec2(0.75, 0)); uvs->push_back(osg::Vec2(1, 0)); - + for (int i=0; i<4; ++i) normals->push_back(osg::Vec3(-1, 0.0, 0)); @@ -150,7 +149,7 @@ struct GlyphGeometry vertices->push_back(osg::Vec3(thick, -caseWidth, grounddist + caseHeight)); vertices->push_back(osg::Vec3(thick, caseWidth, grounddist + caseHeight)); vertices->push_back(osg::Vec3(-thick, caseWidth, grounddist + caseHeight)); - + uvs->push_back(osg::Vec2(1, texsize)); uvs->push_back(osg::Vec2(0.75, texsize)); uvs->push_back(osg::Vec2(0.75, 0)); @@ -179,7 +178,7 @@ struct GlyphGeometry (*vertices)[i]= xform.preMult((*vertices)[i]); (*normals)[i] = xform.preMult((*normals)[i]); } - + quads->setCount(vertices->size()); } }; @@ -189,17 +188,17 @@ typedef std::map EffectGeometryMap; GlyphGeometry* makeGeometry(Effect* eff, osg::Group* group) { GlyphGeometry* gg = new GlyphGeometry; - + EffectGeode* geode = new EffectGeode; geode->setEffect(eff); - + gg->vertices = new osg::Vec3Array; gg->normals = new osg::Vec3Array; gg->uvs = new osg::Vec2Array; - + osg::Vec4Array* cl = new osg::Vec4Array; cl->push_back(osg::Vec4(1, 1, 1, 1)); - + osg::Geometry* geometry = new osg::Geometry; geometry->setVertexArray(gg->vertices); geometry->setNormalArray(gg->normals); @@ -207,7 +206,7 @@ GlyphGeometry* makeGeometry(Effect* eff, osg::Group* group) geometry->setColorArray(cl); geometry->setColorBinding(osg::Geometry::BIND_OVERALL); geometry->setTexCoordArray(0, gg->uvs); - + gg->quads = new osg::DrawArrays(GL_QUADS, 0, gg->vertices->size()); geometry->addPrimitiveSet(gg->quads); geode->addDrawable(geometry); @@ -227,29 +226,29 @@ public: EffectGeometryMap geometries; osg::MatrixTransform* signsGroup; GlyphGeometry* signCaseGeometry; - + GlyphGeometry* getGeometry(Effect* eff) { EffectGeometryMap::iterator it = geometries.find(eff); if (it != geometries.end()) { return it->second; } - + GlyphGeometry* gg = makeGeometry(eff, signsGroup); geometries[eff] = gg; return gg; } - + void makeFace(const ElementVec& elements, double hpos, const osg::Matrix& xform) { - BOOST_FOREACH(element_info* element, elements) { + for (auto element : elements) { GlyphGeometry* gg = getGeometry(element->material->get_effect()); gg->addGlyph(element->glyph, hpos, grounddist, element->abswidth, element->height, xform); hpos += element->abswidth; delete element; } } - + }; AirportSignBuilder::AirportSignBuilder(SGMaterialLib* mats, const SGGeod& center) : @@ -257,7 +256,7 @@ AirportSignBuilder::AirportSignBuilder(SGMaterialLib* mats, const SGGeod& center { d->signsGroup = new osg::MatrixTransform; d->signsGroup->setMatrix(makeZUpFrame(center)); - + assert(mats); d->materials = mats; d->signCaseGeometry = d->getGeometry(d->materials->find("signcase", center)->get_effect()); @@ -505,12 +504,12 @@ void AirportSignBuilder::addSign(const SGGeod& pos, double heading, const std::s double boxwidth = std::max(total_width1, total_width2) * 0.5; double hpos = -boxwidth; SGMaterial *mat = d->materials->find("signcase", pos); - + double coverSize = fabs(total_width1 - total_width2) * 0.5; element_info* s1 = new element_info(mat, mat->get_glyph("cover1"), sign_height, coverSize); element_info* s2 = new element_info(mat, mat->get_glyph("cover2"), sign_height, coverSize); - - if (total_width1 < total_width2) { + + if (total_width1 < total_width2) { elements1.insert(elements1.begin(), s1); elements1.push_back(s2); } else if (total_width2 < total_width1) { @@ -520,25 +519,24 @@ void AirportSignBuilder::addSign(const SGGeod& pos, double heading, const std::s delete s1; delete s2; } - + // position the sign const osg::Vec3 Z_AXIS(0, 0, 1); osg::Matrix m(makeZUpFrame(pos)); m.preMultRotate(osg::Quat(SGMiscd::deg2rad(heading), Z_AXIS)); - + // apply the inverse of the group transform, so sign vertices // are relative to the tile center, and hence have a magnitude which // fits in a float with sufficent precision. m.postMult(d->signsGroup->getInverseMatrix()); - + d->makeFace(elements1, hpos, m); // Create back side osg::Matrix back(m); back.preMultRotate(osg::Quat(M_PI, Z_AXIS)); d->makeFace(elements2, hpos, back); - + d->signCaseGeometry->addSignCase(boxwidth, sign_height, m); } } // of namespace simgear - diff --git a/simgear/structure/SGBinding.cxx b/simgear/structure/SGBinding.cxx index 1f87ca95..d8992e9a 100644 --- a/simgear/structure/SGBinding.cxx +++ b/simgear/structure/SGBinding.cxx @@ -11,7 +11,6 @@ # include #endif -#include #include #include "SGBinding.hxx" @@ -103,7 +102,7 @@ SGBinding::fire (SGPropertyNode* params) const if (params != NULL) { copyProperties(params, _arg); } - + innerFire(); } } @@ -132,14 +131,14 @@ SGBinding::fire (double setting) const void fireBindingList(const SGBindingList& aBindings, SGPropertyNode* params) { - BOOST_FOREACH(SGBinding_ptr b, aBindings) { + for (auto b : aBindings) { b->fire(params); } } void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, double max) { - BOOST_FOREACH(SGBinding_ptr b, aBindings) { + for (auto b : aBindings) { b->fire(offset, max); } } @@ -147,16 +146,16 @@ void fireBindingListWithOffset(const SGBindingList& aBindings, double offset, do SGBindingList readBindingList(const simgear::PropertyList& aNodes, SGPropertyNode* aRoot) { SGBindingList result; - BOOST_FOREACH(SGPropertyNode* node, aNodes) { + for (auto node : aNodes) { result.push_back(new SGBinding(node, aRoot)); } - + return result; } void clearBindingList(const SGBindingList& aBindings) { - BOOST_FOREACH(SGBinding_ptr b, aBindings) { + for (auto b : aBindings) { b->clear(); } } @@ -167,7 +166,7 @@ bool anyBindingEnabled(const SGBindingList& aBindings) return false; } - BOOST_FOREACH(SGBinding_ptr b, aBindings) { + for (auto b : aBindings) { if (b->test()) { return true; } @@ -175,4 +174,3 @@ bool anyBindingEnabled(const SGBindingList& aBindings) return false; } -