mirror of
https://github.com/corda/corda.git
synced 2024-12-18 20:47:57 +00:00
NOTICK - Move CompositeFactory into amqp::internal namespace
This commit is contained in:
parent
2ba8676013
commit
3c3f5f5e04
@ -18,7 +18,7 @@
|
|||||||
#include "amqp/descriptors/AMQPDescriptorRegistory.h"
|
#include "amqp/descriptors/AMQPDescriptorRegistory.h"
|
||||||
|
|
||||||
#include "amqp/schema/Envelope.h"
|
#include "amqp/schema/Envelope.h"
|
||||||
#include "CompositeFactory.h"
|
#include "amqp/CompositeFactory.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ data_and_stop(std::ifstream & f_, ssize_t sz) {
|
|||||||
<< *envelope << std::endl); // NOLINT
|
<< *envelope << std::endl); // NOLINT
|
||||||
}
|
}
|
||||||
|
|
||||||
CompositeFactory cf;
|
amqp::internal::CompositeFactory cf;
|
||||||
|
|
||||||
cf.process (envelope->schema());
|
cf.process (envelope->schema());
|
||||||
|
|
||||||
@ -112,4 +112,3 @@ main (int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
32
experimental/cpp-serializer/include/ICompositeFactory.h
Normal file
32
experimental/cpp-serializer/include/ICompositeFactory.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
#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;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -34,14 +36,14 @@ computeIfAbsent (
|
|||||||
if (it == map_.end()) {
|
if (it == map_.end()) {
|
||||||
DBG ("ComputeIfAbsent \"" << k_ << "\" - missing" << std::endl); // NOLINT
|
DBG ("ComputeIfAbsent \"" << k_ << "\" - missing" << std::endl); // NOLINT
|
||||||
map_[k_] = std::move(f_());
|
map_[k_] = std::move(f_());
|
||||||
DBG (" \"" << k_ << "\" - RTN: " << map_[k_]->name() << " : " << map_[k_]->type() << std::endl); // NOLINT
|
DBG (" \"" << k_ << "\" - RTN: " << map_[k_]->name() << " : " << map_[k_]->type()
|
||||||
|
<< std::endl); // NOLINT
|
||||||
assert (map_[k_]);
|
assert (map_[k_]);
|
||||||
assert (map_[k_] != nullptr);
|
assert (map_[k_] != nullptr);
|
||||||
assert (k_ == map_[k_]->type());
|
assert (k_ == map_[k_]->type());
|
||||||
|
|
||||||
return map_[k_];
|
return map_[k_];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
DBG ("ComputeIfAbsent \"" << k_ << "\" - found it" << std::endl); // NOLINT
|
DBG ("ComputeIfAbsent \"" << k_ << "\" - found it" << std::endl); // NOLINT
|
||||||
DBG (" \"" << k_ << "\" - RTN: " << map_[k_]->name() << std::endl); // NOLINT
|
DBG (" \"" << k_ << "\" - RTN: " << map_[k_]->name() << std::endl); // NOLINT
|
||||||
|
|
||||||
@ -51,6 +53,8 @@ computeIfAbsent (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
*
|
*
|
||||||
* CompositeFactory
|
* CompositeFactory
|
||||||
@ -68,9 +72,10 @@ computeIfAbsent (
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::process (const SchemaPtr & schema_) {
|
CompositeFactory::process (const SchemaPtr & schema_) {
|
||||||
for (auto i = schema_->begin() ; i != schema_->end() ; ++i) {
|
for (const auto & i : *schema_) {
|
||||||
for (const auto & j : *i) {
|
for (const auto & j : i) {
|
||||||
process(*j);
|
process(*j);
|
||||||
m_readersByDescriptor[j->descriptor()] = m_readersByType[j->name()];
|
m_readersByDescriptor[j->descriptor()] = m_readersByType[j->name()];
|
||||||
}
|
}
|
||||||
@ -80,6 +85,7 @@ CompositeFactory::process (const SchemaPtr & schema_) {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
std::shared_ptr<amqp::Reader>
|
std::shared_ptr<amqp::Reader>
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::process(
|
CompositeFactory::process(
|
||||||
const amqp::internal::schema::AMQPTypeNotation & schema_)
|
const amqp::internal::schema::AMQPTypeNotation & schema_)
|
||||||
{
|
{
|
||||||
@ -101,6 +107,7 @@ CompositeFactory::process(
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
std::shared_ptr<amqp::Reader>
|
std::shared_ptr<amqp::Reader>
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::processComposite (
|
CompositeFactory::processComposite (
|
||||||
const amqp::internal::schema::AMQPTypeNotation & type_)
|
const amqp::internal::schema::AMQPTypeNotation & type_)
|
||||||
{
|
{
|
||||||
@ -155,6 +162,7 @@ CompositeFactory::processComposite (
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
std::shared_ptr<amqp::Reader>
|
std::shared_ptr<amqp::Reader>
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::processRestricted (
|
CompositeFactory::processRestricted (
|
||||||
const amqp::internal::schema::AMQPTypeNotation & type_)
|
const amqp::internal::schema::AMQPTypeNotation & type_)
|
||||||
{
|
{
|
||||||
@ -194,6 +202,7 @@ CompositeFactory::processRestricted (
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const std::shared_ptr<amqp::Reader>
|
const std::shared_ptr<amqp::Reader>
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::byType (const std::string & type_) {
|
CompositeFactory::byType (const std::string & type_) {
|
||||||
auto it = m_readersByType.find (type_);
|
auto it = m_readersByType.find (type_);
|
||||||
|
|
||||||
@ -203,6 +212,7 @@ CompositeFactory::byType (const std::string & type_) {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const std::shared_ptr<amqp::Reader>
|
const std::shared_ptr<amqp::Reader>
|
||||||
|
amqp::internal::
|
||||||
CompositeFactory::byDescriptor (const std::string & descriptor_) {
|
CompositeFactory::byDescriptor (const std::string & descriptor_) {
|
||||||
auto it = m_readersByDescriptor.find (descriptor_);
|
auto it = m_readersByDescriptor.find (descriptor_);
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#include "ICompositeFactory.h"
|
||||||
#include "amqp/schema/Schema.h"
|
#include "amqp/schema/Schema.h"
|
||||||
#include "amqp/schema/Envelope.h"
|
#include "amqp/schema/Envelope.h"
|
||||||
#include "amqp/schema/Composite.h"
|
#include "amqp/schema/Composite.h"
|
||||||
@ -14,9 +16,10 @@
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
class CompositeFactory {
|
namespace amqp::internal {
|
||||||
|
|
||||||
|
class CompositeFactory : public ICompositeFactory {
|
||||||
private :
|
private :
|
||||||
using SchemaPtr = uPtr<amqp::internal::schema::Schema>;
|
|
||||||
using CompositePtr = uPtr<amqp::internal::schema::Composite>;
|
using CompositePtr = uPtr<amqp::internal::schema::Composite>;
|
||||||
using EnvelopePtr = uPtr<amqp::internal::schema::Envelope>;
|
using EnvelopePtr = uPtr<amqp::internal::schema::Envelope>;
|
||||||
|
|
||||||
@ -29,10 +32,11 @@ class CompositeFactory {
|
|||||||
public :
|
public :
|
||||||
CompositeFactory() = default;
|
CompositeFactory() = default;
|
||||||
|
|
||||||
void process (const SchemaPtr &);
|
void process(const SchemaPtr &) override ;
|
||||||
|
|
||||||
const std::shared_ptr<amqp::Reader> byType (const std::string &);
|
virtual const std::shared_ptr<amqp::Reader> byType(const std::string &) override;
|
||||||
const std::shared_ptr<amqp::Reader> byDescriptor (const std::string &);
|
|
||||||
|
virtual const std::shared_ptr<amqp::Reader> byDescriptor(const std::string &) override;
|
||||||
|
|
||||||
private :
|
private :
|
||||||
std::shared_ptr<amqp::Reader> process(const amqp::internal::schema::AMQPTypeNotation &);
|
std::shared_ptr<amqp::Reader> process(const amqp::internal::schema::AMQPTypeNotation &);
|
||||||
@ -44,5 +48,7 @@ class CompositeFactory {
|
|||||||
processRestricted(const amqp::internal::schema::AMQPTypeNotation &);
|
processRestricted(const amqp::internal::schema::AMQPTypeNotation &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
@ -32,7 +32,6 @@ namespace {
|
|||||||
|
|
||||||
// do we depend on the left hand side
|
// do we depend on the left hand side
|
||||||
|
|
||||||
|
|
||||||
if (std::find (
|
if (std::find (
|
||||||
otn.begin(),
|
otn.begin(),
|
||||||
otn.end(),
|
otn.end(),
|
||||||
|
Loading…
Reference in New Issue
Block a user