nub::objectdb Class Reference

#include <nub/objdb.h>

Collaboration diagram for nub::objectdb:

Collaboration graph
[legend]

List of all members.

Public Types

typedef rutz::fwd_iter< object
*const > 
iterator

Public Member Functions

virtual ~objectdb ()
 Virtual destructor.
iterator objects () const
int count () const throw ()
 Returns the number of valid objects in the database.
bool is_valid_uid (nub::uid id) const throw ()
 Returns true if 'id' is a valid uid.
void remove (nub::uid id)
 Releases the object specified by id, but only if it is unshared.
void release (nub::uid id)
 Removes reference to the object with uid id.
void purge ()
 Releases all unshared objects held in the database.
void clear ()
 Calls purge() repeatedly until no more items can be removed.
void clear_on_exit ()
 WARNING: should only be called during program exit.
nub::objectget_checked_obj (nub::uid id) throw (nub::invalid_uid_error)
 Return the nub::object* with the uid given by id.
void insert_obj (nub::object *obj)
 Insert a strong reference to obj into the database.
void insert_obj_weak (nub::object *obj)
 Insert a weak reference to obj into the database.

Static Public Member Functions

static objectdbinstance ()
 Returns the singleton instance of objectdb.

Protected Member Functions

 objectdb ()
 Default constructor makes an empty list.

Classes

class  casting_iterator
 A filtering iterator class; only exposes objects matching a given type. More...
class  impl


Detailed Description

objectdb is a database for storing nub::object objects, which can be accessed by their nub::uid values. Most clients will not need to use the objectdb directly, but can instead use the nub::ref and nub::soft_ref smart pointers.

Definition at line 81 of file objdb.h.


Member Function Documentation

void nub::objectdb::remove ( nub::uid  id  ) 

Releases the object specified by id, but only if it is unshared.

This causes the object to be destroyed since it was unshared. If the object is shared, this operation throws an exception.

Definition at line 335 of file objdb.cc.

void nub::objectdb::purge (  ) 

Releases all unshared objects held in the database.

Since the objects are unshared, they will be destroyed in the process.

Definition at line 347 of file objdb.cc.

void nub::objectdb::clear (  ) 

Calls purge() repeatedly until no more items can be removed.

This will get rid of items that were only referenced by other items in the list.

Definition at line 354 of file objdb.cc.

void nub::objectdb::clear_on_exit (  ) 

WARNING: should only be called during program exit.

Does a full clear of all objects held by the objectdb. This breaks the usual semantics of objectdb, since it removes both shared and unshared objects.

Definition at line 362 of file objdb.cc.

nub::object * nub::objectdb::get_checked_obj ( nub::uid  id  )  throw (nub::invalid_uid_error)

Return the nub::object* with the uid given by id.

Checks first if id is a valid uid, and throws an nub::invalid_uid_error if it is not.

Definition at line 368 of file objdb.cc.


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

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:21 2008 by Doxygen version 1.5.5.