2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Frame.h
|
2014-04-29 21:51:33 +08:00
|
|
|
*
|
2014-01-04 19:45:04 +08:00
|
|
|
* Base class for frames. This base class can not be constructed from outside
|
|
|
|
|
* the library, and is only used internally.
|
2014-04-29 21:51:33 +08:00
|
|
|
*
|
2018-05-11 17:58:55 +08:00
|
|
|
* @copyright 2014 - 2018 Copernica BV
|
2014-01-04 19:45:04 +08:00
|
|
|
*/
|
|
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
|
|
|
|
* Include guard
|
|
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Dependencies
|
|
|
|
|
*/
|
|
|
|
|
#include "protocolexception.h"
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2016-06-23 20:42:50 +08:00
|
|
|
/**
|
|
|
|
|
* Forward declarations
|
|
|
|
|
*/
|
|
|
|
|
class ConnectionImpl;
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Class definition
|
|
|
|
|
*/
|
|
|
|
|
class Frame
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
2014-04-29 21:51:33 +08:00
|
|
|
* Protected constructor to ensure that no objects are created from
|
2014-01-04 19:45:04 +08:00
|
|
|
* outside the library
|
|
|
|
|
*/
|
|
|
|
|
Frame() {}
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
virtual ~Frame() {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* return the total size of the frame
|
|
|
|
|
* @return uint32_t
|
|
|
|
|
*/
|
|
|
|
|
virtual uint32_t totalSize() const = 0;
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Fill an output buffer
|
|
|
|
|
* @param buffer
|
|
|
|
|
*/
|
|
|
|
|
virtual void fill(OutBuffer &buffer) const = 0;
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-01-05 03:34:36 +08:00
|
|
|
/**
|
|
|
|
|
* Is this a frame that is part of the connection setup?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2014-01-05 20:08:35 +08:00
|
|
|
virtual bool partOfHandshake() const { return false; }
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-08-20 17:47:16 +08:00
|
|
|
/**
|
|
|
|
|
* Is this a frame that is part of the connection close operation?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
virtual bool partOfShutdown() const { return false; }
|
|
|
|
|
|
2014-01-05 20:08:35 +08:00
|
|
|
/**
|
|
|
|
|
* Does this frame need an end-of-frame seperator?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
virtual bool needsSeparator() const { return true; }
|
2014-04-29 21:51:33 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Is this a synchronous frame?
|
|
|
|
|
*
|
|
|
|
|
* After a synchronous frame no more frames may be
|
|
|
|
|
* sent until the accompanying -ok frame arrives
|
|
|
|
|
*/
|
|
|
|
|
virtual bool synchronous() const { return false; }
|
|
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Process the frame
|
|
|
|
|
* @param connection The connection over which it was received
|
|
|
|
|
* @return bool Was it succesfully processed?
|
|
|
|
|
*/
|
2014-04-29 21:51:33 +08:00
|
|
|
virtual bool process(ConnectionImpl *connection)
|
2014-01-06 01:50:41 +08:00
|
|
|
{
|
2018-05-11 17:58:55 +08:00
|
|
|
// make sure compilers dont complain about unused parameters
|
2018-05-11 08:52:43 +08:00
|
|
|
(void) connection;
|
|
|
|
|
|
2014-01-06 01:50:41 +08:00
|
|
|
// this is an exception
|
|
|
|
|
throw ProtocolException("unimplemented frame");
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-01-06 01:50:41 +08:00
|
|
|
// unreachable
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-04 19:45:04 +08:00
|
|
|
};
|
2014-04-29 21:51:33 +08:00
|
|
|
|
2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* End of namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|