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 cOwnedObjects
00010 //
00011 //==========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 1992-2008 Andras Varga
00015   Copyright (C) 2006-2008 OpenSim Ltd.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CDEFAULTLIST_H
00022 #define __CDEFAULTLIST_H
00023 
00024 #include "cownedobject.h"
00025 
00026 NAMESPACE_BEGIN
00027 
00028 
00038 class SIM_API cDefaultList : public cNoncopyableOwnedObject
00039 {
00040     friend class cObject;
00041     friend class cOwnedObject;
00042     friend class cChannelType;
00043 
00044   private:
00045     enum {FL_PERFORMFINALGC = 2};  // whether to delete owned objects in the destructor
00046 
00047   private:
00048     cOwnedObject **vect; // vector of objects
00049     int capacity;        // allocated size of vect[]
00050     int size;            // number of elements used in vect[] (0..size-1)
00051 
00052   private:
00053     void construct();
00054     void doInsert(cOwnedObject *obj);
00055     virtual void ownedObjectDeleted(cOwnedObject *obj);
00056     virtual void yieldOwnership(cOwnedObject *obj, cObject *newOwner);
00057 
00058   public:
00059     // internal: called from module creation code in ctypes.cc
00060     void takeAllObjectsFrom(cDefaultList& other);
00061 
00062   protected:
00065 
00069     void take(cOwnedObject *obj);
00070 
00074     void drop(cOwnedObject *obj);
00075 
00076   public:
00082     explicit cDefaultList(const char *name=NULL);
00083 
00087     virtual ~cDefaultList();
00089 
00095     virtual bool isSoftOwner() const {return true;}
00096 
00101     virtual std::string info() const;
00102 
00107     virtual void forEachChild(cVisitor *v);
00108 
00113     virtual void parsimPack(cCommBuffer *buffer);
00114 
00119     virtual void parsimUnpack(cCommBuffer *buffer);
00121 
00123     // Note: we need long method names here because cModule subclasses from this class
00125 
00131     bool getPerformFinalGC() const  {return flags&FL_PERFORMFINALGC;}
00132 
00154     virtual void setPerformFinalGC(bool b)  {setFlag(FL_PERFORMFINALGC,b);}
00155 
00159     int defaultListSize() const {return size;}
00160 
00166     cOwnedObject *defaultListGet(int k);
00167 
00171     // Note: we need a long name here because cModule subclasses from this
00172     bool defaultListContains(cOwnedObject *obj) const;
00174 };
00175 
00176 NAMESPACE_END
00177 
00178 
00179 #endif
00180 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3