From 8953c3a9fcd4b54ab6cefb26567a562cadcb1c36 Mon Sep 17 00:00:00 2001 From: "Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)" Date: Sat, 17 Nov 2018 16:23:09 +0000 Subject: Added combining_handle_adapter and xor_handle_adapter. These were written over a number of weeks in very short bursts on the train to work, so they are riddled with bugs. Do not use them until the documentation warning regarding them has been removed. --- .../algorithm/handle_adapter/cached_parent.hpp | 3 + .../v2.0/algorithm/handle_adapter/combining.hpp | 589 +++++++++++++++++++++ .../llfio/v2.0/algorithm/handle_adapter/xor.hpp | 193 +++++++ 3 files changed, 785 insertions(+) create mode 100644 include/llfio/v2.0/algorithm/handle_adapter/combining.hpp create mode 100644 include/llfio/v2.0/algorithm/handle_adapter/xor.hpp (limited to 'include/llfio/v2.0/algorithm') diff --git a/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp b/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp index bbc2c7ab..c39b34fc 100644 --- a/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp +++ b/include/llfio/v2.0/algorithm/handle_adapter/cached_parent.hpp @@ -71,6 +71,9 @@ namespace algorithm handle at the time of creation. Third party changes to the part of the filesystem you are working upon will result in the inability to do race free unlinking etc, but if no third party changes are encountered it ought to work well. + + \todo I have been lazy and used public inheritance from that base i/o handle. + I should use protected inheritance to prevent slicing, and expose all the public functions by hand. */ template LLFIO_REQUIRES(sizeof(construct) > 0) class LLFIO_DECL cached_parent_handle_adapter : public T { diff --git a/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp b/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp new file mode 100644 index 00000000..c15962c9 --- /dev/null +++ b/include/llfio/v2.0/algorithm/handle_adapter/combining.hpp @@ -0,0 +1,589 @@ +/* A handle which combines two other handles +(C) 2018 Niall Douglas (14 commits) +File Created: Oct 2018 + + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License in the accompanying file +Licence.txt or at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +Distributed under the Boost Software License, Version 1.0. + (See accompanying file Licence.txt or copy at + http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef LLFIO_ALGORITHM_HANDLE_ADAPTER_COMBINING_H +#define LLFIO_ALGORITHM_HANDLE_ADAPTER_COMBINING_H + +#include "../../map_handle.hpp" + +//! \file handle_adapter/combining.hpp Provides `combining_handle_adapter`. + +LLFIO_V2_NAMESPACE_EXPORT_BEGIN + +namespace algorithm +{ + namespace detail + { + // file_handle additional member functions + struct file_handle_wrapper : public file_handle + { + file_handle_wrapper() = default; + using file_handle::file_handle; + file_handle_wrapper(native_handle_type nativeh, io_handle::caching _caching, io_handle::flag flags) + : file_handle(nativeh, 0, 0, _caching, flags) + { + } + }; + template + using combining_handle_adapter_choose_base = std::conditional_t< // + std::is_base_of::value && (std::is_void::value || std::is_base_of::value), // + file_handle_wrapper, // + io_handle // + >; + template struct is_void_or_io_request_compatible + { + static constexpr bool value = std::is_same, typename B::template io_request>::value; + }; + template struct is_void_or_io_request_compatible : std::true_type + { + }; + + template