From fc406dff3525ae6b0296a6e874d28d5642f23e05 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sat, 5 Dec 2020 22:42:30 +0100 Subject: [PATCH] Extent scripting interface, add options interface --- include/dwarfs/options_interface.h | 43 ++++++++++++++++++++++++++++++ include/dwarfs/script.h | 7 +++++ test/dwarfs.cpp | 6 +++++ 3 files changed, 56 insertions(+) create mode 100644 include/dwarfs/options_interface.h diff --git a/include/dwarfs/options_interface.h b/include/dwarfs/options_interface.h new file mode 100644 index 00000000..0687e8d7 --- /dev/null +++ b/include/dwarfs/options_interface.h @@ -0,0 +1,43 @@ +/* vim:set ts=2 sw=2 sts=2 et: */ +/** + * \author Marcus Holland-Moritz (github@mhxnet.de) + * \copyright Copyright (c) Marcus Holland-Moritz + * + * This file is part of dwarfs. + * + * dwarfs is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * dwarfs is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with dwarfs. If not, see . + */ + +#pragma once + +#include + +#include "dwarfs/options.h" + +namespace dwarfs { + +class options_interface { + public: + enum set_mode { DEFAULT, OVERRIDE }; + + virtual ~options_interface() = default; + + virtual void + set_order(file_order_mode order_mode, set_mode mode = DEFAULT) = 0; + virtual void + set_remove_empty_dirs(bool remove_empty, set_mode mode = DEFAULT) = 0; + virtual void enable_similarity() = 0; +}; + +} // namespace dwarfs diff --git a/include/dwarfs/script.h b/include/dwarfs/script.h index d15719a2..c61e98d5 100644 --- a/include/dwarfs/script.h +++ b/include/dwarfs/script.h @@ -28,6 +28,7 @@ namespace dwarfs { class entry_interface; class inode; +class options_interface; class script { public: @@ -36,9 +37,15 @@ class script { virtual ~script() = default; + virtual bool has_configure() const = 0; + virtual bool has_filter() const = 0; + virtual bool has_transform() const = 0; + virtual bool has_order() const = 0; + virtual void configure(options_interface const& oi) = 0; virtual bool filter(entry_interface const& ei) = 0; virtual void transform(entry_interface& ei) = 0; virtual void order(inode_vector& iv) = 0; }; + } // namespace dwarfs diff --git a/test/dwarfs.cpp b/test/dwarfs.cpp index 08ce9246..014d8713 100644 --- a/test/dwarfs.cpp +++ b/test/dwarfs.cpp @@ -164,6 +164,12 @@ class os_access_mock : public os_access { class script_mock : public script { public: + bool has_configure() const override { return true; } + bool has_filter() const override { return true; } + bool has_transform() const override { return true; } + bool has_order() const override { return true; } + + void configure(options_interface const& /*oi*/) override {} bool filter(entry_interface const& /*ei*/) override { return true; }