Index

dkCollection

Purpose:

dkCollection is an abstract base class that represents a collection of DKAny objects, therefore it doesn't require a template. A collection may have a name; the default name is an empty string, but it could be set to anything. For example, this could be the name of the item type or table where the members belong.

dkCollection cannot evaluate a query, and only supports dkIterator, the base class for all iterators.

Class summary:

class dkCollection
{
public:
dkCollection();
 
   virtual dkCollection();
 
   virtual unsigned long cardinality() = 0;
   virtual DKAny* retrieveElementAt(dkIterator& where) = 0;
   virtual dkIterator *createIterator() = 0;
   virtual void addElement(const DKAny& element) = 0;
   virtual void insertElementAt(const DKAny& element, 
                                dkIterator& where) = 0;
   virtual void replaceElementAt(const DKAny& element, 
                                 dkIterator& where) = 0;
   virtual void removeElementAt(dkIterator& where) = 0;
   virtual void removeAllElements() = 0;
   virtual void apply(void (*function)(DKAny& ));
 
   virtual DKString getName() const;
   virtual void     setName(const char* collName);
   virtual dkDataObjectBase* getowner() = 0;
   virtual DKString getAssociatedAttrName() = 0;
};

Members:

Member functions

cardinality
Returns the number of elements in a collection.
virtual unsigned long cardinality() = 0;

retrieveElementAt
Returns the element that the iterator is pointing at.
virtual DKAny* retrieveElementAt(dkIterator& where) = 0;

createIterator
Creates a new iterator over this dkCollection object.
virtual dkIterator *createIterator() = 0;

addElement
Adds an element to the end of the collection, and invalidates all of the current iterators.
virtual void addElement(const DKAny& element) = 0;

insertElementAt
Adds a new element after the element that the supplied iterator is currently pointing to. The iterator is advanced to the new element, invalidating all other iterators.
virtual void insertElementAt(const DKAny& element, dkIterator& where) = 0;

replaceElementAt
Replaces the element the iterator is currently pointing at.
virtual void replaceElementAt(const DKAny& element, dkIterator& where) = 0;

removeElementAt
Removes the element the iterator is currently pointing at. The iterator is automatically advanced to the next element after this operation, invalidating all other iterators.
virtual void removeElementAt(dkIterator& where) = 0;

removeAllElements
Removes all elements in the collection, and invalidates all other iterators.
virtual void removeAllElements() = 0;

apply
Executes a caller-supplied function on every element in the collection. This method is often used to destroy the data portion of the elements before the collection is destroyed. This is because the collection elements are DKAny objects, and their destructors only destroy objects of which storage is managed by DKAny.
virtual void apply(void (*function)(DKAny& ));

getName
Gets the name of the collection.
virtual DKString getName() const;

setName
Sets the name of the collection with this method.
virtual void  setName(const char* collName);

getOwner
Gets the owner data object for this collection.
virtual dkDataObjectBase* getOwner() = 0;

getAssociatedAttrName
Gets the associated attribute name
virtual DKString getAssociatedAttrName() = 0;

(c) Copyright International Business Machines Corporation 1996, 2003. IBM Corp. All rights reserved.