Commit dbf99836 authored by Jonathon Duerig's avatar Jonathon Duerig
Browse files

Changed the dependency declarations and their associated function declarations...

Changed the dependency declarations and their associated function declarations to reflect a previous unstated assumption: Functions called on dependencies do not change those dependencies. Now everything is declared const and that has been propagated throughout the system.
parent 41ca8e25
......@@ -8,8 +8,8 @@
using namespace std;
DelaySensor::DelaySensor(PacketSensor * newPacketHistory,
StateSensor * newState)
DelaySensor::DelaySensor(PacketSensor const * newPacketHistory,
StateSensor const * newState)
: state(newState)
{
lastDelay = 0;
......
......@@ -11,15 +11,16 @@ class StateSensor;
class DelaySensor : public Sensor
{
public:
DelaySensor(PacketSensor * newPacketHistory, StateSensor * newState);
DelaySensor(PacketSensor const * newPacketHistory,
StateSensor const * newState);
int getLastDelay(void) const;
protected:
virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet);
private:
int lastDelay;
PacketSensor * packetHistory;
StateSensor * state;
PacketSensor const * packetHistory;
StateSensor const * state;
};
#endif
......@@ -9,8 +9,8 @@
using namespace std;
EwmaThroughputSensor::EwmaThroughputSensor(
ThroughputSensor * newThroughputSource,
StateSensor * newState)
ThroughputSensor const * newThroughputSource,
StateSensor const * newState)
: maxThroughput(0)
, bandwidth(0.0)
, throughputSource(newThroughputSource)
......
......@@ -11,8 +11,8 @@ class StateSensor;
class EwmaThroughputSensor : public Sensor
{
public:
EwmaThroughputSensor(ThroughputSensor * newThroughputSource,
StateSensor * newState);
EwmaThroughputSensor(ThroughputSensor const * newThroughputSource,
StateSensor const * newState);
protected:
virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet);
......@@ -21,8 +21,8 @@ private:
int maxThroughput;
// And EWMA of the last several solid bandwidth measurements
double bandwidth;
ThroughputSensor * throughputSource;
StateSensor * state;
ThroughputSensor const * throughputSource;
StateSensor const * state;
};
#endif
......@@ -8,8 +8,10 @@
using namespace std;
MaxDelaySensor::MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState,
MinDelaySensor *newminDelay, PacketSensor *newpacketSensor)
MaxDelaySensor::MaxDelaySensor(DelaySensor const * newDelay,
StateSensor const * newState,
MinDelaySensor const * newminDelay,
PacketSensor const * newpacketSensor)
: maximum(0, 0.01)
, delay(newDelay)
, state(newState)
......
......@@ -16,17 +16,18 @@ class PacketSensor;
class MaxDelaySensor : public Sensor
{
public:
MaxDelaySensor(DelaySensor * newDelay, StateSensor * newState,
MinDelaySensor * newminDelay, PacketSensor * newpacketSensor);
MaxDelaySensor(DelaySensor const * newDelay, StateSensor const * newState,
MinDelaySensor const * newminDelay,
PacketSensor const * newpacketSensor);
protected:
virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet);
private:
Decayer maximum;
DelaySensor * delay;
StateSensor * state;
MinDelaySensor * mindelay;
PacketSensor * packetsensor;
DelaySensor const * delay;
StateSensor const * state;
MinDelaySensor const * mindelay;
PacketSensor const * packetsensor;
// The last delay we reported to the monitor
int lastreported;
......
......@@ -7,7 +7,7 @@
using namespace std;
MinDelaySensor::MinDelaySensor(DelaySensor * newDelay)
MinDelaySensor::MinDelaySensor(DelaySensor const * newDelay)
: minimum(1000000, -0.01), minDelay(1000000), lastreported(-1)
{
delay = newDelay;
......
......@@ -14,15 +14,15 @@ class DelaySensor;
class MinDelaySensor : public Sensor
{
public:
MinDelaySensor(DelaySensor * newDelay);
MinDelaySensor(DelaySensor const * newDelay);
// Note: This is the minimum RTT, not one-way delay
int getMinDelay() { return minDelay; }
int getMinDelay(void) const { return minDelay; }
protected:
virtual void localSend(PacketInfo * packet);
virtual void localAck(PacketInfo * packet);
private:
Decayer minimum;
DelaySensor * delay;
DelaySensor const * delay;
int minDelay;
int lastreported;
};
......
......@@ -6,7 +6,7 @@
using namespace std;
PacketSensor::PacketSensor(StateSensor * newState)
PacketSensor::PacketSensor(StateSensor const * newState)
: globalSequence()
, state(newState)
{
......
......@@ -13,7 +13,7 @@ class StateSensor;
class PacketSensor : public Sensor
{
public:
PacketSensor(StateSensor * newState);
PacketSensor(StateSensor const * newState);
// Get the size of the acknowledgement in bytes.
int getAckedSize(void) const;
// Find out if the packet in question is a retransmission
......@@ -42,7 +42,7 @@ private:
SentPacket globalSequence;
bool isRetransmit;
StateSensor * state;
StateSensor const * state;
};
#endif
......@@ -10,6 +10,11 @@
// check to each associated push function to see if that pointer is
// non-NULL.
// ASSUMPTION: Functions called through the dependency declarations
// are queries only. They do not change the sensor
// involved. Therefore, declare them const and any reference to them
// const and any query-functions in them const.
#ifndef SENSOR_LIST_H_STUB_2
#define SENSOR_LIST_H_STUB_2
......@@ -51,13 +56,13 @@ private:
void pushEwmaThroughputSensor(void);
private:
// Example dependency
NullSensor * depNullSensor;
NullSensor const * depNullSensor;
// Dependency pointers.
StateSensor * depStateSensor;
PacketSensor * depPacketSensor;
DelaySensor * depDelaySensor;
MinDelaySensor * depMinDelaySensor;
ThroughputSensor * depThroughputSensor;
StateSensor const * depStateSensor;
PacketSensor const * depPacketSensor;
DelaySensor const * depDelaySensor;
MinDelaySensor const * depMinDelaySensor;
ThroughputSensor const * depThroughputSensor;
};
#endif
......@@ -7,8 +7,8 @@
using namespace std;
ThroughputSensor::ThroughputSensor(PacketSensor * newPacketHistory,
StateSensor * newState)
ThroughputSensor::ThroughputSensor(PacketSensor const * newPacketHistory,
StateSensor const * newState)
: throughputInKbps(0)
, maxThroughput(0)
, packetHistory(newPacketHistory)
......
......@@ -13,7 +13,8 @@ class StateSensor;
class ThroughputSensor : public Sensor
{
public:
ThroughputSensor(PacketSensor * newPacketHistory, StateSensor * newState);
ThroughputSensor(PacketSensor const * newPacketHistory,
StateSensor const * newState);
int getThroughputInKbps(void) const;
protected:
virtual void localSend(PacketInfo * packet);
......@@ -22,8 +23,8 @@ private:
int throughputInKbps;
int maxThroughput;
Time lastAckTime;
PacketSensor * packetHistory;
StateSensor * state;
PacketSensor const * packetHistory;
StateSensor const * state;
};
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment