2014-01-04 19:45:04 +08:00
|
|
|
/**
|
|
|
|
|
* Frame.h
|
|
|
|
|
*
|
|
|
|
|
* Base class for frames. This base class can not be constructed from outside
|
|
|
|
|
* the library, and is only used internally.
|
|
|
|
|
*
|
|
|
|
|
* @copyright 2014 Copernica BV
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up namespace
|
|
|
|
|
*/
|
|
|
|
|
namespace AMQP {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class definition
|
|
|
|
|
*/
|
|
|
|
|
class Frame
|
|
|
|
|
{
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
|
|
|
|
* Protected constructor to ensure that no objects are created from
|
|
|
|
|
* outside the library
|
|
|
|
|
*/
|
|
|
|
|
Frame() {}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Destructor
|
|
|
|
|
*/
|
|
|
|
|
virtual ~Frame() {}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* return the total size of the frame
|
|
|
|
|
* @return uint32_t
|
|
|
|
|
*/
|
|
|
|
|
virtual uint32_t totalSize() const = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Fill an output buffer
|
|
|
|
|
* @param buffer
|
|
|
|
|
*/
|
|
|
|
|
virtual void fill(OutBuffer &buffer) const = 0;
|
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Does this frame need an end-of-frame seperator?
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
virtual bool needsSeparator() const { return true; }
|
2014-01-05 03:34:36 +08:00
|
|
|
|
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-01-06 01:50:41 +08:00
|
|
|
virtual bool process(ConnectionImpl *connection)
|
|
|
|
|
{
|
|
|
|
|
// this is an exception
|
|
|
|
|
throw ProtocolException("unimplemented frame");
|
|
|
|
|
|
|
|
|
|
// unreachable
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-01-04 19:45:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* End of namespace
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|