#include <PDUwithContext.hpp>
Public Member Functions | |
| bool | has_context () |
| Whether the PDU has a context. | |
| Octet_String | get_context () |
| Get context. | |
| void | set_context (Octet_String value) |
| Set the PDU's context. | |
| void | remove_context () |
| Removes the context from the PDU. | |
Protected Member Functions | |
| PDUwithContext (data_t::const_iterator &pos, const data_t::const_iterator &end, bool big_endian) | |
| Parse constructor. | |
| void | add_header (type_t type, data_t &payload) const |
| Add PDU header and context field to the payload. | |
| PDUwithContext () | |
| Default Constructor. | |
Private Attributes | |
| Octet_String | context |
| The context. | |
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.
| agentxcpp::PDUwithContext::PDUwithContext | ( | data_t::const_iterator & | pos, |
| const data_t::const_iterator & | end, | ||
| bool | big_endian | ||
| ) | [inline, protected] |
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.
| pos | Iterator pointing to the current stream position. The iterator is advanced while reading the header. |
| end | Iterator pointing one element past the end of the current stream. This is needed to mark the end of the buffer. |
| big_endian | Whether the serialized form of the PDU is in big_endian format. |
| parse_error | If parsing fails, for example because reading the stream fails or the PDU is malformed. |
Definition at line 75 of file PDUwithContext.hpp.
References context, and agentxcpp::PDU::non_default_context.
| agentxcpp::PDUwithContext::PDUwithContext | ( | ) | [inline, protected] |
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.
| void agentxcpp::PDUwithContext::add_header | ( | type_t | type, |
| data_t & | payload | ||
| ) | const [inline, protected] |
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.
Header and context are encoded in big endian format.
| type | The PDU type, according to RFC 2741, 6.1. "AgentX PDU Header". |
| payload | The payload of the PDU. The header is added to the payload, i.e. payload is altered by this function. |
Reimplemented from agentxcpp::PDU.
Definition at line 108 of file PDUwithContext.hpp.
References context, agentxcpp::PDU::non_default_context, and agentxcpp::Octet_String::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().
| Octet_String agentxcpp::PDUwithContext::get_context | ( | ) | [inline] |
Get 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 | ( | Octet_String | value | ) | [inline] |
Set the PDU's context.
| value | The 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 context, and agentxcpp::PDU::non_default_context.
The context.
Definition at line 50 of file PDUwithContext.hpp.
Referenced by add_header(), get_context(), PDUwithContext(), and set_context().