From 692e1511aafbc05144fa82cb80698b96e27c2083 Mon Sep 17 00:00:00 2001 From: falsycat Date: Fri, 8 Sep 2023 20:54:16 +0900 Subject: [PATCH] remove nf7::File and unify data iface into subsys --- core/uv/file.cc | 8 ++++---- core/uv/file.hh | 20 ++++++++++---------- iface/CMakeLists.txt | 4 ---- iface/data/interface.hh | 23 ----------------------- iface/file.hh | 11 ----------- iface/{data => subsys}/buffer.hh | 7 ++++--- iface/{data/wrap.hh => subsys/wrapper.hh} | 10 +++++----- 7 files changed, 23 insertions(+), 60 deletions(-) delete mode 100644 iface/data/interface.hh delete mode 100644 iface/file.hh rename iface/{data => subsys}/buffer.hh (92%) rename iface/{data/wrap.hh => subsys/wrapper.hh} (52%) diff --git a/core/uv/file.cc b/core/uv/file.cc index cd075b5..8b6790a 100644 --- a/core/uv/file.cc +++ b/core/uv/file.cc @@ -52,10 +52,10 @@ std::shared_ptr File::Make( File::File(Env& env, std::string_view path, uvw::file_req::file_open_flags open_flags) -try : data::FiniteBuffer("nf7::core::uv::File::Finite"), - data::ResizableBuffer("nf7::core::uv::File::Resizable"), - data::ReadableBuffer("nf7::core::uv::File::Readable"), - data::WritableBuffer("nf7::core::uv::File::Writable"), +try : subsys::FiniteBuffer("nf7::core::uv::File::Finite"), + subsys::ResizableBuffer("nf7::core::uv::File::Resizable"), + subsys::ReadableBuffer("nf7::core::uv::File::Readable"), + subsys::WritableBuffer("nf7::core::uv::File::Writable"), logger_(env.GetOr(NullLogger::instance())), delete_(env.Get()->Make()), path_(path), diff --git a/core/uv/file.hh b/core/uv/file.hh index 79bb209..668fae6 100644 --- a/core/uv/file.hh +++ b/core/uv/file.hh @@ -13,7 +13,7 @@ #include "iface/common/future.hh" #include "iface/common/mutex.hh" #include "iface/common/void.hh" -#include "iface/data/buffer.hh" +#include "iface/subsys/buffer.hh" #include "iface/subsys/logger.hh" #include "iface/env.hh" @@ -23,10 +23,10 @@ namespace nf7::core::uv { class File : public std::enable_shared_from_this, - public data::FiniteBuffer, - public data::ResizableBuffer, - public data::ReadableBuffer, - public data::WritableBuffer { + public subsys::FiniteBuffer, + public subsys::ResizableBuffer, + public subsys::ReadableBuffer, + public subsys::WritableBuffer { private: class Finite; class Resizable; @@ -34,7 +34,7 @@ class File : class Writable; public: - using ReadResult = data::ReadableBuffer::Result; + using ReadResult = subsys::ReadableBuffer::Result; public: static std::shared_ptr Make( @@ -69,10 +69,10 @@ class File : Future Resize(uint64_t n) noexcept override { return Truncate(n); } public: - std::shared_ptr MakeFinite(); - std::shared_ptr MakeResizable(); - std::shared_ptr MakeReadable(); - std::shared_ptr MakeWritable(); + std::shared_ptr MakeFinite(); + std::shared_ptr MakeResizable(); + std::shared_ptr MakeReadable(); + std::shared_ptr MakeWritable(); private: const std::shared_ptr logger_; diff --git a/iface/CMakeLists.txt b/iface/CMakeLists.txt index 3b1716f..8abadfd 100644 --- a/iface/CMakeLists.txt +++ b/iface/CMakeLists.txt @@ -23,16 +23,12 @@ target_sources(nf7_iface common/task_context.hh common/value.hh common/void.hh - data/buffer.hh - data/interface.hh - data/wrap.hh subsys/concurrency.hh subsys/database.hh subsys/interface.hh subsys/logger.hh subsys/parallelism.hh env.hh - file.hh lambda.hh version.hh ) diff --git a/iface/data/interface.hh b/iface/data/interface.hh deleted file mode 100644 index b43b7f1..0000000 --- a/iface/data/interface.hh +++ /dev/null @@ -1,23 +0,0 @@ -// No copyright -#pragma once - -namespace nf7::data { - -class Interface { - public: - Interface() = delete; - explicit Interface(const char* name) : name_(name) { } - virtual ~Interface() = default; - - Interface(const Interface&) = delete; - Interface(Interface&&) = delete; - Interface& operator=(const Interface&) = delete; - Interface& operator=(Interface&&) = delete; - - const char* name() const noexcept { return name_; } - - private: - const char* name_; -}; - -} // namespace nf7::data diff --git a/iface/file.hh b/iface/file.hh deleted file mode 100644 index c8e2c1d..0000000 --- a/iface/file.hh +++ /dev/null @@ -1,11 +0,0 @@ -// No copyright -#pragma once - -#include "iface/common/container.hh" -#include "iface/data/interface.hh" - -namespace nf7 { - -using File = Container; - -} // namespace nf7 diff --git a/iface/data/buffer.hh b/iface/subsys/buffer.hh similarity index 92% rename from iface/data/buffer.hh rename to iface/subsys/buffer.hh index 5c91b89..c8c02ac 100644 --- a/iface/data/buffer.hh +++ b/iface/subsys/buffer.hh @@ -6,9 +6,9 @@ #include "iface/common/future.hh" #include "iface/common/void.hh" -#include "iface/data/interface.hh" +#include "iface/subsys/interface.hh" -namespace nf7::data { +namespace nf7::subsys { class FiniteBuffer : public Interface { public: @@ -54,4 +54,5 @@ class WritableBuffer : public Interface { } }; -} // namespace nf7::data +} // namespace nf7::subsys + diff --git a/iface/data/wrap.hh b/iface/subsys/wrapper.hh similarity index 52% rename from iface/data/wrap.hh rename to iface/subsys/wrapper.hh index 82b1884..f0dc0f6 100644 --- a/iface/data/wrap.hh +++ b/iface/subsys/wrapper.hh @@ -1,14 +1,14 @@ // No copyright #pragma once -#include "iface/data/interface.hh" +#include "iface/subsys/interface.hh" -namespace nf7::data { +namespace nf7::subsys { template -class Wrap : public Interface { +class Wrapper : public Interface { protected: - Wrap(const char* name, T& data) noexcept + Wrapper(const char* name, T& data) noexcept : Interface(name), data_(data) { } public: @@ -18,4 +18,4 @@ class Wrap : public Interface { T& data_; }; -} // namespace nf7::data +} // namespace nf7::subsys