cdelaychannel.h Source File

API: cdelaychannel.h Source File
API
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
22namespace omnetpp {
23
29class 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:
59
64 explicit cDelayChannel(const char *name=nullptr) : cChannel(name) {}
65
69 virtual ~cDelayChannel() {}
70
75 static cDelayChannel *create(const char *name);
77
80
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
108
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
134
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
cChannel(const char *name=nullptr)
virtual simtime_t getTransmissionFinishTime() const override
Definition cdelaychannel.h:98
static cDelayChannel * create(const char *name)
virtual void handleParameterChange(const char *parname) override
cDelayChannel(const char *name=nullptr)
Definition cdelaychannel.h:64
virtual bool isBusy() const override
Definition cdelaychannel.h:103
virtual double getNominalDatarate() const override
Definition cdelaychannel.h:88
virtual simtime_t calculateDuration(cMessage *msg) const override
Definition cdelaychannel.h:93
virtual void setDelay(double d)
virtual simtime_t getDelay() const
Definition cdelaychannel.h:122
virtual void initialize() override
virtual bool isDisabled() const override
Definition cdelaychannel.h:129
virtual void setDisabled(bool d)
virtual bool isTransmissionChannel() const override
Definition cdelaychannel.h:83
virtual Result processMessage(cMessage *msg, const SendOptions &options, simtime_t t) override
virtual ~cDelayChannel()
Definition cdelaychannel.h:69
The message class in OMNeT++. cMessage objects may represent events, messages, jobs or other entities...
Definition cmessage.h:96
Thrown when the simulation kernel or other components detect a runtime error.
Definition cexception.h:343
int simsignal_t
Signal handle.
Definition clistener.h:37
SimTime simtime_t
Represents simulation time.
Definition simtime_t.h:40
#define SIMTIME_ZERO
Zero simulation time.
Definition simtime_t.h:70
Options for the cSimpleModule::send() and cSimpleModule::sendDirect() calls.
Definition csimplemodule.h:82