Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members  

cgate.h

00001 //==========================================================================
00002 //   CGATE.H  -  header for
00003 //                             OMNeT++
00004 //            Discrete System Simulation in C++
00005 //
00006 //
00007 //  Declaration of the following classes:
00008 //    cGate       : module gate
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 __CGATE_H
00020 #define __CGATE_H
00021 
00022 #include "cobject.h"
00023 
00024 //=== classes mentioned here:
00025 class  cGate;
00026 class  cModule;
00027 class  cPar;
00028 class  cMessage;
00029 class  cLinkType;
00030 class  cChannel;
00031 
00032 //==========================================================================
00033 
00042 class SIM_API cGate : public cObject
00043 {
00044     friend class cModule;
00045   protected:
00046     mutable char *fullname; // buffer to store full name of object
00047     int  serno;         // index if gate vector, 0 otherwise
00048     int  vectsize;      // gate vector size (-1 if not vector)
00049     char typ;           // type of gate: 'I' or 'O'
00050 
00051     cChannel *channelp; // channel object (if exists)
00052 
00053     cModule *omodp;     // owner module
00054     int gateid;         // gate number within the module
00055 
00056     cGate *fromgatep;   // previous and next gate
00057     cGate *togatep;     //   in the route
00058 
00059     opp_string dispstr; // the display string
00060 
00061     void (*notify_inspector)(cGate*,bool,void*); // to notify inspector about display string changes
00062     void *data_for_inspector;
00063 
00064   public:
00067 
00071     cGate(const cGate& gate);
00072 
00076     explicit cGate(const char *name, char tp);
00077 
00081     virtual ~cGate();
00082 
00087     cGate& operator=(const cGate& gate);
00089 
00092 
00097     virtual cObject *dup() const  {return new cGate(*this);}
00098 
00103     virtual void forEach(ForeachFunc f);
00104 
00109     virtual void info(char *buf);
00110 
00116     virtual const char *fullName() const;
00117 
00121     virtual const char *fullPath() const;
00122 
00127     virtual const char *fullPath(char *buffer, int bufsize) const;
00128 
00133     virtual void writeContents(ostream& os);
00135 
00140     // FIXME: why public?
00141     void deliver(cMessage *msg, simtime_t at);
00142 
00145 
00151     void setOwnerModule(cModule *m, int gid);
00152 
00158     void setIndex(int sn, int vs);
00160 
00163 
00172     void connectTo(cGate *g, cChannel *chan=NULL);
00173 
00180     void setFrom(cGate *g);
00181 
00188     void setTo(cGate *g);
00190 
00193 
00197     void setChannel(cChannel *ch);
00198 
00202     cChannel *channel() const {return channelp;}
00204 
00207 
00211     char type() const      {return typ;}
00212 
00216     cModule *ownerModule() const {return omodp;}
00217 
00222     int id() const         {return gateid;}
00223 
00227     bool isVector() const  {return vectsize>=0;}
00228 
00233     int index() const      {return serno;}
00234 
00239     int size()  const      {return vectsize<0?1:vectsize;}
00241 
00244 
00251     void setLink(cLinkType *l);
00252 
00260     void setDelay(cPar *p);
00261 
00269     void setError(cPar *p);
00270 
00278     void setDataRate(cPar *p);
00279 
00285     cLinkType *link() const;
00286 
00294     cPar *delay() const;
00295 
00303     cPar *error() const;
00304 
00312     cPar *datarate() const;
00314 
00317 
00323     bool isBusy() const;
00324 
00330     simtime_t transmissionFinishes() const;
00332 
00335 
00341     cGate *fromGate() const {return fromgatep;}
00342 
00348     cGate *toGate() const   {return togatep;}
00349 
00354     cGate *sourceGate() const;
00355 
00360     cGate *destinationGate() const;
00361 
00365     int routeContains(cModule *m, int g=-1);
00366 
00374     bool isConnectedOutside() const;
00375 
00383     bool isConnectedInside() const;
00384 
00390     bool isConnected() const;
00391 
00396     bool isRouteOK() const;
00398 
00401 
00416     void setDisplayString(const char *dispstr, bool immediate=true);
00417 
00422     const char *displayString() const;
00423 
00428     void setDisplayStringNotify(void (*notify_func)(cGate*,bool,void*), void *data);
00430 };
00431 
00432 #endif
00433 

Generated at Mon Jun 16 23:37:31 2003 for OMNeT++ by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001