OMNeT++ Simulation Library  6.0.3
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;}
105 
111  virtual void setDelay(double d);
112 
116  virtual void setDisabled(bool d);
117 
122  virtual simtime_t getDelay() const {checkState(); return delay;}
123 
129  virtual bool isDisabled() const override {checkState(); return flags & FL_ISDISABLED;}
131 
137  virtual void initialize() override;
138 
143  virtual Result processMessage(cMessage *msg, const SendOptions& options, simtime_t t) override;
145 };
146 
147 } // namespace omnetpp
148 
149 
150 #endif
151 
152 
omnetpp::simsignal_t
int simsignal_t
Signal handle.
Definition: clistener.h:27
omnetpp::cDelayChannel
Channel with propagation delay.
Definition: cdelaychannel.h:29
omnetpp::cDelayChannel::isBusy
virtual bool isBusy() const override
Definition: cdelaychannel.h:103
omnetpp::cDelayChannel::calculateDuration
virtual simtime_t calculateDuration(cMessage *msg) const override
Definition: cdelaychannel.h:93
omnetpp::cChannel
Base class for channels.
Definition: cchannel.h:46
omnetpp::SimTime
int64_t-based, base-10 fixed-point simulation time.
Definition: simtime.h:66
omnetpp::cDelayChannel::getTransmissionFinishTime
virtual simtime_t getTransmissionFinishTime() const override
Definition: cdelaychannel.h:98
omnetpp::SendOptions
Options for the cSimpleModule::send() and cSimpleModule::sendDirect() calls.
Definition: csimplemodule.h:82
omnetpp::cDelayChannel::getDelay
virtual simtime_t getDelay() const
Definition: cdelaychannel.h:122
omnetpp::cDelayChannel::~cDelayChannel
virtual ~cDelayChannel()
Definition: cdelaychannel.h:69
omnetpp::cDelayChannel::isDisabled
virtual bool isDisabled() const override
Definition: cdelaychannel.h:129
SIMTIME_ZERO
#define SIMTIME_ZERO
Zero simulation time.
Definition: simtime_t.h:70
omnetpp::cMessage
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition: cmessage.h:95
omnetpp::cDelayChannel::cDelayChannel
cDelayChannel(const char *name=nullptr)
Definition: cdelaychannel.h:64
omnetpp::cRuntimeError
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
omnetpp::cDelayChannel::isTransmissionChannel
virtual bool isTransmissionChannel() const override
Definition: cdelaychannel.h:83
omnetpp::cDelayChannel::getNominalDatarate
virtual double getNominalDatarate() const override
Definition: cdelaychannel.h:88