From dbf9983611a5c69a2a19ad87b2ebf09dc98263e2 Mon Sep 17 00:00:00 2001 From: Jonathon Lynn Duerig <duerig@flux.utah.edu> Date: Wed, 6 Sep 2006 01:00:14 +0000 Subject: [PATCH] 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. --- pelab/magent/DelaySensor.cc | 4 ++-- pelab/magent/DelaySensor.h | 7 ++++--- pelab/magent/EwmaThroughputSensor.cc | 4 ++-- pelab/magent/EwmaThroughputSensor.h | 8 ++++---- pelab/magent/MaxDelaySensor.cc | 6 ++++-- pelab/magent/MaxDelaySensor.h | 13 +++++++------ pelab/magent/MinDelaySensor.cc | 2 +- pelab/magent/MinDelaySensor.h | 6 +++--- pelab/magent/PacketSensor.cc | 2 +- pelab/magent/PacketSensor.h | 4 ++-- pelab/magent/SensorList.h | 17 +++++++++++------ pelab/magent/ThroughputSensor.cc | 4 ++-- pelab/magent/ThroughputSensor.h | 7 ++++--- 13 files changed, 47 insertions(+), 37 deletions(-) diff --git a/pelab/magent/DelaySensor.cc b/pelab/magent/DelaySensor.cc index 3a090433e3..b90fb0d1a2 100644 --- a/pelab/magent/DelaySensor.cc +++ b/pelab/magent/DelaySensor.cc @@ -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; diff --git a/pelab/magent/DelaySensor.h b/pelab/magent/DelaySensor.h index 2c3a747059..1ece4df89d 100644 --- a/pelab/magent/DelaySensor.h +++ b/pelab/magent/DelaySensor.h @@ -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 diff --git a/pelab/magent/EwmaThroughputSensor.cc b/pelab/magent/EwmaThroughputSensor.cc index 77cfeb0c3c..bc462b2a08 100644 --- a/pelab/magent/EwmaThroughputSensor.cc +++ b/pelab/magent/EwmaThroughputSensor.cc @@ -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) diff --git a/pelab/magent/EwmaThroughputSensor.h b/pelab/magent/EwmaThroughputSensor.h index 409f6805b0..3e6aabaa3c 100644 --- a/pelab/magent/EwmaThroughputSensor.h +++ b/pelab/magent/EwmaThroughputSensor.h @@ -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 diff --git a/pelab/magent/MaxDelaySensor.cc b/pelab/magent/MaxDelaySensor.cc index 95c51d5a73..35f9bfb69e 100644 --- a/pelab/magent/MaxDelaySensor.cc +++ b/pelab/magent/MaxDelaySensor.cc @@ -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) diff --git a/pelab/magent/MaxDelaySensor.h b/pelab/magent/MaxDelaySensor.h index 4413666e78..945459a857 100644 --- a/pelab/magent/MaxDelaySensor.h +++ b/pelab/magent/MaxDelaySensor.h @@ -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; diff --git a/pelab/magent/MinDelaySensor.cc b/pelab/magent/MinDelaySensor.cc index 2b67e0daf5..2ceb7d594a 100644 --- a/pelab/magent/MinDelaySensor.cc +++ b/pelab/magent/MinDelaySensor.cc @@ -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; diff --git a/pelab/magent/MinDelaySensor.h b/pelab/magent/MinDelaySensor.h index a6c59bb86e..03501b2edb 100644 --- a/pelab/magent/MinDelaySensor.h +++ b/pelab/magent/MinDelaySensor.h @@ -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; }; diff --git a/pelab/magent/PacketSensor.cc b/pelab/magent/PacketSensor.cc index b5f079dcc6..aa04892846 100644 --- a/pelab/magent/PacketSensor.cc +++ b/pelab/magent/PacketSensor.cc @@ -6,7 +6,7 @@ using namespace std; -PacketSensor::PacketSensor(StateSensor * newState) +PacketSensor::PacketSensor(StateSensor const * newState) : globalSequence() , state(newState) { diff --git a/pelab/magent/PacketSensor.h b/pelab/magent/PacketSensor.h index 3457dd0774..5f1892e2a5 100644 --- a/pelab/magent/PacketSensor.h +++ b/pelab/magent/PacketSensor.h @@ -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 diff --git a/pelab/magent/SensorList.h b/pelab/magent/SensorList.h index 4f1bfa292b..d0dee4f099 100755 --- a/pelab/magent/SensorList.h +++ b/pelab/magent/SensorList.h @@ -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 diff --git a/pelab/magent/ThroughputSensor.cc b/pelab/magent/ThroughputSensor.cc index b394732b73..a76882853a 100644 --- a/pelab/magent/ThroughputSensor.cc +++ b/pelab/magent/ThroughputSensor.cc @@ -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) diff --git a/pelab/magent/ThroughputSensor.h b/pelab/magent/ThroughputSensor.h index 21dcfc6947..7f8f7696a3 100644 --- a/pelab/magent/ThroughputSensor.h +++ b/pelab/magent/ThroughputSensor.h @@ -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 -- GitLab