Countable.hpp

Go to the documentation of this file.
00001 #ifndef wali_COUNTABLE_GUARD
00002 #define wali_COUNTABLE_GUARD 1
00003 
00004 /**
00005  * @author Nicholas Kidd
00006  */
00007 
00008 #include "wali/Common.hpp"
00009 #include "ref_ptr.hpp"
00010 
00011 namespace wali
00012 {
00013   class Countable
00014   {
00015     public:
00016       ref_ptr<Countable>::count_t count;
00017 
00018     public:
00019       /**
00020        * <b>Note:</b> The capability that a reference counted
00021        * object should never be reclaimed has been removed.
00022        * If you require an object to "live forever", then it
00023        * is up to you to hold onto a reference to the object.
00024        */
00025       Countable() : count(0) {}
00026 
00027       /**
00028        * The copy constructor creates a new instance of
00029        * Countable, therefore its "count" is initialized to 0.
00030        */
00031       Countable( const Countable& c ATTR_UNUSED ) : count(0)
00032       {
00033         (void) c;
00034       }
00035 
00036       /**
00037        * Countable::operator= does not modify "this's" count.
00038        * This is because operator= does not modify the number of
00039        * pointers which refer to this. Therefore, operator= is a 
00040        * nop.
00041        */
00042       Countable& operator=( const Countable& c ATTR_UNUSED ) throw()
00043       {
00044         (void) c;
00045         return *this;
00046       }
00047 
00048       virtual ~Countable() {}
00049 
00050   }; // class Countable
00051 
00052 } // namespace wali
00053 
00054 #endif // wali_COUNTABLE_GUARD
00055