Welcome to mirror list, hosted at ThFree Co, Russian Federation.

storage_defines.hpp « storage - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: ee2c6361d6ba80f3496812eb316e1737e2da611c (plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
#pragma once

#include "storage/index.hpp"

#include "std/cstdint.hpp"
#include "std/function.hpp"
#include "std/string.hpp"
#include "std/utility.hpp"

namespace storage
{
  /// Inner status which is used inside Storage class
  enum class Status : uint8_t
  {
    EUndefined = 0,
    EOnDisk,          /**< Downloaded mwm(s) is up to date. No need to update it. */
    ENotDownloaded,   /**< Mwm can be download but not downloaded yet. */
    EDownloadFailed,  /**< Downloading failed because no internet connection. */
    EDownloading,     /**< Downloading a new mwm or updating an old one. */
    EInQueue,         /**< A mwm is waiting for downloading in the queue. */
    EUnknown,         /**< Downloading failed because of unknown error. */
    EOnDiskOutOfDate, /**< An update for a downloaded mwm is ready according to counties.txt. */
    EOutOfMemFailed,  /**< Downloading failed because it's not enough memory */
  };
  string DebugPrint(Status status);

  /// \note The order of enum items is important. It is used in Storage::NodeStatus method.
  /// If it's necessary to add more statuses it's better to add to the end.
  enum class NodeStatus
  {
    Undefined,
    Downloading,      /**< Downloading a new mwm or updating an old one. */
    InQueue,          /**< An mwm is waiting for downloading in the queue. */
    Error,            /**< An error happened while downloading */
    OnDiskOutOfDate,  /**< An update for a downloaded mwm is ready according to counties.txt. */
    OnDisk,           /**< Downloaded mwm(s) is up to date. No need to update it. */
    NotDownloaded,    /**< An mwm can be downloaded but not downloaded yet. */
    Partly,           /**< Leafs of group node has a mix of NotDownloaded and OnDisk status. */
  };
  string DebugPrint(NodeStatus status);

  enum class NodeErrorCode
  {
    NoError,
    UnknownError,     /**< Downloading failed because of unknown error. */
    OutOfMemFailed,   /**< Downloading failed because it's not enough memory */
    NoInetConnection, /**< Downloading failed because internet connection was interrupted */
  };
  string DebugPrint(NodeErrorCode status);

  struct StatusAndError
  {
    StatusAndError(NodeStatus nodeStatus, NodeErrorCode nodeError) :
      status(nodeStatus), error(nodeError) {}

    bool operator==(StatusAndError const & other)
    {
      return other.status == status && other.error == error;
    }

    NodeStatus status;
    NodeErrorCode error;
  };
  string DebugPrint(StatusAndError statusAndError);

  StatusAndError ParseStatus(Status innerStatus);
}  // namespace storage

using TDownloadFn = function<void (storage::TCountryId const &)>;