MCPcopy Create free account
hub / github.com/comaps/comaps / LoadDataSources

Function LoadDataSources

tools/openlr/openlr_stat/openlr_stat.cpp:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59int32_t const kHandleAllSegments = -1;
60
61void LoadDataSources(std::string const & pathToMWMFolder, std::vector<FrozenDataSource> & dataSources)
62{
63 CHECK(Platform::IsDirectory(pathToMWMFolder), (pathToMWMFolder, "must be a directory."));
64
65 Platform::FilesList files;
66 Platform::GetFilesByRegExp(pathToMWMFolder, boost::regex(std::string(".*\\") + DATA_FILE_EXTENSION), files);
67
68 CHECK(!files.empty(), (pathToMWMFolder, "Contains no .mwm files."));
69
70 size_t const numDataSources = dataSources.size();
71 std::vector<uint64_t> numCountries(numDataSources);
72
73 for (auto const & fileName : files)
74 {
75 auto const fullFileName = base::JoinPath(pathToMWMFolder, fileName);
76 ModelReaderPtr reader(GetPlatform().GetReader(fullFileName, "f"));
77 platform::LocalCountryFile localFile(pathToMWMFolder, platform::CountryFile(base::FilenameWithoutExt(fileName)),
78 version::ReadVersionDate(reader));
79
80 LOG(LINFO, ("Found mwm:", fullFileName));
81 try
82 {
83 localFile.SyncWithDisk();
84 for (size_t i = 0; i < numDataSources; ++i)
85 {
86 auto const result = dataSources[i].RegisterMap(localFile);
87 CHECK_EQUAL(result.second, MwmSet::RegResult::Success, ("Can't register mwm:", localFile));
88
89 auto const & info = result.first.GetInfo();
90 if (info && info->GetType() == MwmInfo::COUNTRY)
91 ++numCountries[i];
92 }
93 }
94 catch (RootException const & ex)
95 {
96 CHECK(false, (ex.Msg(), "Bad mwm file:", localFile));
97 }
98 }
99
100 for (size_t i = 0; i < numDataSources; ++i)
101 if (numCountries[i] == 0)
102 LOG(LWARNING, ("No countries for thread", i));
103}
104
105bool ValidateLimit(char const * flagname, int32_t value)
106{

Callers 1

mainFunction · 0.85

Calls 11

JoinPathFunction · 0.85
FilenameWithoutExtFunction · 0.85
ReadVersionDateFunction · 0.85
SyncWithDiskMethod · 0.80
CountryFileClass · 0.50
emptyMethod · 0.45
sizeMethod · 0.45
GetReaderMethod · 0.45
RegisterMapMethod · 0.45
GetInfoMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected