diff --git a/base/stl_iterator.hpp b/base/stl_iterator.hpp index a409f08b5f..9ea9c0be53 100644 --- a/base/stl_iterator.hpp +++ b/base/stl_iterator.hpp @@ -2,25 +2,25 @@ #include -namespace detail +namespace stl_iterator_detail { struct Dummy { template Dummy & operator=(T const &) { return *this; } }; -} +} // namespace stl_iterator_detail class CounterIterator : - public boost::iterator_facade + public boost::iterator_facade { size_t m_count; public: CounterIterator() : m_count(0) {} size_t GetCount() const { return m_count; } - detail::Dummy & dereference() const + stl_iterator_detail::Dummy & dereference() const { - static detail::Dummy dummy; + static stl_iterator_detail::Dummy dummy; return dummy; } void increment() { ++m_count; } diff --git a/cmake/OmimHelpers.cmake b/cmake/OmimHelpers.cmake index 6e9a018d06..9f603851a6 100644 --- a/cmake/OmimHelpers.cmake +++ b/cmake/OmimHelpers.cmake @@ -71,6 +71,8 @@ endfunction() function(omim_add_library library) add_library(${library} ${ARGN}) + set_target_properties(${library} PROPERTIES UNITY_BUILD ON) + set_target_properties(${library} PROPERTIES UNITY_BUILD_BATCH_SIZE 50) add_dependencies(${library} BuildVersion) # Enable warnings for all our libraries. target_compile_options(${library} PRIVATE ${OMIM_WARNING_FLAGS}) diff --git a/drape_frontend/path_text_handle.cpp b/drape_frontend/path_text_handle.cpp index 5fb3e50b5d..a3aade16ae 100644 --- a/drape_frontend/path_text_handle.cpp +++ b/drape_frontend/path_text_handle.cpp @@ -10,9 +10,9 @@ namespace df namespace { -double const kValidSplineTurn = 15 * math::pi / 180; -double const kCosTurn = cos(kValidSplineTurn); -double const kSinTurn = sin(kValidSplineTurn); +double const kValidPathSplineTurn = 15 * math::pi / 180; +double const kCosTurn = cos(kValidPathSplineTurn); +double const kSinTurn = sin(kValidPathSplineTurn); double const kRoundStep = 23; int const kMaxStepsCount = 7; @@ -91,7 +91,7 @@ void AddPointAndRound(m2::Spline & spline, m2::PointD const & pt) double const dotProduct = m2::DotProduct(dir1, dir2); if (dotProduct < kCosTurn) { - int leftStepsCount = static_cast(acos(dotProduct) / kValidSplineTurn); + int leftStepsCount = static_cast(acos(dotProduct) / kValidPathSplineTurn); std::vector roundedCorner; while (leftStepsCount > 0 && leftStepsCount <= kMaxStepsCount && RoundCorner(spline.GetPath()[spline.GetSize() - 2], diff --git a/geometry/calipers_box.cpp b/geometry/calipers_box.cpp index c6bff0bcb9..38675cbcd8 100644 --- a/geometry/calipers_box.cpp +++ b/geometry/calipers_box.cpp @@ -23,7 +23,7 @@ static_assert(numeric_limits::has_infinity, ""); double const kInf = numeric_limits::infinity(); // Checks whether (p1 - p) x (p2 - p) >= 0. -bool IsCCW(PointD const & p1, PointD const & p2, PointD const & p, double eps) +bool IsCCWNeg(PointD const & p1, PointD const & p2, PointD const & p, double eps) { return robust::OrientedS(p1, p2, p) > -eps; } @@ -137,7 +137,7 @@ bool CalipersBox::HasPoint(PointD const & p, double eps) const { auto const & a = m_points[i]; auto const & b = m_points[(i + 1) % n]; - if (!IsCCW(b, p, a, eps)) + if (!IsCCWNeg(b, p, a, eps)) return false; } return true; diff --git a/indexer/categories_holder.cpp b/indexer/categories_holder.cpp index deb3feefcc..737fb81074 100644 --- a/indexer/categories_holder.cpp +++ b/indexer/categories_holder.cpp @@ -13,7 +13,7 @@ using namespace std; namespace { -enum State +enum ParseState { EParseTypes, EParseLanguages @@ -194,7 +194,7 @@ void CategoriesHolder::LoadFromStream(istream & s) m_name2type.Clear(); m_groupTranslations.clear(); - State state = EParseTypes; + ParseState state = EParseTypes; string line; Category cat; vector types; diff --git a/indexer/classificator.cpp b/indexer/classificator.cpp index 7fc66368ea..6f4c294750 100644 --- a/indexer/classificator.cpp +++ b/indexer/classificator.cpp @@ -123,18 +123,11 @@ void ClassifObject::ConcatChildNames(string & s) const // Classificator implementation ///////////////////////////////////////////////////////////////////////////////////////// -namespace -{ -Classificator & classif(MapStyle mapStyle) -{ - static Classificator c[MapStyleCount]; - return c[mapStyle]; -} -} // namespace - Classificator & classif() { - return classif(GetStyleReader().GetCurrentStyle()); + static Classificator c[MapStyleCount]; + MapStyle const mapStyle = GetStyleReader().GetCurrentStyle(); + return c[mapStyle]; } namespace ftype diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt index e657974792..bbb68de196 100644 --- a/platform/CMakeLists.txt +++ b/platform/CMakeLists.txt @@ -160,3 +160,24 @@ target_link_libraries(${PROJECT_NAME} omim_add_test_subdirectory(platform_tests_support) omim_add_test_subdirectory(platform_tests) + +set_property( + SOURCE + preferred_languages.cpp +apple_location_service.mm +gui_thread_apple.mm +http_client_apple.mm +http_thread_apple.h +http_thread_apple.mm +http_uploader_apple.mm +http_uploader_background_dummy.cpp +locale.mm +platform_mac.mm +platform_unix_impl.cpp +platform_unix_impl.hpp +secure_storage_qt.cpp +socket_apple.mm +http_session_manager.mm +PROPERTY + SKIP_UNITY_BUILD_INCLUSION ON +) diff --git a/routing_common/bicycle_model.cpp b/routing_common/bicycle_model.cpp index 29dfecf765..07fe417f2b 100644 --- a/routing_common/bicycle_model.cpp +++ b/routing_common/bicycle_model.cpp @@ -10,7 +10,7 @@ using namespace routing; using namespace std; -namespace +namespace bicycle_model { // See model specifics in different countries here: // https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions @@ -379,19 +379,19 @@ VehicleModel::SurfaceInitList const kBicycleSurface = { {{"psurface", "unpaved_good"}, {1.0, 1.0}}, {{"psurface", "unpaved_bad"}, {0.3, 0.3}} }; -} // namespace +} // namespace bicycle_model namespace routing { BicycleModel::BicycleModel() - : VehicleModel(classif(), kBicycleOptionsDefault, kBicycleSurface, - {kDefaultSpeeds, kDefaultFactors}) + : VehicleModel(classif(), bicycle_model::kBicycleOptionsDefault, bicycle_model::kBicycleSurface, + {bicycle_model::kDefaultSpeeds, bicycle_model::kDefaultFactors}) { Init(); } BicycleModel::BicycleModel(VehicleModel::LimitsInitList const & speedLimits) - : VehicleModel(classif(), speedLimits, kBicycleSurface, {kDefaultSpeeds, kDefaultFactors}) + : VehicleModel(classif(), speedLimits, bicycle_model::kBicycleSurface, {bicycle_model::kDefaultSpeeds, bicycle_model::kDefaultFactors}) { Init(); } @@ -406,8 +406,8 @@ void BicycleModel::Init() m_onedirBicycleType = classif().GetTypeByPath({"hwtag", "onedir_bicycle"}); vector const additionalTags = { {hwtagYesBicycle, m_maxModelSpeed}, - {{"route", "ferry"}, kDefaultSpeeds.at(HighwayType::RouteFerry)}, - {{"man_made", "pier"}, kDefaultSpeeds.at(HighwayType::ManMadePier)}}; + {{"route", "ferry"}, bicycle_model::kDefaultSpeeds.at(HighwayType::RouteFerry)}, + {{"man_made", "pier"}, bicycle_model::kDefaultSpeeds.at(HighwayType::ManMadePier)}}; SetAdditionalRoadTypes(classif(), additionalTags); } @@ -451,14 +451,14 @@ bool BicycleModel::IsOneWay(FeatureType & f) const return VehicleModel::IsOneWay(f); } -SpeedKMpH const & BicycleModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; } +SpeedKMpH const & BicycleModel::GetOffroadSpeed() const { return bicycle_model::kSpeedOffroadKMpH; } // If one of feature types will be disabled for bicycles, features of this type will be simplified // in generator. Look FeatureBuilder1::IsRoad() for more details. // static BicycleModel const & BicycleModel::AllLimitsInstance() { - static BicycleModel const instance(kBicycleOptionsAll); + static BicycleModel const instance(bicycle_model::kBicycleOptionsAll); return instance; } @@ -466,6 +466,7 @@ BicycleModelFactory::BicycleModelFactory( CountryParentNameGetterFn const & countryParentNameGetterFn) : VehicleModelFactory(countryParentNameGetterFn) { + using namespace bicycle_model; // Names must be the same with country names from countries.txt m_models[""] = make_shared(kBicycleOptionsDefault); m_models["Australia"] = make_shared(kBicycleOptionsAustralia); diff --git a/routing_common/car_model.cpp b/routing_common/car_model.cpp index 8d405fa49a..e7a84fadac 100644 --- a/routing_common/car_model.cpp +++ b/routing_common/car_model.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace routing; -namespace +namespace car_model { // See model specifics in different countries here: // https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions @@ -154,31 +154,31 @@ std::unordered_map const kCarOptions {"Slovakia", kCarOptionsNoPassThroughLivingStreet}, {"Ukraine", kCarOptionsNoPassThroughLivingStreetAndService} }; -} // namespace +} // namespace car_model namespace routing { CarModel::CarModel() - : VehicleModel(classif(), kCarOptionsDefault, kCarSurface, + : VehicleModel(classif(), car_model::kCarOptionsDefault, car_model::kCarSurface, {kHighwayBasedSpeeds, kHighwayBasedFactors}) { Init(); } CarModel::CarModel(VehicleModel::LimitsInitList const & roadLimits, HighwayBasedInfo const & info) - : VehicleModel(classif(), roadLimits, kCarSurface, info) + : VehicleModel(classif(), roadLimits, car_model::kCarSurface, info) { Init(); } -SpeedKMpH const & CarModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; } +SpeedKMpH const & CarModel::GetOffroadSpeed() const { return car_model::kSpeedOffroadKMpH; } void CarModel::Init() { m_noCarType = classif().GetTypeByPath({"hwtag", "nocar"}); m_yesCarType = classif().GetTypeByPath({"hwtag", "yescar"}); - SetAdditionalRoadTypes(classif(), kAdditionalTags); + SetAdditionalRoadTypes(classif(), car_model::kAdditionalTags); } VehicleModelInterface::RoadAvailability CarModel::GetRoadAvailability(feature::TypesHolder const & types) const @@ -200,25 +200,25 @@ CarModel const & CarModel::AllLimitsInstance() } // static -routing::VehicleModel::LimitsInitList const & CarModel::GetOptions() { return kCarOptionsDefault; } +routing::VehicleModel::LimitsInitList const & CarModel::GetOptions() { return car_model::kCarOptionsDefault; } // static vector const & CarModel::GetAdditionalTags() { - return kAdditionalTags; + return car_model::kAdditionalTags; } // static -VehicleModel::SurfaceInitList const & CarModel::GetSurfaces() { return kCarSurface; } +VehicleModel::SurfaceInitList const & CarModel::GetSurfaces() { return car_model::kCarSurface; } CarModelFactory::CarModelFactory(CountryParentNameGetterFn const & countryParentNameGetterFn) : VehicleModelFactory(countryParentNameGetterFn) { m_models[""] = make_shared( - kCarOptionsDefault, + car_model::kCarOptionsDefault, HighwayBasedInfo(kHighwayBasedSpeeds, kHighwayBasedFactors)); - for (auto const & kv : kCarOptionsByCountries) + for (auto const & kv : car_model::kCarOptionsByCountries) { auto const * country = kv.first; auto const & limit = kv.second; diff --git a/routing_common/pedestrian_model.cpp b/routing_common/pedestrian_model.cpp index 82cc331662..8c5e30ff87 100644 --- a/routing_common/pedestrian_model.cpp +++ b/routing_common/pedestrian_model.cpp @@ -10,7 +10,7 @@ using namespace routing; using namespace std; -namespace +namespace pedestrian_model { // See model specifics in different countries here: // https://wiki.openstreetmap.org/wiki/OSM_tags_for_routing/Access-Restrictions @@ -264,19 +264,19 @@ VehicleModel::SurfaceInitList const kPedestrianSurface = { {{"psurface", "unpaved_good"}, {1.0, 1.0}}, {{"psurface", "unpaved_bad"}, {0.8, 0.8}} }; -} // namespace +} // namespace pedestrian_model namespace routing { PedestrianModel::PedestrianModel() - : VehicleModel(classif(), kPedestrianOptionsDefault, kPedestrianSurface, - {kDefaultSpeeds, kDefaultFactors}) + : VehicleModel(classif(), pedestrian_model::kPedestrianOptionsDefault, pedestrian_model::kPedestrianSurface, + {pedestrian_model::kDefaultSpeeds, pedestrian_model::kDefaultFactors}) { Init(); } PedestrianModel::PedestrianModel(VehicleModel::LimitsInitList const & speedLimits) - : VehicleModel(classif(), speedLimits, kPedestrianSurface, {kDefaultSpeeds, kDefaultFactors}) + : VehicleModel(classif(), speedLimits, pedestrian_model::kPedestrianSurface, {pedestrian_model::kDefaultSpeeds, pedestrian_model::kDefaultFactors}) { Init(); } @@ -286,7 +286,7 @@ SpeedKMpH PedestrianModel::GetSpeed(FeatureType & f, SpeedParams const & speedPa return VehicleModel::GetSpeedWihtoutMaxspeed(f, speedParams); } -SpeedKMpH const & PedestrianModel::GetOffroadSpeed() const { return kSpeedOffroadKMpH; } +SpeedKMpH const & PedestrianModel::GetOffroadSpeed() const { return pedestrian_model::kSpeedOffroadKMpH; } void PedestrianModel::Init() { @@ -297,8 +297,8 @@ void PedestrianModel::Init() vector const additionalTags = { {hwtagYesFoot, m_maxModelSpeed}, - {{"route", "ferry"}, kDefaultSpeeds.at(HighwayType::RouteFerry)}, - {{"man_made", "pier"}, kDefaultSpeeds.at(HighwayType::ManMadePier)}}; + {{"route", "ferry"}, pedestrian_model::kDefaultSpeeds.at(HighwayType::RouteFerry)}, + {{"man_made", "pier"}, pedestrian_model::kDefaultSpeeds.at(HighwayType::ManMadePier)}}; SetAdditionalRoadTypes(classif(), additionalTags); } @@ -319,7 +319,7 @@ VehicleModelInterface::RoadAvailability PedestrianModel::GetRoadAvailability(fea // static PedestrianModel const & PedestrianModel::AllLimitsInstance() { - static PedestrianModel const instance(kPedestrianOptionsAll); + static PedestrianModel const instance(pedestrian_model::kPedestrianOptionsAll); return instance; } @@ -327,6 +327,7 @@ PedestrianModelFactory::PedestrianModelFactory( CountryParentNameGetterFn const & countryParentNameGetterFn) : VehicleModelFactory(countryParentNameGetterFn) { + using namespace pedestrian_model; // Names must be the same with country names from countries.txt m_models[""] = make_shared(kPedestrianOptionsDefault); m_models["Australia"] = make_shared(kPedestrianOptionsAustralia); diff --git a/storage/pinger.cpp b/storage/pinger.cpp index 1b65aac656..92dfc94cde 100644 --- a/storage/pinger.cpp +++ b/storage/pinger.cpp @@ -15,7 +15,7 @@ using namespace std; using namespace std::chrono; -namespace +namespace pinger { auto constexpr kTimeoutInSeconds = 4.0; int64_t constexpr kInvalidPing = -1; @@ -56,14 +56,14 @@ Pinger::Endpoints Pinger::ExcludeUnavailableAndSortEndpoints(Endpoints const & u CHECK_GREATER(size, 0, ()); using EntryT = std::pair; - std::vector timeUrls(size, {kInvalidPing, 0}); + std::vector timeUrls(size, {pinger::kInvalidPing, 0}); { ThreadPool pool(size, ThreadPool::Exit::ExecPending); for (size_t i = 0; i < size; ++i) { pool.Push([&urls, &timeUrls, i] { - timeUrls[i] = { DoPing(urls[i]), i }; + timeUrls[i] = { pinger::DoPing(urls[i]), i }; }); } } diff --git a/tools/unix/build_omim.sh b/tools/unix/build_omim.sh index 575a2f51a2..f48c595932 100755 --- a/tools/unix/build_omim.sh +++ b/tools/unix/build_omim.sh @@ -14,11 +14,12 @@ OPT_STANDALONE= OPT_COMPILE_DATABASE= OPT_LAUNCH_BINARY= OPT_NJOBS= -while getopts ":cdrstagjlpn:" opt; do +while getopts ":cdrxstagjlpn:" opt; do case $opt in a) OPT_STANDALONE=1 ;; c) OPT_CLEAN=1 ;; d) OPT_DEBUG=1 ;; + x) CMAKE_CONFIG="${CMAKE_CONFIG:-} -DUSE_PCH=YES" ;; g) OPT_GCC=1 ;; j) OPT_COMPILE_DATABASE=1 CMAKE_CONFIG="${CMAKE_CONFIG:-} -DCMAKE_EXPORT_COMPILE_COMMANDS=YES" @@ -35,22 +36,22 @@ while getopts ":cdrstagjlpn:" opt; do t) OPT_DESIGNER=1 ;; *) echo "This tool builds Organic Maps" - echo "Usage: $0 [-d] [-r] [-c] [-s] [-t] [-a] [-g] [-j] [-l] [-p PATH] [-n NUM] [target1 target2 ...]" + echo "Usage: $0 [-d] [-r] [-c] [-x] [-s] [-t] [-a] [-g] [-j] [-l] [-p PATH] [-n NUM] [target1 target2 ...]" echo - echo "By default all targets for both debug and release versions are built" - echo "and binaries are put into ../omim-build- dir." + echo "By default both debug and release versions are built in ../omim-build- dir." echo - echo -e "-d\tBuild debug version" - echo -e "-r\tBuild release version" - echo -e "-c\tClean before building" - echo -e "-s\tSkip desktop app building" - echo -e "-t\tBuild designer tool (only for MacOS X platform)" - echo -e "-a\tBuild standalone desktop app (only for MacOS X platform)" - echo -e "-g\tForce use GCC (only for MacOS X platform)" - echo -e "-p\tDirectory for built binaries" - echo -e "-n\tNumber of parallel processes" - echo -e "-j\tGenerate compile_commands.json" - echo -e "-l\tLaunches built binary(ies), useful for tests" + echo -e "-d Build debug version" + echo -e "-r Build release version" + echo -e "-x Use precompiled headers" + echo -e "-c Clean before building" + echo -e "-s Skip desktop app building" + echo -e "-t Build designer tool (only for MacOS X platform)" + echo -e "-a Build standalone desktop app (only for MacOS X platform)" + echo -e "-g Force use GCC (only for MacOS X platform)" + echo -e "-p Directory for built binaries" + echo -e "-n Number of parallel processes" + echo -e "-j Generate compile_commands.json" + echo -e "-l Launches built binary(ies), useful for tests" exit 1 ;; esac diff --git a/transit/transit_schedule.cpp b/transit/transit_schedule.cpp index a0c26bc4cf..b9e5dc9639 100644 --- a/transit/transit_schedule.cpp +++ b/transit/transit_schedule.cpp @@ -37,7 +37,7 @@ enum class DateTimeRelation Equal }; -DateTimeRelation GetDatesRelation(transit::Date const & date1, transit::Date const & date2) +DateTimeRelation GetDatesRelation(::transit::Date const & date1, ::transit::Date const & date2) { if (date1.m_year < date2.m_year) return DateTimeRelation::Earlier; @@ -57,7 +57,7 @@ DateTimeRelation GetDatesRelation(transit::Date const & date1, transit::Date con return DateTimeRelation::Equal; } -DateTimeRelation GetTimesRelation(transit::Time const & time1, transit::Time const & time2) +DateTimeRelation GetTimesRelation(::transit::Time const & time1, ::transit::Time const & time2) { if (time1.m_hour < time2.m_hour) return DateTimeRelation::Earlier; @@ -77,14 +77,14 @@ DateTimeRelation GetTimesRelation(transit::Time const & time1, transit::Time con return DateTimeRelation::Equal; } -transit::Date GetDate(std::tm const & tm) +::transit::Date GetDate(std::tm const & tm) { - return transit::Date(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); + return ::transit::Date(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday); } -transit::Time GetTime(std::tm const & tm) +::transit::Time GetTime(std::tm const & tm) { - return transit::Time(tm.tm_hour, tm.tm_min, tm.tm_sec); + return ::transit::Time(tm.tm_hour, tm.tm_min, tm.tm_sec); } } // namespace