Update of /cvsroot/mahogany/M/include
In directory sc8-pr-cvs1:/tmp/cvs-serv16122/include

Modified Files:
        pointers.h 
Log Message:
Removed SpamOptionManager::Pointer and extended RefCounter

Index: pointers.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/pointers.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -u -2 -r1.1 -r1.2
--- pointers.h  3 Oct 2003 12:51:20 -0000       1.1
+++ pointers.h  3 Oct 2003 13:39:46 -0000       1.2
@@ -19,6 +19,8 @@
 {
 public:
-   RefCounter() { m_pointer = 0; }
-   ~RefCounter() { RefCounterDecrement(m_pointer); }
+   RefCounter() { NewDefault(); }
+   RefCounter(ClassName *copy) { NewBare(copy); }
+   RefCounter(const RefCounter<ClassName> &copy) { NewCopy(copy); }
+   ~RefCounter() { Destroy(); }
    
    void AttachAndIncRef(ClassName *pointer)
@@ -28,20 +30,39 @@
    }
 
-   ClassName *Get() { return m_pointer; }
-   bool NotNull() { return m_pointer != 0; }
-   
    operator ClassName *() { return Get(); }
    ClassName *operator->() { return Get(); }
    operator bool() { return NotNull(); }
+   RefCounter<ClassName>& operator=(const RefCounter<ClassName> &copy)
+      { return Assign(copy); }
 
 private:
+   void NewDefault() { m_pointer = 0; }
+   void NewCopy(const RefCounter<ClassName> &copy)
+      { NewBare(copy.m_pointer); }
+   void NewBare(ClassName *copy)
+      { RefCounterIncrement(m_pointer = copy); }
+   void Destroy() { RefCounterDecrement(m_pointer); }
+   
+   RefCounter<ClassName>& Assign(const RefCounter<ClassName> &copy)
+   {
+      AttachAndIncRef(copy.m_pointer);
+      return *this;
+   }
+
+   ClassName *Get() const { return m_pointer; }
+   bool NotNull() const { return m_pointer != 0; }
+   
    ClassName *m_pointer;
 };
 
 #define DECLARE_REF_COUNTER(ClassName) \
+   class ClassName; \
+   extern void RefCounterIncrement(ClassName *pointer); \
    extern void RefCounterDecrement(ClassName *pointer); \
    extern void RefCounterAssign(ClassName *target,ClassName *source);
 
 #define DEFINE_REF_COUNTER(ClassName) \
+   extern void RefCounterIncrement(ClassName *pointer) \
+      { RefCounterIncrement(static_cast<MObjectRC *>(pointer)); } \
    extern void RefCounterDecrement(ClassName *pointer) \
       { RefCounterDecrement(static_cast<MObjectRC *>(pointer)); } \
@@ -52,4 +73,5 @@
    }
 
+extern void RefCounterIncrement(MObjectRC *pointer);
 extern void RefCounterDecrement(MObjectRC *pointer);
 extern void RefCounterAssign(MObjectRC *target,MObjectRC *source);



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to