[asycxx-devel] SF.net SVN: asycxx:[40] trunk
Status: Alpha
Brought to you by:
joe_steeve
From: <joe...@us...> - 2009-04-08 07:41:33
|
Revision: 40 http://asycxx.svn.sourceforge.net/asycxx/?rev=40&view=rev Author: joe_steeve Date: 2009-04-08 07:41:32 +0000 (Wed, 08 Apr 2009) Log Message: ----------- refactored RefCounter.* * moved class:RefCounter into 'asycxx' namespace * moved most of the one-liner code from RefCounter.cxx to RefCounter.h From: Joe Steeve <js...@hi...> Modified Paths: -------------- trunk/include/asycxx/RefCounter.h trunk/src/RefCounter.cxx Modified: trunk/include/asycxx/RefCounter.h =================================================================== --- trunk/include/asycxx/RefCounter.h 2009-04-08 07:40:45 UTC (rev 39) +++ trunk/include/asycxx/RefCounter.h 2009-04-08 07:41:32 UTC (rev 40) @@ -17,19 +17,36 @@ #include "Error.h" -class RefCounter +namespace asycxx { -public: - RefCounter (); + class RefCounter + { + public: + /* + * CTOR: + */ + RefCounter () { m_OwnerCount = 1; } - void Own (void); - void DisOwn (void); + void Own (void) { m_OwnerCount ++; } + void DisOwn (void) + { + m_OwnerCount --; + if (m_OwnerCount == 0) + { + delete this; + } + } -protected: - virtual ~RefCounter (); - int m__OwnerCount; -}; + protected: + /* DTOR: A reference counted object may not be deleted + * directly. Hence we have the 'dtor' as protected. + */ + virtual ~RefCounter (); + private: + int m_OwnerCount; + }; +} #endif /* __HIPRO_ASYCXX__REF_COUNTER_H__ */ /* Modified: trunk/src/RefCounter.cxx =================================================================== --- trunk/src/RefCounter.cxx 2009-04-08 07:40:45 UTC (rev 39) +++ trunk/src/RefCounter.cxx 2009-04-08 07:41:32 UTC (rev 40) @@ -16,50 +16,15 @@ #endif #include "asycxx-common.h" -#include <asycxx/Error.h> #include <asycxx/RefCounter.h> +using namespace asycxx; -/** - * \author Joe Steeve, jo...@hi... - * \class RefCounter - * \brief A simple reference counting mechanism - * - * \details This class provides functionality necessary for a simple - * reference-counting system. The creator of the object already owns - * the object. Hence the creator should explicitly calls - * RefCounter::DisOwn() to disown the object - */ - -RefCounter::RefCounter () -{ - m__OwnerCount = 1; -} - RefCounter::~RefCounter () { - if (m__OwnerCount != 0) - { - ERR ("FATAL: some-one still owns me"); - } + ASSERT ((m_OwnerCount == 0), "FATAL: some-one still owns me"); } -void -RefCounter::Own (void) -{ - m__OwnerCount ++; -} - -void -RefCounter::DisOwn (void) -{ - m__OwnerCount --; - if (m__OwnerCount == 0) - { - delete this; - } -} - /* Local Variables: mode: c++ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |