Skip to content

Commit

Permalink
Draft of IO streams and (De)serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn authored and vigsterkr committed Jul 23, 2018
1 parent 1be1dbb commit d5557dc
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 0 deletions.
21 changes: 21 additions & 0 deletions 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 <shogun/io/serialization/Deserializer.h>

using namespace shogun;

CDeserializer::CDeserializer() : m_stream(nullptr)
{
}

CDeserializer::~CDeserializer()
{
}

void CDeserializer::attach(Some<CInputStream> stream)
{
m_stream = stream;
}
26 changes: 26 additions & 0 deletions 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 <shogun/base/SGObject.h>
#include <shogun/io/stream/InputStream.h>

namespace shogun
{
class CDeserializer : public CSGObject
{
public:
CDeserializer();
virtual ~CDeserializer();
virtual void attach(Some<CInputStream> stream) = 0;
virtual Some<CSGObject> read() = 0;

private:
Some<CInputStream> m_stream;
};
}

#endif
21 changes: 21 additions & 0 deletions 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 <shogun/io/serialization/Serializer.h>

using namespace shogun;

CSerializer::CSerializer() : m_stream(nullptr)
{
}

CSerializer::~CSerializer()
{
}

void CSerializer::attach(Some<COutputStream> stream)
{
m_stream = stream;
}
26 changes: 26 additions & 0 deletions 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 <shogun/base/SGObject.h>
#include <shogun/io/stream/OutputStream.h>

namespace shogun
{
class CSerializer : public CSGObject
{
public:
CSerializer();
virtual ~CSerializer();
virtual void attach(Some<COutputStream> stream);
virtual void write(Some<CSGObject> object) = 0;

private:
Some<COutputStream> m_stream;
};
}

#endif
16 changes: 16 additions & 0 deletions 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 <shogun/io/stream/InputStream.h>

using namespace shogun;

CInputStream::CInputStream()
{
}

CInputStream::~CInputStream()
{
}
22 changes: 22 additions & 0 deletions 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 <shogun/base/SGObject.h>

namespace shogun
{
class CInputStream : public CSGObject
{
public:
CInputStream();
virtual ~CInputStream();

virtual void read(void* buffer, size_t size) = 0;
};
}

#endif
16 changes: 16 additions & 0 deletions 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 <shogun/io/stream/OutputStream.h>

using namespace shogun;

COutputStream::COutputStream()
{
}

COutputStream::~COutputStream()
{
}
22 changes: 22 additions & 0 deletions 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 <shogun/base/SGObject.h>

namespace shogun
{
class COutputStream : public CSGObject
{
public:
COutputStream();
virtual ~COutputStream();

virtual void write(void* buffer, size_t size) = 0;
};
}

#endif

0 comments on commit d5557dc

Please sign in to comment.