NOTICK - Fix namespace allocation for C++ Serialiser

Now things are working for the most part, move the readers into their
own internal namespace. Also start creating an actual separation of the
interface and the implementation with some Interface classes at the
non internal level.
This commit is contained in:
Katelyn Baker
2019-08-19 20:10:57 +01:00
parent 101d978050
commit eb8eaba1d7
27 changed files with 527 additions and 365 deletions

View File

@ -1,32 +0,0 @@
#pragma once
/******************************************************************************/
#include <map>
#include <set>
#include "types.h"
#include "amqp/schema/Schema.h"
#include "amqp/schema/Envelope.h"
#include "amqp/schema/Composite.h"
#include "amqp/consumer/PropertyReader.h"
#include "amqp/consumer/CompositeReader.h"
/******************************************************************************/
class ICompositeFactory {
public :
using SchemaPtr = uPtr<amqp::internal::schema::Schema>;
ICompositeFactory() = default;
virtual ~ICompositeFactory() = default;
virtual void process (const SchemaPtr &) = 0;
virtual const std::shared_ptr<amqp::Reader> byType (const std::string &) = 0;
virtual const std::shared_ptr<amqp::Reader> byDescriptor (const std::string &) = 0;
};
/******************************************************************************/

View File

@ -0,0 +1,15 @@
#pragma once
/******************************************************************************/
namespace amqp {
class AMQPDescribed {
public :
virtual ~AMQPDescribed() { }
};
}
/******************************************************************************/

View File

@ -0,0 +1,33 @@
#pragma once
/******************************************************************************/
#include "types.h"
#include "amqp/schema/ISchema.h"
#include "amqp/reader/IReader.h"
/******************************************************************************/
namespace amqp {
template <class SchemaIterator>
class ICompositeFactory {
public :
using SchemaType = schema::ISchema<SchemaIterator>;
using ReaderType = reader::IReader<SchemaIterator>;
ICompositeFactory() = default;
virtual ~ICompositeFactory() = default;
virtual void process (const SchemaType &) = 0;
virtual const std::shared_ptr<ReaderType> byType (const std::string &) = 0;
virtual const std::shared_ptr<ReaderType> byDescriptor (const std::string &) = 0;
};
}
/******************************************************************************/

View File

@ -0,0 +1,75 @@
#pragma once
/******************************************************************************/
#include <any>
#include "amqp/AMQPDescribed.h"
#include "amqp/schema/Schema.h"
/******************************************************************************
*
* Forward declarations
*
******************************************************************************/
struct pn_data_t;
/******************************************************************************
*
* class amqp::reader::IValue
*
******************************************************************************/
/**
* Used by the dump method on all instantiated instances of amqp readers
* it represents the ability to pull out a value from the blob as determined
* by the reader type and convert it to a string formatted nicely as JSON
*/
namespace amqp::reader {
class IValue {
public :
virtual std::string dump() const = 0;
virtual ~IValue() = default;
};
}
/******************************************************************************
*
* class ampq::reader::IReader
*
******************************************************************************/
namespace amqp::reader {
template <class SchemaIterator>
class IReader {
public :
using SchemaType = amqp::schema::ISchema<SchemaIterator>;
virtual ~IReader() = default;
virtual const std::string & name() const = 0;
virtual const std::string & type() const = 0;
virtual std::any read (pn_data_t *) const = 0;
virtual std::string readString (pn_data_t *) const = 0;
virtual std::unique_ptr<IValue> dump(
const std::string &,
pn_data_t *,
const SchemaType &) const = 0;
virtual std::unique_ptr<IValue> dump(
pn_data_t *,
const SchemaType &) const = 0;
};
}
/******************************************************************************/

View File

@ -0,0 +1,16 @@
#pragma once
#include "types.h"
#include "amqp/AMQPDescribed.h"
namespace amqp::schema {
template <class Iterator>
class ISchema {
public :
virtual Iterator fromType (const std::string &) const = 0;
virtual Iterator fromDescriptor (const std::string &) const = 0;
};
}