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

booking_params_base.hpp « partners_api - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c2c275662b8d169e0e9434a4cccf6cff1924bdb5 (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
#pragma once

#include "partners_api/utils.hpp"

#include "base/macros.hpp"

#include <exception>

namespace booking
{
struct AvailabilityParams;
struct BlockParams;

struct ParamsBase
{
  using Clock = std::chrono::system_clock;
  using Time = Clock::time_point;

  static std::string FormatTime(Time p)
  {
    return partners_api::FormatTime(p, "%Y-%m-%d");
  }

  virtual ~ParamsBase() = default;

  virtual bool IsEmpty() const = 0;
  virtual bool Equals(ParamsBase const & rhs) const = 0;
  virtual void Set(ParamsBase const & src) = 0;

  virtual bool Equals(AvailabilityParams const & lhs) const
  {
    return false;
  }

  virtual bool Equals(BlockParams const & lhs) const
  {
    return false;
  }

  template <typename T>
  void CopyTo(T & dest) const
  {
    if (Equals(dest))
      return;

    try
    {
      dest = dynamic_cast<T const &>(*this);
    }
    catch (std::bad_cast const & ex)
    {
      CHECK(false, ("Cannot cast ParamsBase to child type"));
    }
  }
};
}  // namespace booking