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

Modified Files:
        lists.h 
Log Message:
added M_LIST_RC_ABSTRACT

Index: lists.h
===================================================================
RCS file: /cvsroot/mahogany/M/include/lists.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -b -u -2 -r1.9 -r1.10
--- lists.h     8 Dec 2002 00:41:09 -0000       1.9
+++ lists.h     29 Aug 2003 00:03:39 -0000      1.10
@@ -354,10 +354,6 @@
 }
 
-/** Macro to define a list with a given name, having elements of pointer
-    to the given reference-counted type; i.e. M_LIST_RC(MyRef,obj) will
-    create a MyRef type holding pointers-to-obj.  The list will take
-    ownership of any pointer in it and will DecRef any orphaned objects.
-*/
-#define M_LIST_RC(name,type) \
+/// common part of M_LIST_RC and M_LIST_RC_ABSTRACT
+#define M_LIST_RC_common(name,type,operator_star_and_inline) \
 M_LIST_common(name##_common,type*); \
 class name : public name##_common \
@@ -367,9 +363,9 @@
    { \
    public: \
+      iterator(ListNode *n = NULL) : name##_common::iterator(n) {} \
       iterator(const name##_common::iterator &i) \
          : name##_common::iterator(i) {} \
-      inline type operator*(void) \
-         { return *(name##_common::iterator::operator*()); } \
-      inline value_type operator->(void) \
+      operator_star_and_inline \
+      value_type operator->(void) \
          { return name##_common::iterator::operator*(); } \
    }; \
@@ -390,4 +386,28 @@
       } \
 }
+
+/// helper for M_LIST_RC
+#define M_LIST_RC_operator_star(name, type)                                \
+      inline type operator*(void)                                          \
+         { return *(name##_common::iterator::operator*()); }               \
+      inline
+
+/** Macro to define a list with a given name, having elements of pointer
+    to the given reference-counted type; i.e. M_LIST_RC(MyRef,obj) will
+    create a MyRef type holding pointers-to-obj.  The list will take
+    ownership of any pointer in it and will DecRef any orphaned objects.
+*/
+#define M_LIST_RC(name,type)                                               \
+      M_LIST_RC_common(name, type, M_LIST_RC_operator_star(name, type))
+
+/**
+   M_LIST_RC_ABSTRACT is just like M_LIST_RC but for abstract classes.
+
+   M_LIST_RC doesn't work for abstract classes because we can't have a function
+   returning objects of such classes and operator*() does just that. So we
+   define a macro which does exactly the same thing as M_LIST_RC except that it
+   omits the definition of operator*().
+ */
+#define M_LIST_RC_ABSTRACT(name,type) M_LIST_RC_common(name, type, inline)
 
 #endif // LISTS_H



-------------------------------------------------------
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