2014-01-04 19:45:04 +08:00
/**
* Class describing an AMQP exchange declare frame
*
* @ copyright 2014 Copernica BV
*/
/**
* Set up namespace
*/
namespace AMQP {
/**
* Class implementation
*/
class ExchangeDeclareFrame : public ExchangeFrame
{
private :
/**
* Field that no longer is used
* @ var uint16_t
*/
2014-02-12 15:27:07 +08:00
uint16_t _deprecated = 0 ;
2014-01-04 19:45:04 +08:00
/**
* The exchange name
* @ var ShortString
*/
ShortString _name ;
/**
* The exchange type
* @ var ShortString
*/
ShortString _type ;
/**
* The boolean set contains three settings :
* 0 : Passive declaration , do not create exchange if it does not exist
* 1 : Durable exchange
* 4 : Do not wait for a response
* @ var BooleanSet
*/
BooleanSet _bools ;
/**
* Additional arguments . Implementation dependent .
* @ var Table
*/
Table _arguments ;
protected :
/**
* Encode a frame on a string buffer
*
* @ param buffer buffer to write frame to
*/
virtual void fill ( OutBuffer & buffer ) const override
{
// call base
ExchangeFrame : : fill ( buffer ) ;
// add fields
buffer . add ( _deprecated ) ;
_name . fill ( buffer ) ;
_type . fill ( buffer ) ;
_bools . fill ( buffer ) ;
_arguments . fill ( buffer ) ;
}
public :
/**
* Construct a exchange declare frame ( client side )
*
* @ param channel channel we ´ re working on
* @ param name exchange name
* @ param type exchange type
* @ param passive do not create exchange if it does not exist
* @ param durable durable exchange
* @ param noWait do not wait on response
* @ param arguments additional arguments
*/
ExchangeDeclareFrame ( uint16_t channel , const std : : string & name , const std : : string & type , bool passive , bool durable , bool noWait , const Table & arguments ) :
ExchangeFrame ( channel , ( name . length ( ) + type . length ( ) + arguments . size ( ) + 5 ) ) , // size of name, type and arguments + 1 (all booleans are stored in 1 byte) + 2 (deprecated short) + 2 (string sizes)
_name ( name ) ,
_type ( type ) ,
_bools ( passive , durable , false , false , noWait ) ,
_arguments ( arguments )
{ }
/**
* Construct parsing a declare frame from a received frame
* @ param frame The received frame
*/
ExchangeDeclareFrame ( ReceivedFrame & frame ) :
ExchangeFrame ( frame ) ,
_deprecated ( frame . nextUint16 ( ) ) ,
_name ( frame ) ,
_type ( frame ) ,
_bools ( frame ) ,
_arguments ( frame )
{ }
/**
* Destructor
*/
virtual ~ ExchangeDeclareFrame ( ) { }
/**
* Method id
* @ return uint16_t
*/
2014-01-07 00:15:21 +08:00
virtual uint16_t methodID ( ) const override
2014-01-04 19:45:04 +08:00
{
return 10 ;
}
/**
* The exchange name
* @ return string
*/
2014-01-07 00:15:21 +08:00
const std : : string & name ( ) const
2014-01-04 19:45:04 +08:00
{
return _name ;
}
/**
* The exchange type
* @ return string
*/
2014-01-07 00:15:21 +08:00
const std : : string & exchangeType ( ) const
2014-01-04 19:45:04 +08:00
{
return _type ;
}
/**
* Passive declaration , do not create exchange if it does not exist
* @ return bool
*/
2014-01-07 00:15:21 +08:00
bool passive ( ) const
2014-01-04 19:45:04 +08:00
{
return _bools . get ( 0 ) ;
}
/**
* Durable exchange
* @ return bool
*/
2014-01-07 00:15:21 +08:00
bool durable ( ) const
2014-01-04 19:45:04 +08:00
{
return _bools . get ( 1 ) ;
}
/**
* Do not wait for a response
* @ return bool
*/
2014-01-07 00:15:21 +08:00
bool noWait ( ) const
2014-01-04 19:45:04 +08:00
{
return _bools . get ( 4 ) ;
}
/**
* Additional arguments . Implementation dependent .
* @ return Table
*/
2014-01-07 00:15:21 +08:00
const Table & arguments ( ) const
2014-01-04 19:45:04 +08:00
{
return _arguments ;
}
} ;
/**
* end namespace
*/
}