From d5557dc15feb2caa7949ec8dfef82edd02c9abce Mon Sep 17 00:00:00 2001 From: Sergey Lisitsyn Date: Sat, 14 Apr 2018 12:29:42 +0200 Subject: [PATCH] Draft of IO streams and (De)serializers --- src/shogun/io/serialization/Deserializer.cpp | 21 ++++++++++++++++ src/shogun/io/serialization/Deserializer.h | 26 ++++++++++++++++++++ src/shogun/io/serialization/Serializer.cpp | 21 ++++++++++++++++ src/shogun/io/serialization/Serializer.h | 26 ++++++++++++++++++++ src/shogun/io/stream/InputStream.cpp | 16 ++++++++++++ src/shogun/io/stream/InputStream.h | 22 +++++++++++++++++ src/shogun/io/stream/OutputStream.cpp | 16 ++++++++++++ src/shogun/io/stream/OutputStream.h | 22 +++++++++++++++++ 8 files changed, 170 insertions(+) create mode 100644 src/shogun/io/serialization/Deserializer.cpp create mode 100644 src/shogun/io/serialization/Deserializer.h create mode 100644 src/shogun/io/serialization/Serializer.cpp create mode 100644 src/shogun/io/serialization/Serializer.h create mode 100644 src/shogun/io/stream/InputStream.cpp create mode 100644 src/shogun/io/stream/InputStream.h create mode 100644 src/shogun/io/stream/OutputStream.cpp create mode 100644 src/shogun/io/stream/OutputStream.h diff --git a/src/shogun/io/serialization/Deserializer.cpp b/src/shogun/io/serialization/Deserializer.cpp new file mode 100644 index 00000000000..4b0dbd776e5 --- /dev/null +++ b/src/shogun/io/serialization/Deserializer.cpp @@ -0,0 +1,21 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ + +#include + +using namespace shogun; + +CDeserializer::CDeserializer() : m_stream(nullptr) +{ +} + +CDeserializer::~CDeserializer() +{ +} + +void CDeserializer::attach(Some stream) +{ + m_stream = stream; +} diff --git a/src/shogun/io/serialization/Deserializer.h b/src/shogun/io/serialization/Deserializer.h new file mode 100644 index 00000000000..691b2c6c149 --- /dev/null +++ b/src/shogun/io/serialization/Deserializer.h @@ -0,0 +1,26 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ +#ifndef __DESERIALIZER_H__ +#define __DESERIALIZER_H__ + +#include +#include + +namespace shogun +{ + class CDeserializer : public CSGObject + { + public: + CDeserializer(); + virtual ~CDeserializer(); + virtual void attach(Some stream) = 0; + virtual Some read() = 0; + + private: + Some m_stream; + }; +} + +#endif diff --git a/src/shogun/io/serialization/Serializer.cpp b/src/shogun/io/serialization/Serializer.cpp new file mode 100644 index 00000000000..6312b90451c --- /dev/null +++ b/src/shogun/io/serialization/Serializer.cpp @@ -0,0 +1,21 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ + +#include + +using namespace shogun; + +CSerializer::CSerializer() : m_stream(nullptr) +{ +} + +CSerializer::~CSerializer() +{ +} + +void CSerializer::attach(Some stream) +{ + m_stream = stream; +} diff --git a/src/shogun/io/serialization/Serializer.h b/src/shogun/io/serialization/Serializer.h new file mode 100644 index 00000000000..171824eefde --- /dev/null +++ b/src/shogun/io/serialization/Serializer.h @@ -0,0 +1,26 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ +#ifndef __SERIALIZER_H__ +#define __SERIALIZER_H__ + +#include +#include + +namespace shogun +{ + class CSerializer : public CSGObject + { + public: + CSerializer(); + virtual ~CSerializer(); + virtual void attach(Some stream); + virtual void write(Some object) = 0; + + private: + Some m_stream; + }; +} + +#endif diff --git a/src/shogun/io/stream/InputStream.cpp b/src/shogun/io/stream/InputStream.cpp new file mode 100644 index 00000000000..37cabb937d3 --- /dev/null +++ b/src/shogun/io/stream/InputStream.cpp @@ -0,0 +1,16 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ + +#include + +using namespace shogun; + +CInputStream::CInputStream() +{ +} + +CInputStream::~CInputStream() +{ +} diff --git a/src/shogun/io/stream/InputStream.h b/src/shogun/io/stream/InputStream.h new file mode 100644 index 00000000000..d799bda9175 --- /dev/null +++ b/src/shogun/io/stream/InputStream.h @@ -0,0 +1,22 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ +#ifndef __INPUT_STREAM_H__ +#define __INPUT_STREAM_H__ + +#include + +namespace shogun +{ + class CInputStream : public CSGObject + { + public: + CInputStream(); + virtual ~CInputStream(); + + virtual void read(void* buffer, size_t size) = 0; + }; +} + +#endif diff --git a/src/shogun/io/stream/OutputStream.cpp b/src/shogun/io/stream/OutputStream.cpp new file mode 100644 index 00000000000..c40f873e873 --- /dev/null +++ b/src/shogun/io/stream/OutputStream.cpp @@ -0,0 +1,16 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ + +#include + +using namespace shogun; + +COutputStream::COutputStream() +{ +} + +COutputStream::~COutputStream() +{ +} diff --git a/src/shogun/io/stream/OutputStream.h b/src/shogun/io/stream/OutputStream.h new file mode 100644 index 00000000000..65acc09e6d1 --- /dev/null +++ b/src/shogun/io/stream/OutputStream.h @@ -0,0 +1,22 @@ +/** This software is distributed under BSD 3-clause license (see LICENSE file). + * + * Authors: Sergey Lisitsyn + */ +#ifndef __OUTPUT_STREAM_H__ +#define __OUTPUT_STREAM_H__ + +#include + +namespace shogun +{ + class COutputStream : public CSGObject + { + public: + COutputStream(); + virtual ~COutputStream(); + + virtual void write(void* buffer, size_t size) = 0; + }; +} + +#endif