AgentXcpp  Version:0.3
Internals Documentation
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Pages
agentxcpp::PDUwithContext Class Reference

#include <PDUwithContext.hpp>

Inheritance diagram for agentxcpp::PDUwithContext:
Collaboration diagram for agentxcpp::PDUwithContext:

Public Member Functions

bool has_context ()
 Whether the PDU has a context. More...
 
OctetStringVariable get_context ()
 Get context. More...
 
void set_context (OctetStringVariable value)
 Set the PDU's context. More...
 
void remove_context ()
 Removes the context from the PDU. More...
 
- Public Member Functions inherited from agentxcpp::PDU
virtual ~PDU ()
 Destructor. More...
 
bool get_new_index ()
 Get new_index flag. More...
 
void set_new_index (bool new_index)
 Set new_index flag. More...
 
bool get_any_index ()
 Get any_index flag. More...
 
void set_any_index (bool any_index)
 Set any_index flag. More...
 
quint32 get_sessionID ()
 Get sessionID. More...
 
void set_sessionID (quint32 id)
 Set sessionID. More...
 
quint32 get_transactionID ()
 Get transactionID. More...
 
void set_transactionID (quint32 id)
 Set transactionID. More...
 
quint32 get_packetID ()
 Get packetID. More...
 
void set_packetID (quint32 packetID)
 Set packetID. More...
 
virtual binary serialize () const =0
 Serialize function for concrete PDUs. More...
 

Protected Member Functions

 PDUwithContext (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian)
 Parse constructor. More...
 
void add_header (type_t type, binary &payload) const
 Add PDU header and context field to the payload. More...
 
 PDUwithContext ()
 Default Constructor. More...
 
- Protected Member Functions inherited from agentxcpp::PDU
 PDU (binary::const_iterator &pos, const binary::const_iterator &end, bool big_endian)
 Parse constructor. More...
 
void add_header (type_t type, binary &payload) const
 Construct the PDU header and add it to the payload. More...
 
 PDU ()
 Default constructor. More...
 

Private Attributes

OctetStringVariable context
 The context. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from agentxcpp::PDU
static QSharedPointer< PDUparse_pdu (binary buf)
 Parse a PDU from a buffer. More...
 
- Protected Types inherited from agentxcpp::PDU
enum  type_t {
  agentxOpenPDU = 1, agentxClosePDU = 2, agentxRegisterPDU = 3, agentxUnregisterPDU = 4,
  agentxGetPDU = 5, agentxGetNextPDU = 6, agentxGetBulkPDU = 7, agentxTestSetPDU = 8,
  agentxCommitSetPDU = 9, agentxUndoSetPDU = 10, agentxCleanupSetPDU = 11, agentxNotifyPDU = 12,
  agentxPingPDU = 13, agentxIndexAllocatePDU = 14, agentxIndexDeallocatePDU = 15, agentxAddAgentCapsPDU = 16,
  agentxRemoveAgentCapsPDU = 17, agentxResponsePDU = 18
}
 The PDU types. More...
 
- Protected Attributes inherited from agentxcpp::PDU
bool instance_registration
 the instance_registration flag More...
 
bool non_default_context
 Whether the PDU has a non-default context. More...
 
quint32 packetID
 h.packetID field according to RFC 2741, 6.1. "AgentX PDU Header". More...
 

Detailed Description

This class is never instantiated itself, but serves as the base class for concrete PDU classes which have a context field (e.g. GetPDU). For concrete PDU's without context field, the class PDUwithContext is used.

This derives from the PDU class and adds a context field. This field is only meaningful if PUD::non_default_context is true. If non_default_context is false, the context will neither be read in when a PDU is parsed nor will it be serialized by PDUwithContext::add_header().

Definition at line 44 of file PDUwithContext.hpp.

Constructor & Destructor Documentation

agentxcpp::PDUwithContext::PDUwithContext ( binary::const_iterator &  pos,
const binary::const_iterator &  end,
bool  big_endian 
)
inlineprotected

Parse constructor.

Read the context from a buffer and let the PDU::PDU() parse constructor do the rest. Is called by the parse constructors of derived classes. See Parsing incoming PDUs for details about PDU parsing.

Parameters
posIterator pointing to the current stream position. The iterator is advanced while reading the header.
endIterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer.
big_endianWhether the serialized form of the PDU is in big_endian format.
Exceptions
parse_errorIf parsing fails, for example because reading the stream fails or the PDU is malformed.

Definition at line 75 of file PDUwithContext.hpp.

References agentxcpp::PDU::non_default_context.

agentxcpp::PDUwithContext::PDUwithContext ( )
inlineprotected

Default Constructor.

Sets the state of the object to the defaults as set by the PDU::PDU() constructor. The non_default_context flag is set to false by default, which means that the object has no context.

Definition at line 127 of file PDUwithContext.hpp.

Member Function Documentation

void agentxcpp::PDUwithContext::add_header ( type_t  type,
binary payload 
) const
inlineprotected

Add PDU header and context field to the payload.

Add the PDU header and the context field to the payload. Called by derived classes during serialization.

Warning
The payload must not grow or shrink after a call to this function as its size is encoded into the header.
The function must not be called twice for the same PDU, because this would add two headers and thus generate a malformed PDU.

Header and context are encoded in big endian format.

Parameters
typeThe PDU type, according to RFC 2741, 6.1. "AgentX PDU Header".
payloadThe payload of the PDU. The header is added to the payload, i.e. payload is altered by this function.

Definition at line 108 of file PDUwithContext.hpp.

References agentxcpp::PDU::add_header(), agentxcpp::PDU::non_default_context, and agentxcpp::OctetStringVariable::serialize().

Referenced by agentxcpp::PingPDU::serialize(), agentxcpp::IndexAllocatePDU::serialize(), agentxcpp::IndexDeallocatePDU::serialize(), agentxcpp::TestSetPDU::serialize(), agentxcpp::GetPDU::serialize(), agentxcpp::GetNextPDU::serialize(), agentxcpp::NotifyPDU::serialize(), agentxcpp::RemoveAgentCapsPDU::serialize(), agentxcpp::UnregisterPDU::serialize(), agentxcpp::AddAgentCapsPDU::serialize(), agentxcpp::RegisterPDU::serialize(), and agentxcpp::GetBulkPDU::serialize().

OctetStringVariable agentxcpp::PDUwithContext::get_context ( )
inline

Get context.

Returns
The internally stored context.
Warning
The returned context is only valid if the PDU actually has a context. This can be determined using has_context().

Definition at line 147 of file PDUwithContext.hpp.

References context.

bool agentxcpp::PDUwithContext::has_context ( )
inline

Whether the PDU has a context.

Definition at line 133 of file PDUwithContext.hpp.

References agentxcpp::PDU::non_default_context.

void agentxcpp::PDUwithContext::remove_context ( )
inline

Removes the context from the PDU.

Afterwards the PDU has no context any longer.

Definition at line 171 of file PDUwithContext.hpp.

References agentxcpp::PDU::non_default_context.

void agentxcpp::PDUwithContext::set_context ( OctetStringVariable  value)
inline

Set the PDU's context.

Parameters
valueThe new context. The given value may be the empty string, which does not delete the context, but set the empty string as context. To remove the context from the PDU, use remove_context().

Definition at line 160 of file PDUwithContext.hpp.

References agentxcpp::PDU::non_default_context.

Member Data Documentation

OctetStringVariable agentxcpp::PDUwithContext::context
private

The context.

Definition at line 50 of file PDUwithContext.hpp.

Referenced by get_context().


The documentation for this class was generated from the following file: