cobject.h

00001 //==========================================================================
00002 //  COBJECT.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //  Declaration of the following classes:
00007 //    cObject : general base class
00008 //
00009 //==========================================================================
00010 
00011 /*--------------------------------------------------------------*
00012   Copyright (C) 1992-2008 Andras Varga
00013   Copyright (C) 2006-2008 OpenSim Ltd.
00014 
00015   This file is distributed WITHOUT ANY WARRANTY. See the file
00016   `license' for details on this and other legal matters.
00017 *--------------------------------------------------------------*/
00018 
00019 #ifndef __COBJECT_H
00020 #define __COBJECT_H
00021 
00022 #include <string>
00023 #include "simkerneldefs.h"
00024 #include "simutil.h"
00025 #include "cvisitor.h"
00026 
00027 // Note: we include regmacros.h here in order to prevent the compiler from
00028 // misunderstanding Register_Class() in other source files as a function declaration
00029 #include "regmacros.h"
00030 
00031 NAMESPACE_BEGIN
00032 
00033 class cCommBuffer;
00034 class cClassDescriptor;
00035 class cOwnedObject;
00036 
00037 
00070 class SIM_API cObject
00071 {
00072     friend class cOwnedObject;
00073     friend class cDefaultList;
00074 
00075   public:
00076     // internal: returns a descriptor object for this object
00077     virtual cClassDescriptor *getDescriptor();
00078 
00079   protected:
00080     // internal
00081     virtual void ownedObjectDeleted(cOwnedObject *obj);
00082 
00083     // internal
00084     virtual void yieldOwnership(cOwnedObject *obj, cObject *to);
00085 
00086   public:
00091     cObject() {}
00092 
00099     cObject(const cObject& other) {}
00100 
00106     virtual ~cObject();
00107 
00113     virtual const char *getClassName() const;
00114 
00121     virtual const char *getName() const  {return "";}
00122 
00126     bool isName(const char *s) const {return !opp_strcmp(getName(),s);}
00127 
00136     virtual const char *getFullName() const  {return getName();}
00137 
00145     virtual std::string getFullPath() const;
00146 
00156     virtual std::string info() const;
00157 
00164     virtual std::string detailedInfo() const;
00165 
00171     virtual cObject *dup() const;
00173 
00174   protected:
00182 
00190     virtual void take(cOwnedObject *obj);
00191 
00200     virtual void drop(cOwnedObject *obj);
00201 
00215     void dropAndDelete(cOwnedObject *obj);
00217 
00218   public:
00229     virtual void parsimPack(cCommBuffer *buffer);
00230 
00234     virtual void parsimUnpack(cCommBuffer *buffer);
00236 
00243     virtual cObject *getOwner() const {return NULL;}
00244 
00252     virtual bool isOwnedObject() const {return false;}
00253 
00262     virtual void forEachChild(cVisitor *v);
00263 
00276     cObject *findObject(const char *name, bool deep=true);
00278 
00287     void copyNotSupported() const;
00289 };
00290 
00291 
00309 class noncopyable
00310 {
00311   protected:
00312     noncopyable() {}
00313     ~noncopyable() {}
00314   private:
00315     // private, and in addition unimplemented (usage causes missing linker symbol)
00316     noncopyable(const noncopyable& x);
00317     const noncopyable& operator=(const noncopyable&);
00318 };
00319 
00320 NAMESPACE_END
00321 
00322 
00323 #endif
00324 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3