Added TcpChannel class so that Connection and Channel class are once again completely protocol agnostic

This commit is contained in:
Emiel Bruijntjes 2015-11-01 09:51:43 +01:00
parent b4bd61580b
commit d41423d5db
6 changed files with 45 additions and 33 deletions

View File

@ -73,3 +73,4 @@
#include <amqpcpp/connection.h>
#include <amqpcpp/tcphandler.h>
#include <amqpcpp/tcpconnection.h>
#include <amqpcpp/tcpchannel.h>

View File

@ -14,11 +14,6 @@
*/
namespace AMQP {
/**
* Forward declarations
*/
class TcpConnection;
/**
* Class definition
*/
@ -42,16 +37,6 @@ public:
_implementation->attach(connection);
}
/**
* Construct a channel around a wrapped-connection
* @param connection
*/
Channel(TcpConnection *connection) : _implementation(new ChannelImpl())
{
// attach the connection to the channel
_implementation->attach(connection);
}
/**
* Copy'ing of channel objects is not supported
* @param channel

View File

@ -18,7 +18,6 @@ namespace AMQP {
* Forward declarations
*/
class ConsumedMessage;
class TcpConnection;
/**
* Class definition
@ -110,12 +109,6 @@ private:
*/
void attach(Connection *connection);
/**
* Attach the connection
* @param connection
*/
void attach(TcpConnection *connection);
/**
* Push a deferred result
* @param result The deferred result

43
include/tcpchannel.h Normal file
View File

@ -0,0 +1,43 @@
/**
* TcpChannel.h
*
* Extended channel that can be constructed on top of a TCP connection
*
* @author Emiel Bruijntjes <emiel.bruijntjes@copernica.com>
* @copyright 2015 Copernica BV
*/
/**
* Include guard
*/
#pragma once
/**
* Set up namespace
*/
namespace AMQP {
/**
* Class definition
*/
class TcpChannel : public Channel
{
public:
/**
* Constructor
* @param connection
*/
TcpChannel(TcpConnection *connection) :
Channel(&connection->_connection) {}
/**
* Destructor
*/
virtual ~TcpChannel() {}
};
/**
* End of namespace
*/
}

View File

@ -84,7 +84,7 @@ private:
* Classes that have access to private data
*/
friend class TcpConnected;
friend class ChannelImpl;
friend class TcpChannel;
public:

View File

@ -90,16 +90,6 @@ void ChannelImpl::attach(Connection *connection)
}
}
/**
* Initialize the object with an connection
* @param connection
*/
void ChannelImpl::attach(TcpConnection *connection)
{
// pass to the other attach() method
attach(&connection->_connection);
}
/**
* Push a deferred result
* @param result The deferred object to push