dtn::RegistrationTable Class Reference

Class for the in-memory registration table. More...

#include <RegistrationTable.h>

List of all members.

Public Member Functions

 RegistrationTable ()
 Constructor.
virtual ~RegistrationTable ()
 Destructor.
bool add (Registration *reg, bool add_to_store=true)
 Add a new registration to the database.
Registrationget (u_int32_t regid) const
 Look up a matching registration.
Registrationget (const EndpointIDPattern &eid) const
 Look up the first matching registration for the exact endpoint id pattern given.
bool del (u_int32_t regid)
 Remove the registration from the database, returns true if successful, false if the registration didn't exist.
bool update (Registration *reg)
 Update the registration in the database.
int get_matching (const EndpointID &eid, RegistrationList *reg_list) const
 Populate the given reglist with all registrations with an endpoint id that matches the bundle demux string.
int delete_expired (const time_t now)
 Delete any expired registrations.
void dump (oasys::StringBuffer *buf) const
 Dump out the registration database.
const RegistrationListreg_list () const
 Return the routing table.
oasys::Lock * lock () const
 Accessor for the RouteTable internal lock.

Protected Member Functions

bool find (u_int32_t regid, RegistrationList::iterator *iter)
 Internal method to find the location of the given registration.

Protected Attributes

RegistrationList reglist_
 All registrations are tabled in-memory in a flat list.
oasys::SpinLock lock_
 Lock to protect internal data structures.

Detailed Description

Class for the in-memory registration table.

All changes to the table are made persistent via the RegistrationStore.

Definition at line 32 of file RegistrationTable.h.


Constructor & Destructor Documentation

dtn::RegistrationTable::RegistrationTable (  ) 

Constructor.

Definition at line 30 of file RegistrationTable.cc.

dtn::RegistrationTable::~RegistrationTable (  )  [virtual]

Destructor.

Definition at line 36 of file RegistrationTable.cc.

References reglist_.


Member Function Documentation

bool dtn::RegistrationTable::add ( Registration reg,
bool  add_to_store = true 
)

Add a new registration to the database.

Returns true if the registration is successfully added, false if there's another registration with the same {endpoint,regid}.

The flag controls whether or not the registration is added to the persistent store, which is only done for registrations added from the RPC interface.

Definition at line 96 of file RegistrationTable.cc.

References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), lock_, dtn::Registration::MAX_RESERVED_REGID, dtn::Registration::regid(), and reglist_.

bool dtn::RegistrationTable::del ( u_int32_t  regid  ) 

Remove the registration from the database, returns true if successful, false if the registration didn't exist.

Definition at line 130 of file RegistrationTable.cc.

References find(), lock_, and reglist_.

int dtn::RegistrationTable::delete_expired ( const time_t  now  ) 

Delete any expired registrations.

(was sweepOldRegistrations)

void dtn::RegistrationTable::dump ( oasys::StringBuffer *  buf  )  const

Dump out the registration database.

Definition at line 211 of file RegistrationTable.cc.

References lock_, and reglist_.

Referenced by dtnsim::NodeCommand::exec().

bool dtn::RegistrationTable::find ( u_int32_t  regid,
RegistrationList::iterator *  iter 
) [protected]

Internal method to find the location of the given registration.

Definition at line 46 of file RegistrationTable.cc.

References dtn::Registration::regid(), and reglist_.

Referenced by del(), and get().

Registration * dtn::RegistrationTable::get ( const EndpointIDPattern eid  )  const

Look up the first matching registration for the exact endpoint id pattern given.

Definition at line 79 of file RegistrationTable.cc.

References dtn::Registration::endpoint(), dtn::EndpointID::equals(), and reglist_.

Registration * dtn::RegistrationTable::get ( u_int32_t  regid  )  const

Look up a matching registration.

Definition at line 63 of file RegistrationTable.cc.

References find(), and lock_.

Referenced by dtnsim::NodeCommand::exec(), dtn::APIClient::handle_bind(), dtn::APIClient::handle_send(), and dtn::APIClient::handle_unbind().

int dtn::RegistrationTable::get_matching ( const EndpointID eid,
RegistrationList reg_list 
) const

Populate the given reglist with all registrations with an endpoint id that matches the bundle demux string.

Returns the count of matching registrations.

Definition at line 182 of file RegistrationTable.cc.

References dtn::EndpointID::c_str(), count, dtn::Registration::endpoint(), lock_, dtn::EndpointIDPattern::match(), dtn::Registration::regid(), and reglist_.

Referenced by dtn::BundleDaemon::check_and_deliver_to_registrations(), dtn::BundleDaemon::handle_bundle_delete(), and dtn::APIClient::handle_send().

oasys::Lock* dtn::RegistrationTable::lock (  )  const [inline]

Accessor for the RouteTable internal lock.

Definition at line 107 of file RegistrationTable.h.

References lock_.

const RegistrationList * dtn::RegistrationTable::reg_list (  )  const

Return the routing table.

Asserts that the RegistrationTable spin lock is held by the caller.

Definition at line 227 of file RegistrationTable.cc.

References lock_, and reglist_.

bool dtn::RegistrationTable::update ( Registration reg  ) 

Update the registration in the database.

Returns true on success, false on error.

Definition at line 157 of file RegistrationTable.cc.

References dtn::EndpointID::c_str(), dtn::Registration::endpoint(), lock_, and dtn::Registration::regid().


Member Data Documentation

oasys::SpinLock dtn::RegistrationTable::lock_ [mutable, protected]

Lock to protect internal data structures.

Definition at line 125 of file RegistrationTable.h.

Referenced by add(), del(), dump(), get(), get_matching(), lock(), reg_list(), and update().

All registrations are tabled in-memory in a flat list.

It's non-obvious what else would be better since we need to do a prefix match on demux strings in matching_registrations.

Definition at line 120 of file RegistrationTable.h.

Referenced by add(), del(), dump(), find(), get(), get_matching(), reg_list(), and ~RegistrationTable().


The documentation for this class was generated from the following files:
Generated on Sun Nov 21 13:21:22 2010 for DTN Reference Implementation by  doxygen 1.6.3