X-TraceC++Library
Public Types | Public Member Functions | Static Public Member Functions
xtr::Option Class Reference

Represents an X-Trace metadata option. More...

#include <XtrOption.h>

Inheritance diagram for xtr::Option:
xtr::OptionAny xtr::OptionChainId xtr::OptionNop xtr::OptionSeverity

Public Types

enum  { NOP = 0, CHAIN_ID = 0xC1, LAMPORT = 0xC0, SEVERITY = 0xCE }

Public Member Functions

 Option ()
virtual ~Option ()
virtual Optionclone () const =0
 Returns a pointer to a newly allocated Option, of the same subtype as the cloned object.
virtual u_int8_t getType () const =0
 Returns the type of this option.
virtual u_int8_t getLength () const =0
 Returns the length of the payload for this option.
virtual u_int8_t getSize () const =0
 Returns the size of the options when packed.
virtual xtr_result pack (u_int8_t *dest, size_t *size) const =0
 Writes the binary packed form of this option to the destination.
bool isEqual (const Option &other) const
 Two Options are equal if their packed representation are the same.

Static Public Member Functions

static OptioncreateFromBytes (const u_int8_t *b, size_t *size)
 Create a new Option from bytes.

Detailed Description

Represents an X-Trace metadata option.


Member Enumeration Documentation

anonymous enum
Enumerator:
NOP 
CHAIN_ID 
LAMPORT 
SEVERITY 

Constructor & Destructor Documentation

xtr::Option::Option ( ) [inline]
virtual xtr::Option::~Option ( ) [inline, virtual]

Member Function Documentation

virtual Option* xtr::Option::clone ( ) const [pure virtual]

Returns a pointer to a newly allocated Option, of the same subtype as the cloned object.

Implemented in xtr::OptionSeverity, xtr::OptionChainId, xtr::OptionAny, and xtr::OptionNop.

static Option* xtr::Option::createFromBytes ( const u_int8_t *  b,
size_t *  size 
) [static]

Create a new Option from bytes.

This is a factory method that returns Options of different derived types, if they are known.

Parameters:
bbuffer to read the option from
sizeINPUT: maximum safe size to read from b
OUTPUT: number of bytes read from b OR 0 in case of an error parsing the option.
Returns:
a pointer to a Option subclass.
If the type is unknown to the implementation, but the option is valid according to the spec, an instance of OptionAny is returned
If the option is not valid (not according to the general spec and/or not according to a specific type spec), an instance of OptionNop is returned, AND size is set to 0.
virtual u_int8_t xtr::Option::getLength ( ) const [pure virtual]

Returns the length of the payload for this option.

Implemented in xtr::OptionSeverity, xtr::OptionChainId, xtr::OptionAny, and xtr::OptionNop.

virtual u_int8_t xtr::Option::getSize ( ) const [pure virtual]

Returns the size of the options when packed.

Implemented in xtr::OptionSeverity, xtr::OptionChainId, xtr::OptionAny, and xtr::OptionNop.

virtual u_int8_t xtr::Option::getType ( ) const [pure virtual]

Returns the type of this option.

Implemented in xtr::OptionSeverity, xtr::OptionChainId, xtr::OptionAny, and xtr::OptionNop.

bool xtr::Option::isEqual ( const Option other) const

Two Options are equal if their packed representation are the same.

virtual xtr_result xtr::Option::pack ( u_int8_t *  dest,
size_t *  size 
) const [pure virtual]

Writes the binary packed form of this option to the destination.

Parameters:
destbuffer to write option to
sizeINPUT: maximum safe size to write to dest
OUTPUT: actual number of bytes written
Returns:
XTR_SUCCESS if enough space, XTR_FAIL otherwise

Implemented in xtr::OptionSeverity, xtr::OptionChainId, xtr::OptionAny, and xtr::OptionNop.


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