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: c0ad15b39adea3035d6a7e30ea44f12b93e53807 (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
#pragma once

#include "base/assert.hpp"

#include <exception>

namespace booking
{
struct AvailabilityParams;
struct BlockParams;

struct ParamsBase
{
  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