Main Page Modules Class Hierarchy Compound List File List Compound Members

# cchannel.h

    00001 //==========================================================================
    00002 //   CCHANNEL.H  -  header for
    00003 //                             OMNeT++
    00004 //            Discrete System Simulation in C++
    00005 //
    00006 //
    00007 //  Declaration of the following classes:
    00008 //    cChannel : channel class
    00009 //
    00010 //==========================================================================
    00011
    00012 /*--------------------------------------------------------------*
    00013   Copyright (C) 1992-2003 Andras Varga
    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 __CCHANNEL_H
    00020 #define __CCHANNEL_H
    00021
    00022 #include "cobject.h"
    00023 #include "cpar.h"
    00024 #include "carray.h"
    00025
    00026 //=== classes mentioned:
    00027 class cPar;
    00028 class cGate;
    00029 class cLinkType;
    00030 class cArray;
    00031 class cMessage;
    00032
    00033
    00040 class SIM_API cChannel : public cObject
    00041 {
    00042     friend class cGate; // to call setFromGate()
    00043   protected:
    00044     cLinkType *linkp;   // link prototype or NULL
    00045     cArray *parlistp;   // ptr to list of all parameters
    00046     cGate *fromgatep;   // gate the channel is attached to
    00047     // FIXME: add on/off modelling? or to cGate?
    00048
    00049   protected:
    00050     // helper functions
    00051     void _createparlist();
    00052     cArray& _parList() {if (!parlistp) _createparlist(); return *parlistp;}
    00053     void setFromGate(cGate *g) {fromgatep=g;}
    00054
    00055   public:
    00058
    00062     cChannel(const cChannel& ch);
    00063
    00067     explicit cChannel(const char *name=NULL, cLinkType *l=NULL);
    00068
    00072     virtual ~cChannel();
    00073
    00078     cChannel& operator=(const cChannel& msg);
    00080
    00083
    00088     virtual cObject *dup() const  {return new cChannel(*this);}
    00089
    00094     virtual void info(char *buf);
    00095
    00100     virtual void forEach( ForeachFunc do_fn );
    00101
    00106     virtual void writeContents(ostream& os);
    00107
    00113     virtual int netPack();
    00114
    00120     virtual int netUnpack();
    00122
    00125
    00129     cGate *fromGate() const {return fromgatep;}
    00130
    00134     cLinkType *link() const {return linkp;}
    00136
    00139
    00143     virtual cPar& addPar(const char *s)  {cPar *p=new cPar(s);_parList().add(p);return *p;}
    00144
    00148     virtual cPar& addPar(cPar *p)  {_parList().add(p); return *p;}
    00149
    00154     virtual cPar& par(int n);
    00155
    00160     virtual cPar& par(const char *s);
    00161
    00166     virtual int findPar(const char *s) const;
    00167
    00171     virtual bool hasPar(const char *s) const {return findPar(s)>=0;}
    00172
    00179     virtual cArray& parList();
    00181
    00184
    00189     virtual void deliver(cMessage *msg, simtime_t at);
    00191 };
    00192
    00193
    00199 class SIM_API cSimpleChannel : public cChannel
    00200 {
    00201   private:
    00202     cPar *disabledp;    // FIXME implement! if not NULL and value is nonzero, channel is down (will delete all packets). Points to an object in the parlist.
    00203     cPar *delayp;       // propagation delay or NULL. Points to an object in the parlist.
    00204     cPar *errorp;       // bit error rate or NULL. Points to an object in the parlist.
    00205     cPar *dataratep;    // data rate or NULL. Points to an object in the parlist.
    00206     simtime_t transm_finishes; // end of transmission; used if dataratep!=NULL
    00207
    00208   public:
    00211
    00215     cSimpleChannel(const cSimpleChannel& ch);
    00216
    00220     explicit cSimpleChannel(const char *name=NULL, cLinkType *l=NULL);
    00221
    00225     virtual ~cSimpleChannel();
    00226
    00231     cSimpleChannel& operator=(const cSimpleChannel& msg);
    00233
    00236
    00241     virtual cObject *dup() const  {return new cSimpleChannel(*this);}
    00242
    00247     virtual void info(char *buf);
    00248
    00253     virtual void forEach( ForeachFunc do_fn );
    00254
    00259     virtual void writeContents(ostream& os);
    00260
    00266     virtual int netPack();
    00267
    00273     virtual int netUnpack();
    00275
    00278
    00285     virtual void setDelay(cPar *p);
    00286
    00297     virtual void setError(cPar *p);
    00298
    00309     virtual void setDatarate(cPar *p);
    00310
    00314     virtual cPar *delay() const     {return delayp;}
    00315
    00319     virtual cPar *error() const     {return errorp;}
    00320
    00324     virtual cPar *datarate() const  {return dataratep;}
    00326
    00329
    00333     virtual cPar& addPar(const char *s);
    00334
    00338     virtual cPar& addPar(cPar *p);
    00340
    00343
    00351     virtual bool isBusy() const;
    00352
    00360     virtual simtime_t transmissionFinishes() const {return transm_finishes;}
    00362
    00365
    00369     virtual void deliver(cMessage *msg, simtime_t at);
    00371 };
    00372
    00373 #endif
    00374
    00375