Main Page Modules Class Hierarchy Compound List File List Compound Members

# cnetmod.h

    00001 //=========================================================================
    00002 //
    00003 // CNETMOD.H - part of
    00004 //                          OMNeT++
    00005 //           Discrete System Simulation in C++
    00006 //
    00007 //   Written by:  Zoltan Vass, 1996
    00008 //
    00009 //   Contents:
    00010 //      Declaration of class cNetMod:
    00011 //            the interface module for distributed simulation.
    00012 //
    00013 //   Changes/rewrite:
    00014 //      Andras Varga  Oct 14 1996 - Aug 1997
    00015 //
    00016 //=========================================================================
    00017
    00018 /*--------------------------------------------------------------*
    00019   Copyright (C) 1992-2003 Andras Varga
    00020
    00021   This file is distributed WITHOUT ANY WARRANTY. See the file
    00022   `license' for details on this and other legal matters.
    00023 *--------------------------------------------------------------*/
    00024
    00025 #ifndef __CNETMOD_H
    00026 #define __CNETMOD_H
    00027
    00028 #include "cmodule.h"
    00029
    00030 class cSimulation;
    00031 class cMessage;
    00032
    00033
    00034 // is_started_as_master:
    00035 //   called from envir to determine whether this is a master or slave
    00036 SIM_API int is_started_as_master();
    00037
    00038 //===========================================================================
    00039
    00060 class SIM_API cNetMod : public cModule
    00061 {
    00062     friend class cSimulation;
    00063
    00064   protected:
    00065     int segments;
    00066     cMessage *after_modinit_msg;
    00067
    00068   public:
    00071
    00075     cNetMod(const cNetMod& m) : cModule(m)
    00076             {setName(m.name());after_modinit_msg=NULL;operator=(m);}
    00077
    00081     cNetMod();
    00082
    00086     virtual ~cNetMod() {}
    00087
    00092     virtual cNetMod& operator=(const cNetMod& other);
    00094
    00097
    00101     virtual bool isSimple() const {return false;}
    00102
    00107     virtual void scheduleStart(simtime_t t) {}
    00108
    00113     virtual void deleteModule() {}
    00114
    00119     virtual bool callInitialize(int stage);
    00120
    00125     virtual void callFinish();
    00127
    00130
    00134     virtual void init()=0;
    00136
    00139
    00143     virtual const char *localhost()=0;
    00144
    00150     int isLocalMachineIn(const cArray& m);
    00152
    00155
    00159     virtual int net_addgate(cModule *mod, int gate, char tp) {return 0;}
    00160
    00164     virtual cGate *ingate(int g)=0;
    00165
    00169     virtual cGate *ingate(const char *s)=0;
    00170
    00174     virtual int findingate(const char *s)=0;
    00175
    00179     virtual cGate *outgate(int g)=0;
    00180
    00184     virtual cGate *outgate(const char *s)=0;
    00185
    00189     virtual int findoutgate(const char *s)=0;
    00191
    00199
    00203     virtual void putmsg_onconsole(const char *s) = 0;
    00204
    00208     virtual void puts_onconsole(const char *s) = 0;
    00209
    00213     virtual bool gets_onconsole(const char *promptstr, char *buf, int len) = 0;
    00214
    00218     virtual bool askyesno_onconsole(const char *question) = 0;
    00220
    00223
    00227     virtual short start_segments(cArray& host_list, int ac, char *av[]) = 0;
    00228
    00232     virtual void setup_connections()=0;
    00233
    00237     virtual void clear() {gatev.clear();}
    00238
    00242     virtual void stop_all_segments()=0;
    00243
    00247     virtual void request_stopsimulation()=0;
    00248
    00252     virtual int receive_runnumber() = 0;
    00253
    00257     virtual void send_runnumber(int run_nr) = 0;
    00259
    00262
    00266     virtual void restart() {}
    00267
    00271     virtual void sync_after_modinits()=0; // sync before processing first 'real' event
    00272
    00277     virtual void process_netmsgs()=0;
    00278
    00284     virtual void process_netmsg_blocking()=0;
    00285
    00289     virtual void send_syncpoint(simtime_t t, int gate) = 0;
    00290
    00294     virtual void send_cancelsyncpoint(simtime_t t, int gate) = 0;
    00295
    00299     virtual bool block_on_syncpoint(simtime_t t) = 0;
    00301 };
    00302
    00303 #endif
    00304
    00305