diff --git a/common/cpp/include/system/io.h b/common/cpp/include/system/io.h new file mode 100644 index 0000000000000000000000000000000000000000..925d53099376cc402f4f64375dcc2571bba0a461 --- /dev/null +++ b/common/cpp/include/system/io.h @@ -0,0 +1,106 @@ +#ifndef HIDRA2_SYSTEM__IO_H +#define HIDRA2_SYSTEM__IO_H + +#include <cinttypes> + +#include <string> +#include <vector> +#include <chrono> +#include <thread> + +#include "common/data_structs.h" +#include "io_error.h" + +namespace hidra2 { + +//Need to be "enum" since multiple flags are allowed +enum FileOpenMode { + IO_OPEN_MODE_READ = 1 << 0, + IO_OPEN_MODE_WRITE = 1 << 1, + IO_OPEN_MODE_RW = IO_OPEN_MODE_READ | IO_OPEN_MODE_WRITE, + IO_OPEN_MODE_CREATE = 1 << 2, + IO_OPEN_MODE_CREATE_AND_FAIL_IF_EXISTS = 1 << 3, + /** + * Will set the length of a file to 0 + * Only works if file is open with READ and WRITE mode + */ + IO_OPEN_MODE_SET_LENGTH_0 = 1 << 4, +}; + +enum class AddressFamilies { + INET, +}; + +enum class SocketTypes { + STREAM, +}; + +enum class SocketProtocols { + IP, +}; + +using FileDescriptor = int; +using SocketDescriptor = int; + +class IO { + public: + + /* + * Special + */ + virtual std::unique_ptr<std::thread> NewThread (std::function<void()> function) const = 0; + + /* + * Network + */ + virtual SocketDescriptor CreateSocket(AddressFamilies address_family, SocketTypes socket_type, + SocketProtocols socket_protocol, Error* err) const = 0; + virtual void Listen(SocketDescriptor socket_fd, int backlog, Error* err) const = 0; + virtual void InetBind(SocketDescriptor socket_fd, const std::string& address, Error* err) const = 0; + virtual SocketDescriptor CreateAndBindIPTCPSocketListener(const std::string& address, int backlog, + Error* err) const = 0; + virtual std::unique_ptr<std::tuple<std::string, SocketDescriptor>> InetAcceptConnection(SocketDescriptor socket_fd, + Error* err) const = 0; + virtual std::string ResolveHostnameToIp(const std::string& hostname, Error* err) const = 0; + virtual void InetConnect(SocketDescriptor socket_fd, const std::string& address, Error* err) const = 0; + virtual SocketDescriptor CreateAndConnectIPTCPSocket(const std::string& address, Error* err) const = 0; + virtual size_t Receive(SocketDescriptor socket_fd, void* buf, size_t length, Error* err) const = 0; + virtual size_t ReceiveWithTimeout(SocketDescriptor socket_fd, + void* buf, + size_t length, + long timeout_in_usec, + Error* err) const = 0; + virtual size_t Send(SocketDescriptor socket_fd, const void* buf, size_t length, Error* err) const = 0; + + virtual void Skip(SocketDescriptor socket_fd, size_t length, Error* err) const = 0; + /** + * @param err Since CloseSocket if often used in an error case, it's able to accept err as nullptr. + */ + virtual void CloseSocket(SocketDescriptor socket_fd, Error* err) const = 0; + + /* + * Filesystem + */ + virtual FileDescriptor Open (const std::string& filename, int open_flags, Error* err) const = 0; + /** + * @param err Since Close if often used in an error case, it's able to accept err as nullptr. + */ + virtual void Close (FileDescriptor fd, Error* err) const = 0; + + virtual size_t Read (FileDescriptor fd, void* buf, size_t length, Error* err) const = 0; + virtual size_t Write (FileDescriptor fd, const void* buf, size_t length, Error* err) const = 0; + + virtual Error WriteDataToFile (const std::string& fname, const FileData& data, size_t length) const = 0; + + virtual void CreateNewDirectory (const std::string& directory_name, Error* err) const = 0; + virtual FileData GetDataFromFile (const std::string& fname, uint64_t fsize, Error* err) const = 0; + virtual void CollectFileInformationRecursively(const std::string& path, std::vector<FileInfo>* files, + Error* err) const = 0; + virtual std::vector<FileInfo> FilesInFolder (const std::string& folder, Error* err) const = 0; + virtual std::string ReadFileToString (const std::string& fname, Error* err) const = 0; + +}; + +} + +#endif //HIDRA2_SYSTEM__IO_H diff --git a/common/cpp/include/system/io_error.h b/common/cpp/include/system/io_error.h new file mode 100644 index 0000000000000000000000000000000000000000..40c9d4dd7e2c62ad73531d0a4aa18ebbbdeff2d0 --- /dev/null +++ b/common/cpp/include/system/io_error.h @@ -0,0 +1,142 @@ +#ifndef HIDRA2_SYSTEM__IO_ERROR_H +#define HIDRA2_SYSTEM__IO_ERROR_H + +#include "common/error.h" + +namespace hidra2 { + + +enum class IOErrorType { + kUnknownIOError, + kBadFileNumber, + kResourceTemporarilyUnavailable, + kFileNotFound, + kReadError, + kPermissionDenied, + kUnsupportedAddressFamily, + kInvalidAddressFormat, + kAddressAlreadyInUse, + kConnectionRefused, + kConnectionResetByPeer, + kTimeout, + kFileAlreadyExists, + kNoSpaceLeft, + kSocketOperationOnNonSocket, + kInvalidMemoryAddress, + kUnableToResolveHostname, + kSocketOperationUnknownAtLevel, + kSocketOperationValueOutOfBound, + kAddressNotValid + +}; + +class IOError : public SimpleError { + private: + IOErrorType io_error_type_; + public: + IOError(const std::string& error, IOErrorType io_error_type) : SimpleError(error, ErrorType::kIOError) { + io_error_type_ = io_error_type; + } + + IOErrorType GetIOErrorType() const noexcept { + return io_error_type_; + } +}; + +class IOErrorTemplate : public SimpleErrorTemplate { + protected: + IOErrorType io_error_type_; + public: + IOErrorTemplate(const std::string& error, IOErrorType io_error_type) : SimpleErrorTemplate(error, ErrorType::kIOError) { + io_error_type_ = io_error_type; + } + + inline IOErrorType GetIOErrorType() const noexcept { + return io_error_type_; + } + + inline Error Generate() const noexcept override { + return Error(new IOError(error_, io_error_type_)); + } + + inline bool operator == (const Error& rhs) const override { + return SimpleErrorTemplate::operator==(rhs) + && GetIOErrorType() == ((IOError*)rhs.get())->GetIOErrorType(); + } +}; + +static inline std::ostream& operator<<(std::ostream& os, const IOErrorTemplate& err) { + return os << err.Text(); +} + + +namespace IOErrorTemplates { +auto const kUnknownIOError = IOErrorTemplate { + "Unknown Error", IOErrorType::kUnknownIOError +}; + +auto const kFileNotFound = IOErrorTemplate { + "No such file or directory", IOErrorType::kFileNotFound +}; +auto const kReadError = IOErrorTemplate { + "Read error", IOErrorType::kReadError +}; +auto const kBadFileNumber = IOErrorTemplate { + "Bad file number", IOErrorType::kBadFileNumber +}; +auto const kResourceTemporarilyUnavailable = IOErrorTemplate { + "Resource temporarily unavailable", IOErrorType::kResourceTemporarilyUnavailable +}; +auto const kPermissionDenied = IOErrorTemplate { + "Permission denied", IOErrorType::kPermissionDenied +}; +auto const kUnsupportedAddressFamily = IOErrorTemplate { + "Unsupported address family", IOErrorType::kUnsupportedAddressFamily +}; +auto const kInvalidAddressFormat = IOErrorTemplate { + "Invalid address format", IOErrorType::kInvalidAddressFormat +}; +auto const kAddressAlreadyInUse = IOErrorTemplate { + "Address already in use", IOErrorType::kAddressAlreadyInUse +}; +auto const kConnectionRefused = IOErrorTemplate { + "Connection refused", IOErrorType::kConnectionRefused +}; +auto const kConnectionResetByPeer = IOErrorTemplate { + "kConnectionResetByPeer", IOErrorType::kConnectionResetByPeer +}; +auto const kTimeout = IOErrorTemplate { + "kTimeout", IOErrorType::kTimeout +}; +auto const kFileAlreadyExists = IOErrorTemplate { + "kFileAlreadyExists", IOErrorType::kFileAlreadyExists +}; +auto const kNoSpaceLeft = IOErrorTemplate { + "kNoSpaceLeft", IOErrorType::kNoSpaceLeft +}; +auto const kSocketOperationOnNonSocket = IOErrorTemplate { + "kSocketOperationOnNonSocket", IOErrorType::kSocketOperationOnNonSocket +}; +auto const kInvalidMemoryAddress = IOErrorTemplate { + "kInvalidMemoryAddress", IOErrorType::kInvalidMemoryAddress +}; +auto const kUnableToResolveHostname = IOErrorTemplate { + "kUnableToResolveHostname", IOErrorType::kUnableToResolveHostname +}; +auto const kSocketOperationUnknownAtLevel = IOErrorTemplate { + "kSocketOperationUnknownAtLevel", IOErrorType::kSocketOperationUnknownAtLevel +}; + +auto const kSocketOperationValueOutOfBound = IOErrorTemplate { + "kSocketOperationValueOutOfBound", IOErrorType::kSocketOperationValueOutOfBound +}; + +auto const kAddressNotValid = IOErrorTemplate { + "Address not valid", IOErrorType::kAddressNotValid +}; + +} + +} + +#endif //HIDRA2_SYSTEM__IO_ERROR_H diff --git a/common/cpp/include/system_wrappers/io_factory.h b/common/cpp/include/system/io_factory.h similarity index 100% rename from common/cpp/include/system_wrappers/io_factory.h rename to common/cpp/include/system/io_factory.h diff --git a/common/cpp/include/system_wrappers/system_io.h b/common/cpp/include/system/system_io.h similarity index 97% rename from common/cpp/include/system_wrappers/system_io.h rename to common/cpp/include/system/system_io.h index 2a1703d7f4823a4ac53911a32fb217088888c191..3aac18edd8e60d7f95fbd2ceb8a2023cbe5432b7 100644 --- a/common/cpp/include/system_wrappers/system_io.h +++ b/common/cpp/include/system/system_io.h @@ -1,5 +1,5 @@ -#ifndef HIDRA2_SYSTEM_WRAPPERS__SYSTEM_IO_H -#define HIDRA2_SYSTEM_WRAPPERS__SYSTEM_IO_H +#ifndef HIDRA2_SYSTEM__SYSTEM_IO_H +#define HIDRA2_SYSTEM__SYSTEM_IO_H #include "io.h" @@ -108,4 +108,4 @@ class SystemIO final : public IO { }; } -#endif //HIDRA2_SYSTEM_WRAPPERS__SYSTEM_IO_H +#endif //HIDRA2_SYSTEM__SYSTEM_IO_H diff --git a/common/cpp/include/system_wrappers/io.h b/common/cpp/include/system_wrappers/io.h deleted file mode 100644 index 76fe9f1c7180f55686f104d76e10b401a8a95fef..0000000000000000000000000000000000000000 --- a/common/cpp/include/system_wrappers/io.h +++ /dev/null @@ -1,238 +0,0 @@ -#ifndef HIDRA2_SYSTEM_WRAPPERS__IO_H -#define HIDRA2_SYSTEM_WRAPPERS__IO_H - -#include <cinttypes> - -#include <string> -#include <vector> -#include <chrono> -#include <thread> - -#include "common/data_structs.h" -#include "common/error.h" - -namespace hidra2 { - - -enum class IOErrorType { - kUnknownIOError, - kBadFileNumber, - kResourceTemporarilyUnavailable, - kFileNotFound, - kReadError, - kPermissionDenied, - kUnsupportedAddressFamily, - kInvalidAddressFormat, - kAddressAlreadyInUse, - kConnectionRefused, - kConnectionResetByPeer, - kTimeout, - kFileAlreadyExists, - kNoSpaceLeft, - kSocketOperationOnNonSocket, - kInvalidMemoryAddress, - kUnableToResolveHostname, - kSocketOperationUnknownAtLevel, - kSocketOperationValueOutOfBound, - kAddressNotValid - -}; - -class IOError : public SimpleError { - private: - IOErrorType io_error_type_; - public: - IOError(const std::string& error, IOErrorType io_error_type) : SimpleError(error, ErrorType::kIOError) { - io_error_type_ = io_error_type; - } - - IOErrorType GetIOErrorType() const noexcept { - return io_error_type_; - } -}; - -class IOErrorTemplate : public SimpleErrorTemplate { - protected: - IOErrorType io_error_type_; - public: - IOErrorTemplate(const std::string& error, IOErrorType io_error_type) : SimpleErrorTemplate(error, ErrorType::kIOError) { - io_error_type_ = io_error_type; - } - - inline IOErrorType GetIOErrorType() const noexcept { - return io_error_type_; - } - - inline Error Generate() const noexcept override { - return Error(new IOError(error_, io_error_type_)); - } - - inline bool operator == (const Error& rhs) const override { - return SimpleErrorTemplate::operator==(rhs) - && GetIOErrorType() == ((IOError*)rhs.get())->GetIOErrorType(); - } -}; - -static inline std::ostream& operator<<(std::ostream& os, const IOErrorTemplate& err) { - return os << err.Text(); -} - - -namespace IOErrorTemplates { -auto const kUnknownIOError = IOErrorTemplate { - "Unknown Error", IOErrorType::kUnknownIOError -}; - -auto const kFileNotFound = IOErrorTemplate { - "No such file or directory", IOErrorType::kFileNotFound -}; -auto const kReadError = IOErrorTemplate { - "Read error", IOErrorType::kReadError -}; -auto const kBadFileNumber = IOErrorTemplate { - "Bad file number", IOErrorType::kBadFileNumber -}; -auto const kResourceTemporarilyUnavailable = IOErrorTemplate { - "Resource temporarily unavailable", IOErrorType::kResourceTemporarilyUnavailable -}; -auto const kPermissionDenied = IOErrorTemplate { - "Permission denied", IOErrorType::kPermissionDenied -}; -auto const kUnsupportedAddressFamily = IOErrorTemplate { - "Unsupported address family", IOErrorType::kUnsupportedAddressFamily -}; -auto const kInvalidAddressFormat = IOErrorTemplate { - "Invalid address format", IOErrorType::kInvalidAddressFormat -}; -auto const kAddressAlreadyInUse = IOErrorTemplate { - "Address already in use", IOErrorType::kAddressAlreadyInUse -}; -auto const kConnectionRefused = IOErrorTemplate { - "Connection refused", IOErrorType::kConnectionRefused -}; -auto const kConnectionResetByPeer = IOErrorTemplate { - "kConnectionResetByPeer", IOErrorType::kConnectionResetByPeer -}; -auto const kTimeout = IOErrorTemplate { - "kTimeout", IOErrorType::kTimeout -}; -auto const kFileAlreadyExists = IOErrorTemplate { - "kFileAlreadyExists", IOErrorType::kFileAlreadyExists -}; -auto const kNoSpaceLeft = IOErrorTemplate { - "kNoSpaceLeft", IOErrorType::kNoSpaceLeft -}; -auto const kSocketOperationOnNonSocket = IOErrorTemplate { - "kSocketOperationOnNonSocket", IOErrorType::kSocketOperationOnNonSocket -}; -auto const kInvalidMemoryAddress = IOErrorTemplate { - "kInvalidMemoryAddress", IOErrorType::kInvalidMemoryAddress -}; -auto const kUnableToResolveHostname = IOErrorTemplate { - "kUnableToResolveHostname", IOErrorType::kUnableToResolveHostname -}; -auto const kSocketOperationUnknownAtLevel = IOErrorTemplate { - "kSocketOperationUnknownAtLevel", IOErrorType::kSocketOperationUnknownAtLevel -}; - -auto const kSocketOperationValueOutOfBound = IOErrorTemplate { - "kSocketOperationValueOutOfBound", IOErrorType::kSocketOperationValueOutOfBound -}; - -auto const kAddressNotValid = IOErrorTemplate { - "Address not valid", IOErrorType::kAddressNotValid -}; - -} - -//Need to be "enum" since multiple flags are allowed -enum FileOpenMode { - IO_OPEN_MODE_READ = 1 << 0, - IO_OPEN_MODE_WRITE = 1 << 1, - IO_OPEN_MODE_RW = IO_OPEN_MODE_READ | IO_OPEN_MODE_WRITE, - IO_OPEN_MODE_CREATE = 1 << 2, - IO_OPEN_MODE_CREATE_AND_FAIL_IF_EXISTS = 1 << 3, - /** - * Will set the length of a file to 0 - * Only works if file is open with READ and WRITE mode - */ - IO_OPEN_MODE_SET_LENGTH_0 = 1 << 4, -}; - -enum class AddressFamilies { - INET, -}; - -enum class SocketTypes { - STREAM, -}; - -enum class SocketProtocols { - IP, -}; - -typedef int FileDescriptor; -typedef int SocketDescriptor; - -class IO { - public: - - /* - * Special - */ - virtual std::unique_ptr<std::thread> NewThread (std::function<void()> function) const = 0; - - /* - * Network - */ - virtual SocketDescriptor CreateSocket(AddressFamilies address_family, SocketTypes socket_type, - SocketProtocols socket_protocol, Error* err) const = 0; - virtual void Listen(SocketDescriptor socket_fd, int backlog, Error* err) const = 0; - virtual void InetBind(SocketDescriptor socket_fd, const std::string& address, Error* err) const = 0; - virtual SocketDescriptor CreateAndBindIPTCPSocketListener(const std::string& address, int backlog, - Error* err) const = 0; - virtual std::unique_ptr<std::tuple<std::string, SocketDescriptor>> InetAcceptConnection(SocketDescriptor socket_fd, - Error* err) const = 0; - virtual std::string ResolveHostnameToIp(const std::string& hostname, Error* err) const = 0; - virtual void InetConnect(SocketDescriptor socket_fd, const std::string& address, Error* err) const = 0; - virtual SocketDescriptor CreateAndConnectIPTCPSocket(const std::string& address, Error* err) const = 0; - virtual size_t Receive(SocketDescriptor socket_fd, void* buf, size_t length, Error* err) const = 0; - virtual size_t ReceiveWithTimeout(SocketDescriptor socket_fd, - void* buf, - size_t length, - long timeout_in_usec, - Error* err) const = 0; - virtual size_t Send(SocketDescriptor socket_fd, const void* buf, size_t length, Error* err) const = 0; - - virtual void Skip(SocketDescriptor socket_fd, size_t length, Error* err) const = 0; - /** - * @param err Since CloseSocket if often used in an error case, it's able to accept err as nullptr. - */ - virtual void CloseSocket(SocketDescriptor socket_fd, Error* err) const = 0; - - /* - * Filesystem - */ - virtual FileDescriptor Open (const std::string& filename, int open_flags, Error* err) const = 0; - /** - * @param err Since Close if often used in an error case, it's able to accept err as nullptr. - */ - virtual void Close (FileDescriptor fd, Error* err) const = 0; - - virtual size_t Read (FileDescriptor fd, void* buf, size_t length, Error* err) const = 0; - virtual size_t Write (FileDescriptor fd, const void* buf, size_t length, Error* err) const = 0; - - virtual Error WriteDataToFile (const std::string& fname, const FileData& data, size_t length) const = 0; - - virtual void CreateNewDirectory (const std::string& directory_name, Error* err) const = 0; - virtual FileData GetDataFromFile (const std::string& fname, uint64_t fsize, Error* err) const = 0; - virtual void CollectFileInformationRecursively(const std::string& path, std::vector<FileInfo>* files, - Error* err) const = 0; - virtual std::vector<FileInfo> FilesInFolder (const std::string& folder, Error* err) const = 0; - virtual std::string ReadFileToString (const std::string& fname, Error* err) const = 0; - -}; - -} - -#endif //HIDRA2_SYSTEM_WRAPPERS__IO_H diff --git a/common/cpp/include/unittests/MockIO.h b/common/cpp/include/unittests/MockIO.h index 262245a8b77c1708c454b99f35be7ef0652e8f1b..9096628863324fe37f42a00233aadd5ac33a1091 100644 --- a/common/cpp/include/unittests/MockIO.h +++ b/common/cpp/include/unittests/MockIO.h @@ -4,7 +4,7 @@ #include <gtest/gtest.h> #include <gmock/gmock.h> -#include "system_wrappers/io.h" +#include "system/io.h" namespace hidra2 { class MockIO : public IO { public: diff --git a/common/cpp/src/json_parser/rapid_json.cpp b/common/cpp/src/json_parser/rapid_json.cpp index 6d5d65b758a4d6253e91649c9ac8418b3f93382f..09b62116bd87b69af61de26378efc5beed4a3a2f 100644 --- a/common/cpp/src/json_parser/rapid_json.cpp +++ b/common/cpp/src/json_parser/rapid_json.cpp @@ -3,7 +3,7 @@ using namespace rapidjson; -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" namespace hidra2 { diff --git a/common/cpp/src/json_parser/rapid_json.h b/common/cpp/src/json_parser/rapid_json.h index 6f55934c2a159eb8746a1132669e6f58c0b31e70..661d695fc345ad4d9e32db439227e9202dda6b2c 100644 --- a/common/cpp/src/json_parser/rapid_json.h +++ b/common/cpp/src/json_parser/rapid_json.h @@ -3,7 +3,7 @@ #include "rapidjson/document.h" #include "common/error.h" -#include "system_wrappers/io.h" +#include "system/io.h" namespace hidra2 { diff --git a/common/cpp/src/system_io/io_factory.cpp b/common/cpp/src/system_io/io_factory.cpp index 116f87e9bb9cfa3d418faa34a481e3aa997c3b44..b30384adb85d8d992105572e7b446a2e648e1997 100644 --- a/common/cpp/src/system_io/io_factory.cpp +++ b/common/cpp/src/system_io/io_factory.cpp @@ -1,5 +1,5 @@ -#include "system_wrappers/system_io.h" -#include "system_wrappers/io_factory.h" +#include "system/system_io.h" +#include "system/io_factory.h" namespace hidra2 { diff --git a/common/cpp/src/system_io/system_io.cpp b/common/cpp/src/system_io/system_io.cpp index d91eda9a4c508c78cd88f5ce69d7482853291946..a6086681ede9b213ba4e5a35b8c247bd7ff0a36d 100644 --- a/common/cpp/src/system_io/system_io.cpp +++ b/common/cpp/src/system_io/system_io.cpp @@ -6,7 +6,6 @@ #include <cstring> #include <algorithm> -#include <system_wrappers/system_io.h> #if defined(__linux__) || defined (__APPLE__) #include <sys/socket.h> @@ -19,6 +18,8 @@ #include <sys/select.h> #endif +#include "system/system_io.h" + namespace hidra2 { diff --git a/common/cpp/src/system_io/system_io_linux.cpp b/common/cpp/src/system_io/system_io_linux.cpp index 4bbb6cac071b62d51a445e3eac67a9081d7ad6d9..004947186080e1d6b53523c0cfbf0799b5e52639 100644 --- a/common/cpp/src/system_io/system_io_linux.cpp +++ b/common/cpp/src/system_io/system_io_linux.cpp @@ -1,4 +1,3 @@ -#include "system_wrappers/system_io.h" #include <cstring> @@ -12,11 +11,13 @@ #include <zconf.h> #include <netdb.h> +#include "system/system_io.h" + + using std::string; using std::vector; using std::chrono::system_clock; - namespace hidra2 { /** diff --git a/common/cpp/src/system_io/system_io_windows.cpp b/common/cpp/src/system_io/system_io_windows.cpp index 19f9e377e784d205dc7d07ee7532f03c59408a8d..de37715511c647da449d85c7649a0c96560157d4 100644 --- a/common/cpp/src/system_io/system_io_windows.cpp +++ b/common/cpp/src/system_io/system_io_windows.cpp @@ -1,4 +1,4 @@ -#include "system_wrappers/system_io.h" +#include "system/system_io.h" #include <cstring> #include <sys/stat.h> diff --git a/examples/producer/dummy-data-producer/dummy_data_producer.cpp b/examples/producer/dummy-data-producer/dummy_data_producer.cpp index be419bf09712e058604fb75bf8a02697e5cff366..a9476d52422276874a68b692957d4d034c19191b 100644 --- a/examples/producer/dummy-data-producer/dummy_data_producer.cpp +++ b/examples/producer/dummy-data-producer/dummy_data_producer.cpp @@ -1,10 +1,10 @@ - -#include <producer/producer.h> #include <iostream> #include <chrono> #include <vector> #include <tuple> +#include "hidra2_producer.h" + using std::chrono::high_resolution_clock; typedef std::tuple<std::string, size_t, uint64_t> ArgumentTuple; diff --git a/producer/api/include/hidra2_producer.h b/producer/api/include/hidra2_producer.h new file mode 100644 index 0000000000000000000000000000000000000000..34f852058baa7de1d4b0a986c9ff9f7f6764acbf --- /dev/null +++ b/producer/api/include/hidra2_producer.h @@ -0,0 +1,6 @@ +#ifndef HIDRA2_HIDRA2_PRODUCER_H +#define HIDRA2_HIDRA2_PRODUCER_H + +#include "producer/producer.h" + +#endif //HIDRA2_HIDRA2_PRODUCER_H diff --git a/producer/api/src/producer_impl.cpp b/producer/api/src/producer_impl.cpp index 69f785c667505cd59daebc25ef7779a654cca361..8ca887112c0593956431a7015cd7f0eff7059482 100644 --- a/producer/api/src/producer_impl.cpp +++ b/producer/api/src/producer_impl.cpp @@ -2,7 +2,7 @@ #include <cstring> #include "producer_impl.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" namespace hidra2 { @@ -20,7 +20,7 @@ ProducerStatus ProducerImpl::GetStatus() const { return status_; } -Error ProducerImpl::InitializeSocketToReceiver_(const std::string& receiver_address) { +Error ProducerImpl::InitializeSocketToReceiver(const std::string& receiver_address) { Error err; FileDescriptor fd = io__->CreateAndConnectIPTCPSocket(receiver_address, &err); if(err != nullptr) { @@ -32,11 +32,11 @@ Error ProducerImpl::InitializeSocketToReceiver_(const std::string& receiver_addr } Error ProducerImpl::ConnectToReceiver(const std::string& receiver_address) { - if(client_fd_ != -1 && status_ != ProducerStatus::kDisconnected) { + if(status_ != ProducerStatus::kDisconnected) { return ProducerErrorTemplates::kAlreadyConnected.Generate(); } - auto error = InitializeSocketToReceiver_(receiver_address); + auto error = InitializeSocketToReceiver(receiver_address); if(error) { status_ = ProducerStatus::kDisconnected; return error; diff --git a/producer/api/src/producer_impl.h b/producer/api/src/producer_impl.h index bc1fc280a257ef5406c98bb0573c4b141ca33d7c..30642ab1af1fe9704aef319604e4036285cb9904 100644 --- a/producer/api/src/producer_impl.h +++ b/producer/api/src/producer_impl.h @@ -3,7 +3,7 @@ #include <string> #include <common/networking.h> -#include <system_wrappers/io.h> +#include <system/io.h> #include "producer/producer.h" namespace hidra2 { @@ -16,7 +16,7 @@ class ProducerImpl : public Producer { ProducerStatus status_ = ProducerStatus::kDisconnected; - Error InitializeSocketToReceiver_(const std::string& receiver_address); + Error InitializeSocketToReceiver(const std::string& receiver_address); GenericNetworkRequestHeader GenerateNextSendRequest(uint64_t file_id, size_t file_size); Error SendHeaderAndData(const GenericNetworkRequestHeader& header, const void* data, size_t file_size); Error ReceiveResponce(); diff --git a/producer/api/unittests/test_producer.cpp b/producer/api/unittests/test_producer.cpp index 8345d264b04cc52f4ead302fe4cffc08bf561e59..91b1f691a6a541cef3da6f69a694c87353574b20 100644 --- a/producer/api/unittests/test_producer.cpp +++ b/producer/api/unittests/test_producer.cpp @@ -1,13 +1,15 @@ #include <gtest/gtest.h> -#include <producer/producer.h> #include <unittests/MockIO.h> +#include "producer/producer.h" +#include "../src/producer_impl.h" using ::testing::Ne; namespace { TEST(CreateProducer, PointerIsNotNullptr) { std::unique_ptr<hidra2::Producer> producer = hidra2::Producer::Create(); + ASSERT_THAT(dynamic_cast<hidra2::ProducerImpl*>(producer.get()), Ne(nullptr)); ASSERT_THAT(producer.get(), Ne(nullptr)); } diff --git a/producer/api/unittests/test_producer_impl.cpp b/producer/api/unittests/test_producer_impl.cpp index 2bb141400881133963a6efd3bd3c67af3f6ba751..3fdbe4688d1c8bc79120a814170b8ac7461bc5b0 100644 --- a/producer/api/unittests/test_producer_impl.cpp +++ b/producer/api/unittests/test_producer_impl.cpp @@ -3,7 +3,7 @@ #include <unittests/MockIO.h> #include "common/error.h" -#include "system_wrappers/io.h" +#include "system/io.h" #include "producer/producer.h" #include "../src/producer_impl.h" diff --git a/receiver/src/connection.cpp b/receiver/src/connection.cpp index 7567d319efda226c3efbf894171b187bdb4a543e..e734f417a604873d33b32a3b908d8afd96be5d31 100644 --- a/receiver/src/connection.cpp +++ b/receiver/src/connection.cpp @@ -2,7 +2,7 @@ #include <assert.h> #include "connection.h" #include "receiver_error.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" namespace hidra2 { diff --git a/receiver/src/connection.h b/receiver/src/connection.h index 23e66b199c476ac8614841eeef4e8b4ba3489a66..c03d85c03b9c0cf8bd9eb07e5654c9d28fffdf5c 100644 --- a/receiver/src/connection.h +++ b/receiver/src/connection.h @@ -12,7 +12,7 @@ #include <vector> #include "common/networking.h" -#include "system_wrappers/io.h" +#include "system/io.h" #include "request.h" namespace hidra2 { diff --git a/receiver/src/receiver.cpp b/receiver/src/receiver.cpp index d384ac936428eee50e8175bd6a9cf33bbfbe2665..01978c842248bbb1b80719f497afe2fdecedbb17 100644 --- a/receiver/src/receiver.cpp +++ b/receiver/src/receiver.cpp @@ -3,7 +3,7 @@ #include "receiver.h" #include "receiver_error.h" #include "connection.h" -#include <system_wrappers/io_factory.h> +#include <system/io_factory.h> namespace hidra2 { diff --git a/receiver/src/request.cpp b/receiver/src/request.cpp index 8d4b90d2e0c8d13ba538964d29845a7bfa81ed28..ac86cac6c813e2067081c19d8b43ac5fbdd20631 100644 --- a/receiver/src/request.cpp +++ b/receiver/src/request.cpp @@ -1,5 +1,5 @@ #include "request.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" namespace hidra2 { diff --git a/receiver/src/request.h b/receiver/src/request.h index dd45a8c7446057dbfe60a7e95a0ae045425adeef..6c8845d58be0728061f22a9bd249e46681edcd24 100644 --- a/receiver/src/request.h +++ b/receiver/src/request.h @@ -3,7 +3,7 @@ #include "receiver_error.h" #include "common/networking.h" -#include "system_wrappers/io.h" +#include "system/io.h" #include "request_handler.h" #include "request_handler_file_write.h" diff --git a/receiver/src/request_handler_file_write.cpp b/receiver/src/request_handler_file_write.cpp index 346416db68fe68476425db0443fb534a797954c3..6af7536776542924b1d5544a293d54953f153461 100644 --- a/receiver/src/request_handler_file_write.cpp +++ b/receiver/src/request_handler_file_write.cpp @@ -1,5 +1,5 @@ #include "request_handler_file_write.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" #include "request.h" namespace hidra2 { diff --git a/receiver/src/request_handler_file_write.h b/receiver/src/request_handler_file_write.h index fb56d4e25c5a3e313de22cab655e2d9e72b9aed8..c38daaabc122e946e1581f5390e945ef104e6af9 100644 --- a/receiver/src/request_handler_file_write.h +++ b/receiver/src/request_handler_file_write.h @@ -3,7 +3,7 @@ #include "request_handler.h" -#include "system_wrappers/io.h" +#include "system/io.h" namespace hidra2 { diff --git a/tests/system_io/ip_tcp_network/ip_tcp_network.cpp b/tests/system_io/ip_tcp_network/ip_tcp_network.cpp index 9d077e9d2001134f4b66992a92397ba199e9a36b..8f5b9c1af62a47b2b0ed56d12f251a6e8c64a99d 100644 --- a/tests/system_io/ip_tcp_network/ip_tcp_network.cpp +++ b/tests/system_io/ip_tcp_network/ip_tcp_network.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include <chrono> #include <thread> #include <future> diff --git a/tests/system_io/ip_tcp_network_speedtest/ip_tcp_network_speedtest.cpp b/tests/system_io/ip_tcp_network_speedtest/ip_tcp_network_speedtest.cpp index 32474803328dfda0735438832fdb5996b8ba3937..1b234f469bf3304f243fb1c13e57cc573273bff0 100644 --- a/tests/system_io/ip_tcp_network_speedtest/ip_tcp_network_speedtest.cpp +++ b/tests/system_io/ip_tcp_network_speedtest/ip_tcp_network_speedtest.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include <future> #include <iomanip> diff --git a/tests/system_io/read_file_content/read_file_content.cpp b/tests/system_io/read_file_content/read_file_content.cpp index 065e94328e4523ff40b341ec42de6e3844ad1365..538fd0b237a395d61e903723dce5fca31e0be91f 100644 --- a/tests/system_io/read_file_content/read_file_content.cpp +++ b/tests/system_io/read_file_content/read_file_content.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include "testing.h" diff --git a/tests/system_io/read_folder_content/read_folder_content.cpp b/tests/system_io/read_folder_content/read_folder_content.cpp index ffc4588eef9c24ebb316b35579824707a4e403a3..5f753075f138885f4697bb92602450c13f55da9f 100644 --- a/tests/system_io/read_folder_content/read_folder_content.cpp +++ b/tests/system_io/read_folder_content/read_folder_content.cpp @@ -1,6 +1,6 @@ #include <iostream> -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" #include "testing.h" using hidra2::IO; diff --git a/tests/system_io/read_string_from_file/read_string_from_file.cpp b/tests/system_io/read_string_from_file/read_string_from_file.cpp index 6a41e2e76ec4f39322c9f3118d0f0b620dbd412d..371403f419cec9c9c03ff76e60ba32f078db0352 100644 --- a/tests/system_io/read_string_from_file/read_string_from_file.cpp +++ b/tests/system_io/read_string_from_file/read_string_from_file.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include "testing.h" diff --git a/tests/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp b/tests/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp index e031b3f4e15e021e8bf6dfd7cd727defce566495..d4f693e425ddbde49590e9a31aac24470c6c4691 100644 --- a/tests/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp +++ b/tests/system_io/resolve_hostname_to_ip/resolve_hostname_to_ip.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include "testing.h" diff --git a/tests/system_io/write_data_to_file/write_data_to_file.cpp b/tests/system_io/write_data_to_file/write_data_to_file.cpp index de329c7b5d13574ad42430e2bedcd62ac1670267..b50085b8e4fcd625fdd9dcc4a981856787585170 100644 --- a/tests/system_io/write_data_to_file/write_data_to_file.cpp +++ b/tests/system_io/write_data_to_file/write_data_to_file.cpp @@ -1,5 +1,5 @@ #include <iostream> -#include <system_wrappers/system_io.h> +#include <system/system_io.h> #include "testing.h" diff --git a/worker/api/cpp/src/folder_data_broker.cpp b/worker/api/cpp/src/folder_data_broker.cpp index 851fbce7db1f47f3fb116672e99a5e8cad8dd757..5fbdf6775aa68d1b8915c1d774d426422a9756d1 100644 --- a/worker/api/cpp/src/folder_data_broker.cpp +++ b/worker/api/cpp/src/folder_data_broker.cpp @@ -1,6 +1,6 @@ #include "folder_data_broker.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" namespace hidra2 { diff --git a/worker/api/cpp/src/folder_data_broker.h b/worker/api/cpp/src/folder_data_broker.h index 4ffe1b21177d770253bda50aae9c06567f5ad93b..4fbec5df62f78da17423601b30cdfb143174030c 100644 --- a/worker/api/cpp/src/folder_data_broker.h +++ b/worker/api/cpp/src/folder_data_broker.h @@ -6,7 +6,7 @@ #include <string> #include <mutex> -#include "system_wrappers/io.h" +#include "system/io.h" namespace hidra2 { diff --git a/worker/api/cpp/src/server_data_broker.cpp b/worker/api/cpp/src/server_data_broker.cpp index fca1ce551876c7adec88d3a82c1e7710fbc0e539..733b4865e45d7e2512d556d5548161eefb9bd25a 100644 --- a/worker/api/cpp/src/server_data_broker.cpp +++ b/worker/api/cpp/src/server_data_broker.cpp @@ -1,5 +1,5 @@ #include "server_data_broker.h" -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" #include "curl_http_client.h" namespace hidra2 { diff --git a/worker/api/cpp/src/server_data_broker.h b/worker/api/cpp/src/server_data_broker.h index d77fff8bfddc4ea7e204e5b1a5c823a774967230..d90b9f5579be3bcc0288a3e05a3c1d8c11b8e778 100644 --- a/worker/api/cpp/src/server_data_broker.h +++ b/worker/api/cpp/src/server_data_broker.h @@ -2,7 +2,7 @@ #define HIDRA2_SERVER_DATA_BROKER_H #include "worker/data_broker.h" -#include "system_wrappers/io.h" +#include "system/io.h" #include "http_client.h" diff --git a/worker/api/cpp/unittests/test_folder_broker.cpp b/worker/api/cpp/unittests/test_folder_broker.cpp index a70c4845b6187040a6cc55ad27f474c3c1f30f1c..d6dec1c045a688bcefd188ea7841636c68d54887 100644 --- a/worker/api/cpp/unittests/test_folder_broker.cpp +++ b/worker/api/cpp/unittests/test_folder_broker.cpp @@ -3,8 +3,8 @@ #include "gtest/gtest.h" #include "worker/data_broker.h" -#include "system_wrappers/io.h" -#include "system_wrappers/system_io.h" +#include "system/io.h" +#include "system/system_io.h" #include "../src/folder_data_broker.h" using hidra2::DataBrokerFactory; diff --git a/worker/api/cpp/unittests/test_server_broker.cpp b/worker/api/cpp/unittests/test_server_broker.cpp index f9dd28e495de4055b4710b867aaa8147ba35f4e2..453423f51e947054bf496b51c0922f7c964d11ac 100644 --- a/worker/api/cpp/unittests/test_server_broker.cpp +++ b/worker/api/cpp/unittests/test_server_broker.cpp @@ -2,8 +2,8 @@ #include "gtest/gtest.h" #include "worker/data_broker.h" -#include "system_wrappers/io.h" -#include "system_wrappers/system_io.h" +#include "system/io.h" +#include "system/system_io.h" #include "../src/server_data_broker.h" #include "../src/curl_http_client.h" #include "unittests/MockIO.h" diff --git a/worker/tools/folder_to_db/src/folder_db_importer.cpp b/worker/tools/folder_to_db/src/folder_db_importer.cpp index eb2494f946cd6d4ff104b1b566c83c4b874ae666..15998cb131943d6b3d0e39f53b54d01c6919708c 100644 --- a/worker/tools/folder_to_db/src/folder_db_importer.cpp +++ b/worker/tools/folder_to_db/src/folder_db_importer.cpp @@ -3,7 +3,7 @@ #include <future> #include <algorithm> -#include "system_wrappers/io_factory.h" +#include "system/io_factory.h" #include "database/database.h" diff --git a/worker/tools/folder_to_db/src/folder_db_importer.h b/worker/tools/folder_to_db/src/folder_db_importer.h index aecadd203618af74b16bb46ed6aa88cc110750b7..b1d0ee04cbefa89ffd42783aaf956a954bb160c8 100644 --- a/worker/tools/folder_to_db/src/folder_db_importer.h +++ b/worker/tools/folder_to_db/src/folder_db_importer.h @@ -6,7 +6,7 @@ #include <future> -#include "system_wrappers/io.h" +#include "system/io.h" #include "database/database.h" #include "common/error.h" namespace hidra2 { diff --git a/worker/tools/folder_to_db/unittests/test_folder_to_db.cpp b/worker/tools/folder_to_db/unittests/test_folder_to_db.cpp index 196ff2a7c223876182931f85a48b9ee89e292390..4c43d081de3a213acc8eb291f9cc1f28b20f1f16 100644 --- a/worker/tools/folder_to_db/unittests/test_folder_to_db.cpp +++ b/worker/tools/folder_to_db/unittests/test_folder_to_db.cpp @@ -2,8 +2,8 @@ #include "gtest/gtest.h" #include <thread> -#include "system_wrappers/io.h" -#include "system_wrappers/system_io.h" +#include "system/io.h" +#include "system/system_io.h" #include "database/database.h"