1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include "storage/queued_country.hpp"
#include "base/assert.hpp"
namespace storage
{
QueuedCountry::QueuedCountry(TCountryId const & countryId, MapOptions opt)
: m_countryId(countryId), m_init(opt), m_left(opt), m_current(MapOptions::Nothing)
{
// @TODO(bykoianko) Probably it's nessecary to check if InIndexInCountryTree here.
ASSERT(IsCountryIdValid(GetCountryId()), ("Only valid countries may be downloaded."));
ASSERT(m_left != MapOptions::Nothing, ("Empty file set was requested for downloading."));
SwitchToNextFile();
}
void QueuedCountry::AddOptions(MapOptions opt)
{
for (MapOptions file : {MapOptions::Map, MapOptions::CarRouting})
{
if (HasOptions(opt, file) && !HasOptions(m_init, file))
{
m_init = SetOptions(m_init, file);
m_left = SetOptions(m_left, file);
}
}
}
void QueuedCountry::RemoveOptions(MapOptions opt)
{
for (MapOptions file : {MapOptions::Map, MapOptions::CarRouting, MapOptions::Diff})
{
if (HasOptions(opt, file) && HasOptions(m_init, file))
{
m_init = UnsetOptions(m_init, file);
m_left = UnsetOptions(m_left, file);
}
}
if (HasOptions(opt, m_current))
m_current = LeastSignificantOption(m_left);
}
void QueuedCountry::ResetToDefaultOptions()
{
m_init = MapOptions::MapWithCarRouting;
m_left = MapOptions::MapWithCarRouting;
m_current = LeastSignificantOption(m_left);
}
bool QueuedCountry::SwitchToNextFile()
{
ASSERT(HasOptions(m_left, m_current),
("Current file (", m_current, ") is not specified in left files (", m_left, ")."));
m_left = UnsetOptions(m_left, m_current);
m_current = LeastSignificantOption(m_left);
return m_current != MapOptions::Nothing;
}
} // namespace storage
|