The Nebula Device 3: Util::Atom< TYPE > Class Template Reference

The Nebula Device 3

Util::Atom< TYPE > Class Template Reference

#include <atom.h>


Detailed Description

template<class TYPE>
class Util::Atom< TYPE >

An Atom is a compact, shared reference of a constant object. A unique object is guaranteed to exist only once, no matter how many Atoms are pointing to it. Copying Atoms and comparing against Atoms is very fast, since these are actually pointer operations.

Note that comparing 2 Atoms against each other will yield a different result then comparing the contents of the same Atoms. This is because comparing 2 Atoms actually compares the addresses of the content without actually invoking the compare operators of the content. So, comparing 2 Atom<String>'s will never do a strcmp(), instead the string pointers are compared against each other.

Atoms are consistent across threads.

The Atom table will *not* be garbage collected automatically, this means, entries for which no more Atoms exist will not be removed automatically. This is to prevent excessive allocations/deallocations for some usage scenarios. Instead, if you want to remove orphaned entries, call the PerformGarbageCollection() method manually.

(C) 2007 Radon Labs GmbH


Public Member Functions

 Atom ()
 default constructor
 Atom (const TYPE &rhs)
 construct from type
 Atom (const Atom< TYPE > &rhs)
 copy constructor
 ~Atom ()
 destructor
void operator= (const TYPE &rhs)
 assignment from type
void operator= (const Atom< TYPE > &rhs)
 assignment from other atom
bool operator== (const TYPE &rhs) const
 equality operator with atom content
bool operator!= (const TYPE &rhs) const
 inequality operator with atom content
bool operator> (const TYPE &rhs) const
 greater-then operator with atom content
bool operator< (const TYPE &rhs) const
 less-then operator with atom content
bool operator>= (const TYPE &rhs) const
 greater-or-equal operator with atom content
bool operator<= (const TYPE &rhs) const
 less-or-equal operator with atom content
bool operator== (const Atom< TYPE > &rhs) const
 equality operator between atoms
bool operator!= (const Atom< TYPE > &rhs) const
 inequality operator between atoms
bool operator> (const Atom< TYPE > &rhs) const
 greater-then operator between atoms
bool operator< (const Atom< TYPE > &rhs) const
 less-then operator between atoms
bool operator>= (const Atom< TYPE > &rhs) const
 greater-or-equal operator between atoms
bool operator<= (const Atom< TYPE > &rhs) const
 less-or-equal operator between atoms
void Clear ()
 clear content
bool IsValid () const
 return true if the Atom is valid
const TYPE & Value () const
 access to referenced object

Static Public Member Functions

static void PerformGarbageCollection ()
 perform garbage collection on atom table
static SizeT GetAtomTableSize ()
 get current atom table size (for debugging)