#pragma once #include #include #include "export.hpp" namespace migrations { class migration; class registrator; namespace detail { class migrator final { using mm = migration*; template using vec_ = std::vector; using vstr = vec_; using vec = vec_; static vec& migrations(); static QString last_migration_time(); static QString time_after_migrations(); static void set_last_migration_time(const QString& val); migrator() = delete; static vec sorted_migrations(); public: static vstr run(); static void register_migration(migration* m); static void mark_config_as_not_needing_migration(); }; template struct registrator final { registrator() { static t m; migrator::register_migration(static_cast(&m)); } }; } #ifndef __COUNTER__ # error "oops, need __COUNTER__ extension for preprocessor" #endif #define OPENTRACK_MIGRATION(type) static ::migrations::detail::registrator 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; }; } OPENTRACK_MIGRATION_EXPORT std::vector run_migrations(); OPENTRACK_MIGRATION_EXPORT void mark_config_as_not_needing_migration();