OMNeT++ Simulation Library  5.6.1
cdelaychannel.h
1 //==========================================================================
2 // CDELAYCHANNEL.H - header for
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 1992-2017 Andras Varga
10  Copyright (C) 2006-2017 OpenSim Ltd.
11 
12  This file is distributed WITHOUT ANY WARRANTY. See the file
13  `license' for details on this and other legal matters.
14 *--------------------------------------------------------------*/
15 
16 #ifndef __OMNETPP_CDELAYCHANNEL_H
17 #define __OMNETPP_CDELAYCHANNEL_H
18 
19 #include "cchannel.h"
20 #include "csimulation.h"
21 
22 namespace omnetpp {
23 
29 class SIM_API cDelayChannel : public cChannel //implies noncopyable
30 {
31  protected:
32  static simsignal_t messageSentSignal;
33  static simsignal_t messageDiscardedSignal;
34 
35  private:
36  enum {
37  FL_ISDISABLED = 1 << 10,
38  FL_DELAY_NONZERO = 1 << 11,
39  };
40 
41  simtime_t delay; // cached value of propagation delay parameter
42 
43  private:
44  // internal: checks whether parameters have been set up
45  void checkState() const {if (!parametersFinalized()) throw cRuntimeError(this, E_PARAMSNOTREADY);}
46 
47  protected:
48  // internal: update cached copies of parameters
49  void rereadPars();
50 
54  virtual void handleParameterChange(const char *parname) override;
55 
56  public:
64  explicit cDelayChannel(const char *name=nullptr) : cChannel(name) {}
65 
69  virtual ~cDelayChannel() {}
70 
75  static cDelayChannel *create(const char *name);
77 
83  virtual bool isTransmissionChannel() const override {return false;}
84 
88  virtual double getNominalDatarate() const override {return 0;}
89 
93  virtual simtime_t calculateDuration(cMessage *msg) const override {return 0;}
94 
98  virtual simtime_t getTransmissionFinishTime() const override {return SIMTIME_ZERO;}
99 
103  virtual bool isBusy() const override {return false;}
104 
108  virtual void forceTransmissionFinishTime(simtime_t t) override {}
110 
116  virtual void setDelay(double d);
117 
121  virtual void setDisabled(bool d);
122 
127  virtual simtime_t getDelay() const {checkState(); return delay;}
128 
134  virtual bool isDisabled() const {checkState(); return flags & FL_ISDISABLED;}
136 
142  virtual void initialize() override;
143 
148  virtual void processMessage(cMessage *msg, simtime_t t, result_t& result) override;
150 };
151 
152 } // namespace omnetpp
153 
154 
155 #endif
156 
157 
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition: cmessage.h:95
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:283
virtual bool isDisabled() const
Definition: cdelaychannel.h:134
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
Channel with propagation delay.
Definition: cdelaychannel.h:29
Allows returning multiple values from the processMessage() method.
Definition: cchannel.h:64
virtual bool isTransmissionChannel() const override
Definition: cdelaychannel.h:83
virtual bool isBusy() const override
Definition: cdelaychannel.h:103
#define SIMTIME_ZERO
Zero simulation time.
Definition: simtime_t.h:73
virtual ~cDelayChannel()
Definition: cdelaychannel.h:69
cDelayChannel(const char *name=nullptr)
Definition: cdelaychannel.h:64
virtual simtime_t calculateDuration(cMessage *msg) const override
Definition: cdelaychannel.h:93
Definition: cabstracthistogram.h:21
virtual void forceTransmissionFinishTime(simtime_t t) override
Definition: cdelaychannel.h:108
int simsignal_t
Signal handle.
Definition: clistener.h:24
virtual simtime_t getDelay() const
Definition: cdelaychannel.h:127
Base class for channels.
Definition: cchannel.h:34
virtual double getNominalDatarate() const override
Definition: cdelaychannel.h:88
virtual simtime_t getTransmissionFinishTime() const override
Definition: cdelaychannel.h:98