cdefaultlist.h

00001 //==========================================================================
00002 //  CDEFAULTLIST.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //
00008 //  Declaration of the following classes:
00009 //    cDefaultList : holds a set of cObjects
00010 //
00011 //==========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 1992-2005 Andras Varga
00015 
00016   This file is distributed WITHOUT ANY WARRANTY. See the file
00017   `license' for details on this and other legal matters.
00018 *--------------------------------------------------------------*/
00019 
00020 #ifndef __CDEFAULTLIST_H
00021 #define __CDEFAULTLIST_H
00022 
00023 #include "cobject.h"
00024 
00025 
00033 class SIM_API cDefaultList : public cObject
00034 {
00035   private:
00036     friend class cObject;
00037     cObject **vect;   // vector of objects
00038     int size;         // size of vector
00039     int count;        // number of elements stored
00040   public:
00041     static bool doGC; // whether garbage collection is necessary in destructor
00042 
00043   private:
00044     void construct();
00045     void doInsert(cObject *obj);
00046     virtual void ownedObjectDeleted(cObject *obj);
00047     virtual void yieldOwnership(cObject *obj, cObject *newOwner);
00048 
00049   public:
00050     // internal: called from module creation code in ctypes.cc
00051     void takeAllObjectsFrom(cDefaultList& other);
00052 
00053   protected:
00056 
00060     void take(cObject *obj);
00061 
00065     void drop(cObject *obj);
00066 
00067   public:
00070 
00074     cDefaultList(const cDefaultList& list);
00075 
00079     explicit cDefaultList(const char *name=NULL);
00080 
00084     virtual ~cDefaultList();
00085 
00089     cDefaultList& operator=(const cDefaultList& list);
00091 
00094 
00098     virtual cPolymorphic *dup() const  {return new cDefaultList(*this);}
00099 
00103     virtual bool isSoftOwner()  {return true;}
00104 
00109     virtual std::string info() const;
00110 
00115     virtual void forEachChild(cVisitor *v);
00116 
00121     virtual void netPack(cCommBuffer *buffer);
00122 
00127     virtual void netUnpack(cCommBuffer *buffer);
00129 
00131     // Note: we need long method names here because cModule subclasses from this class
00133 
00137     int defaultListItems() const {return count;}
00138 
00145     cObject *defaultListGet(int k);
00146 
00150     // Note: we need a long name here because cModule subclasses from this
00151     bool defaultListContains(cObject *obj) const;
00153 };
00154 
00155 #endif
00156 

Generated on Sat Oct 21 17:47:55 2006 for OMNeT++/OMNEST Simulation Library by  doxygen 1.4.6