Classes | Public Member Functions | List of all members
ndn::DelegationSet Class Reference

A DelegationSet holds a list of DelegationSet::Delegation entries which is used as the content of a Link instance. More...

#include <delegation-set.hpp>

Classes

class  Delegation
 A DelegationSet::Delegation holds a preference number and delegation name. More...
 

Public Member Functions

 DelegationSet ()
 Create a DelegationSet with an empty list of delegations.
 
 DelegationSet (const DelegationSet &delegationSet)
 Create a DelegationSet, copying values from the other DelegationSet. More...
 
void add (int preference, const Name &name)
 Add a new DelegationSet::Delegation to the list of delegations, sorted by preference number then by name. More...
 
void addUnsorted (const ptr_lib::shared_ptr< Delegation > &delegation)
 Add the DelegationSet::Delegation to the end of the list of delegations, without sorting or updating any existing entries. More...
 
bool remove (const Name &name)
 Remove every DelegationSet::Delegation with the given name. More...
 
void clear ()
 Clear the list of delegations.
 
size_t size () const
 Get the number of delegation entries. More...
 
const Delegationget (size_t i) const
 Get the delegation at the given index, according to the ordering described in add(). More...
 
int find (const Name &name) const
 Find the first delegation with the given name and return its index. More...
 
Blob wireEncode (WireFormat &wireFormat=*WireFormat::getDefaultWireFormat()) const
 Encode this DelegationSet for a particular wire format. More...
 
void wireDecode (const uint8_t *input, size_t inputLength, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Decode the input using a particular wire format and update this DelegationSet. More...
 
void wireDecode (const std::vector< uint8_t > &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Decode the input using a particular wire format and update this DelegationSet. More...
 
void wireDecode (const Blob &input, WireFormat &wireFormat=*WireFormat::getDefaultWireFormat())
 Decode the input using a particular wire format and update this DelegationSet. More...
 

Detailed Description

A DelegationSet holds a list of DelegationSet::Delegation entries which is used as the content of a Link instance.

If you add elements with add(), then the list is a set sorted by preference number then by name. But wireDecode will add the elements from the wire encoding, preserving the given order and possible duplicates (in which case a DelegationSet really holds a "list" and not necessarily a "set").

Constructor & Destructor Documentation

ndn::DelegationSet::DelegationSet ( const DelegationSet delegationSet)
inline

Create a DelegationSet, copying values from the other DelegationSet.

Parameters
delegationSetThe DelegationSet to copy values from.

Member Function Documentation

void ndn::DelegationSet::add ( int  preference,
const Name name 
)

Add a new DelegationSet::Delegation to the list of delegations, sorted by preference number then by name.

If there is already a delegation with the same name, update its preference, and remove any extra delegations with the same name.

Parameters
preferenceThe preference number.
nameThe delegation name. This makes a copy of the name.
void ndn::DelegationSet::addUnsorted ( const ptr_lib::shared_ptr< Delegation > &  delegation)
inline

Add the DelegationSet::Delegation to the end of the list of delegations, without sorting or updating any existing entries.

This is useful for adding preferences from a wire encoding, preserving the supplied ordering and possible duplicates.

Parameters
preferenceThe preference number.
nameThe delegation name. This makes a copy of the name.
int ndn::DelegationSet::find ( const Name name) const

Find the first delegation with the given name and return its index.

Parameters
nameThen name of the delegation to find.
Returns
The index of the delegation, or -1 if not found.
const DelegationSet::Delegation & ndn::DelegationSet::get ( size_t  i) const

Get the delegation at the given index, according to the ordering described in add().

Parameters
iThe index of the component, starting from 0.
Returns
The delegation at the index.
Exceptions
runtime_errorIf index is out of range.
bool ndn::DelegationSet::remove ( const Name name)

Remove every DelegationSet::Delegation with the given name.

Parameters
nameThe name to match the name of the delegation(s) to be removed.
Returns
True if a DelegationSet::Delegation was removed, otherwise false.
size_t ndn::DelegationSet::size ( ) const
inline

Get the number of delegation entries.

Returns
The number of delegation entries.
void ndn::DelegationSet::wireDecode ( const uint8_t *  input,
size_t  inputLength,
WireFormat wireFormat = *WireFormat::getDefaultWireFormat() 
)
inline

Decode the input using a particular wire format and update this DelegationSet.

Parameters
inputThe input byte array to be decoded.
inputLengthThe length of input.
wireFormat(optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat().
void ndn::DelegationSet::wireDecode ( const std::vector< uint8_t > &  input,
WireFormat wireFormat = *WireFormat::getDefaultWireFormat() 
)
inline

Decode the input using a particular wire format and update this DelegationSet.

Parameters
inputThe input byte array to be decoded.
wireFormat(optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat().
void ndn::DelegationSet::wireDecode ( const Blob input,
WireFormat wireFormat = *WireFormat::getDefaultWireFormat() 
)
inline

Decode the input using a particular wire format and update this DelegationSet.

Parameters
inputThe input byte array to be decoded as an immutable Blob.
wireFormat(optional) A WireFormat object used to decode the input. If omitted, use WireFormat::getDefaultWireFormat().
Blob ndn::DelegationSet::wireEncode ( WireFormat wireFormat = *WireFormat::getDefaultWireFormat()) const
inline

Encode this DelegationSet for a particular wire format.

Parameters
wireFormat(optional) A WireFormat object used to encode this DelegationSet. If omitted, use WireFormat::getDefaultWireFormat().
Returns
The encoded byte array.

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