Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

Collection.h

Go to the documentation of this file.
00001 /*
00002  * Collection.h
00003  *
00004  * Smalltalk like class library for C++
00005  * Abstract collection with common functionality. Header.
00006  *
00007  * Copyright (c) 2003 Milan Cermak
00008  */
00009 /*
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  */
00024 #ifndef __COLLECTION_H
00025 #define __COLLECTION_H
00026 
00027 #include <stlib/Object.h>
00028 #include <stlib/CollectionIterator.h>
00029 
00030 namespace Core {
00031 
00032 class Array;
00033 class OrderedCollection;
00034 class Set;
00035 class Stream;
00036 class String;
00037 class Visitor;
00038 
00039 class Collection : public Object
00040 {
00041   public:
00042     /* Class-accessing protocol */
00043     virtual String *className(void) const;
00044 
00045     /* Accessing protocol */
00047     virtual long capacity(void) const;
00049     virtual long size(void) const abstract;
00051     virtual Object *any(void) abstract;
00052 
00053     /* Adding protocol */
00054     virtual void add(Object *) abstract;
00055     virtual void addAll(Collection *);
00056 
00057     /* Converting protocol */
00058     virtual Array *asArray(void);
00059     virtual OrderedCollection *asOrderedCollection(void);
00060     virtual Set *asSet(void);
00061 
00062     /* Copying protocol */
00063     virtual Object *copy(void) abstract;
00064     virtual Object *copyEmpty(long size) abstract;
00065 
00066     /* Enumeration protocol */
00067     virtual Iterator *iterator(void) const;
00068 
00069     /* Printing protocol */
00070     virtual void printOn(Stream *stream) const;
00071     virtual String *printSeparatedBy(String *separator) const;
00072     virtual String *printSeparatedBy(const char *separator) const;
00073     virtual void printSeparatedOn(Stream *stream, String *separator) const;
00074     virtual void printSeparatedOn(Stream *stream, const char *separator) const;
00075 
00076     /* Removing protocol */
00077     virtual Object *remove(Object *) abstract;
00078     virtual void removeAll(Collection *items);
00079 
00080     /* Testing protocol */
00081     virtual bool includes(Object *);
00082     virtual bool isByteArray(void);
00083     virtual bool isEmpty(void);
00084     virtual bool isSequenceable(void) const;
00085 
00086     /* Visiting protocol */
00087     virtual void visitBy(Visitor *visitor);
00088 
00089   protected:
00090     /* Enumeration protocol */
00091     friend void CollectionIterator::next(void);
00092     virtual Object *privNextForIterator(CollectionIterator *iter) const abstract;
00093 
00094     /* Private protocol */
00095     virtual void emptyCheck(void);
00096     virtual long growSize(void);
00097 };
00098 
00099 };
00100 
00101 #endif /* __COLLECTION_H */

Generated on Mon Nov 27 09:47:54 2006 for Smalltalk like C++ Class Library by  doxygen 1.4.2