| 1 | /* |
| 2 | ** CWContainer.h |
| 3 | ** |
| 4 | ** Copyright (c) 2002-2007 Ludovic Marcotte |
| 5 | ** |
| 6 | ** Author: Ludovic Marcotte <[email protected]> |
| 7 | ** |
| 8 | ** This library is free software; you can redistribute it and/or |
| 9 | ** modify it under the terms of the GNU Lesser General Public |
| 10 | ** License as published by the Free Software Foundation; either |
| 11 | ** version 2.1 of the License, or (at your option) any later version. |
| 12 | ** |
| 13 | ** This library is distributed in the hope that it will be useful, |
| 14 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | ** Lesser General Public License for more details. |
| 17 | ** |
| 18 | ** You should have received a copy of the GNU General Public License |
| 19 | ** along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
| 22 | #ifndef _Pantomime_H_CWContainer |
| 23 | #define _Pantomime_H_CWContainer |
| 24 | |
| 25 | #import <Foundation/NSEnumerator.h> |
| 26 | #import <Foundation/NSObject.h> |
| 27 | |
| 28 | @class CWMessage; |
| 29 | |
| 30 | /*! |
| 31 | @class CWContainer |
| 32 | @discussion This class is a simple placeholder used when doing message threading. |
| 33 | A container is composed of a CWMessage instance which might be nil, a parent, |
| 34 | child and next CWContainer instances. For a full description of the implemented |
| 35 | algorithm, see <a href="http://www.jwz.org/doc/threading.html">message threading</a>. |
| 36 | Instance variables of this class must be accessed directly (ie., without |
| 37 | an accessor) - for performance reasons. |
| 38 | */ |
| 39 | @interface CWContainer : NSObject |
| 40 | { |
| 41 | @public |
| 42 | CWContainer *parent, *child, *next; |
| 43 | CWMessage *message; |
| 44 | } |
| 45 | |
| 46 | /*! |
| 47 | @method setParent: |
| 48 | @discussion This method is used to set the parent CWContainer of the receiver. |
| 49 | @param theParent The parent CWContainer, which might be nil if the receiver |
| 50 | is part of the root set. |
| 51 | */ |
| 52 | - (void) setParent: (CWContainer *) theParent; |
| 53 | |
| 54 | /*! |
| 55 | @method setChild: |
| 56 | @discussion This method is used to add the specified child to the list |
| 57 | of children. |
| 58 | @param theChild The child to add which can be nil to remove the first child. |
| 59 | */ |
| 60 | - (void) setChild: (CWContainer *) theChild; |
| 61 | |
| 62 | /*! |
| 63 | @method childAtIndex: |
| 64 | @discussion This method is used to get the child at the specified index. |
| 65 | @param theIndex The index of the child, which is 0 based. |
| 66 | @result The CWContainer instance. |
| 67 | */ |
| 68 | - (CWContainer *) childAtIndex: (unsigned int) theIndex; |
| 69 | |
| 70 | /*! |
| 71 | @method count |
| 72 | @discussion This method is used to obtain the number of children of |
| 73 | the receiver. |
| 74 | @result The number of children. |
| 75 | */ |
| 76 | - (unsigned int) count; |
| 77 | |
| 78 | /*! |
| 79 | @method setNext: |
| 80 | @discussion This method is used to set the next element in |
| 81 | sibling list. |
| 82 | @param theNext The next element, or nil if there's none. |
| 83 | */ |
| 84 | - (void) setNext: (CWContainer *) theNext; |
| 85 | |
| 86 | /*! |
| 87 | @method childrenEnumerator |
| 88 | @discussion This method is used to obtain all children of the receiver. |
| 89 | @result All children, as a NSEnumerator instance. |
| 90 | */ |
| 91 | - (NSEnumerator *) childrenEnumerator; |
| 92 | |
| 93 | @end |
| 94 | |
| 95 | #endif // _Pantomime_H_CWContainer |