blob: 5f99de7a765bbb64cac0829c4a2a064057ffce01 (
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
70
71
72
73
74
75
76
77
|
/* Copyright (c) 2016, Stanislaw Halik <sthalik@misaki.pl>
* Permission to use, copy, modify, and/or distribute this
* software for any purpose with or without fee is hereby granted,
* provided that the above copyright notice and this permission
* notice appear in all copies.
*/
#pragma once
#include <QString>
#include <vector>
#include "export.hpp"
namespace migrations {
class migration;
class registrator;
namespace detail {
class migrator final
{
static std::vector<migration*>& migrations();
static QString last_migration_time();
static QString time_after_migrations();
static void set_last_migration_time(const QString& val);
migrator() = delete;
static std::vector<migration*> sorted_migrations();
static int to_int(const QString& str, bool& ok);
public:
static std::vector<QString> run();
static void register_migration(migration* m);
static void mark_config_as_not_needing_migration();
};
template<typename t>
struct registrator final
{
registrator()
{
static t m;
migrator::register_migration(static_cast<migration*>(&m));
}
};
}
#ifndef __COUNTER__
# error "oops, need __COUNTER__ extension for preprocessor"
#endif
#define OPENTRACK_MIGRATION(type) static ::migrations::detail::registrator<type> opentrack_migration_registrator__ ## __COUNTER__ ## _gensym
#ifdef Q_CREATOR_RUN
# pragma clang diagnostic ignored "-Wweak-vtables"
#endif
class migration
{
migration& operator=(const migration&) = delete;
migration(const migration&) = delete;
migration& operator=(migration&&) = delete;
migration(migration&&) = delete;
public:
migration();
virtual ~migration();
virtual QString unique_date() const = 0;
virtual QString name() const = 0;
virtual bool should_run() const = 0;
virtual void run() = 0;
};
}
OTR_MIGRATION_EXPORT std::vector<QString> run_migrations();
OTR_MIGRATION_EXPORT void mark_config_as_not_needing_migration();
|