00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "BAPTVVessel.h"
00026
00027 using std::cout;
00028 using std::endl;
00029
00030
00031 TVVessel::TVVessel()
00032 : mID(0), mLength(0), mStartTimeZone(0), mEndTimeZone(0), mSection(0),
00033 mImport(0), mExport(0), mArrival(0), mDeparture(0), mContainers(0),
00034 mTranshipment(0)
00035 {
00036 }
00037
00038
00039 TVVessel::TVVessel(int anID, int aLength)
00040 : mID(anID), mLength(aLength), mStartTimeZone(0), mEndTimeZone(0),
00041 mSection(0), mImport(0), mExport(0), mArrival(0), mDeparture(0),
00042 mContainers(0), mTranshipment(0)
00043 {
00044 }
00045
00046
00047 TVVessel::TVVessel(const TVVessel& aVessel)
00048 : mID(aVessel.mID), mLength(aVessel.mLength),
00049 mImport(aVessel.mImport), mExport(aVessel.mExport),
00050 mTranshipment(aVessel.mTranshipment),
00051 mContainers(aVessel.mContainers),
00052 mStartTimeZone(aVessel.mStartTimeZone),
00053 mEndTimeZone(aVessel.mEndTimeZone),
00054 mArrival(aVessel.mArrival),
00055 mDeparture(aVessel.mDeparture),
00056 mSection(aVessel.mSection),
00057 mNeighbours(aVessel.mNeighbours),
00058 mPotentialDestinations(aVessel.mPotentialDestinations)
00059 {
00060 }
00061
00062
00063 TVVessel::~TVVessel()
00064 {
00065 }
00066
00067
00068 TVVessel& TVVessel::operator=(const TVVessel& aVessel)
00069 {
00070 if (this != &aVessel)
00071 {
00072 mID = aVessel.mID;
00073 mLength = aVessel.mLength;
00074 mImport = aVessel.mImport;
00075 mExport = aVessel.mExport;
00076 mTranshipment = aVessel.mTranshipment;
00077 mContainers = aVessel.mContainers;
00078 mStartTimeZone = aVessel.mStartTimeZone;
00079 mEndTimeZone = aVessel.mEndTimeZone;
00080 mArrival = aVessel.mArrival;
00081 mDeparture = aVessel.mDeparture;
00082 mSection = aVessel.mSection;
00083 mNeighbours = aVessel.mNeighbours;
00084 mPotentialDestinations = aVessel.mPotentialDestinations;
00085 }
00086
00087 return (*this);
00088 }
00089
00090
00091 void TVVessel::Print(const int& aWidth, const int& aDetail) const
00092 {
00093 cout << "TVVessel" << setw(5) << mID
00094 << ", length =" << setw(4) << mLength
00095 << ", [" << setw(3) << mStartTimeZone
00096 << "," << setw(3) << mEndTimeZone
00097
00098
00099 << "], in section" << setw(3) << mSection << endl;
00100
00101 if (aDetail > 1)
00102 {
00103 cout << tab(3) << "neighbours =";
00104
00105 int v;
00106
00107 forall(v, mNeighbours)
00108 {
00109 cout << setw(5) << v;
00110 }
00111
00112 cout << endl;
00113
00114 cout << tab(3) << "destinations =";
00115
00116 forall(v, mPotentialDestinations)
00117 {
00118 cout << setw(3) << v;
00119 }
00120
00121 cout << endl;
00122 }
00123
00124 cout << endl;
00125 }
00126
00127
00128 istream& operator>>(istream& anIS, TVVessel& aVessel)
00129 {
00130 return anIS;
00131 }
00132
00133
00134 ostream& operator<<(ostream& anOS, const TVVessel& aVessel)
00135 {
00136 return anOS << "vessel " << setw(3) << aVessel.mID;
00137 }
00138
00139
00140 int compare(const TVVessel& aV1, const TVVessel& aV2)
00141 {
00142 return compare(aV1.mID, aV2.mID);
00143 }
00144
00145
00146 int TVVessel::ID() const
00147 {
00148 return mID;
00149 }
00150
00151
00152 int TVVessel::Length() const
00153 {
00154 return mLength;
00155 }
00156
00157
00158 int TVVessel::Import() const
00159 {
00160 return mImport;
00161 }
00162
00163
00164 int TVVessel::Export() const
00165 {
00166 return mExport;
00167 }
00168
00169
00170 int TVVessel::Transhipment() const
00171 {
00172 return mTranshipment;
00173 }
00174
00175
00176 int TVVessel::Containers() const
00177 {
00178 return mContainers;
00179 }
00180
00181
00182 int TVVessel::StartTimeZone() const
00183 {
00184 return mStartTimeZone;
00185 }
00186
00187
00188 int TVVessel::EndTimeZone() const
00189 {
00190 return mEndTimeZone;
00191 }
00192
00193
00194 int TVVessel::Arrival() const
00195 {
00196 return mArrival;
00197 }
00198
00199
00200 int TVVessel::Departure() const
00201 {
00202 return mDeparture;
00203 }
00204
00205
00206 int TVVessel::Section() const
00207 {
00208 return mSection;
00209 }
00210
00211
00212 const set<int>& TVVessel::Neighbours() const
00213 {
00214 return mNeighbours;
00215 }
00216
00217
00218 const set<int>& TVVessel::Destinations() const
00219 {
00220 return mPotentialDestinations;
00221 }
00222
00223
00224 int TVVessel::Import(int aNumContainers)
00225 {
00226 mContainers += aNumContainers;
00227 mImport = aNumContainers;
00228 return mImport;
00229 }
00230
00231
00232 int TVVessel::Export(int aNumContainers)
00233 {
00234 mContainers += aNumContainers;
00235 mExport = aNumContainers;
00236 return mExport;
00237 }
00238
00239
00240 void TVVessel::AddTranshipment(int aNumContainers)
00241 {
00242 mContainers += aNumContainers;
00243 mTranshipment += aNumContainers;
00244 }
00245
00246
00247 int TVVessel::StartTimeZone(int aTimeZone)
00248 {
00249 mStartTimeZone = aTimeZone;
00250 return mStartTimeZone;
00251 }
00252
00253
00254 int TVVessel::EndTimeZone(int aTimeZone)
00255 {
00256 mEndTimeZone = aTimeZone;
00257 return mEndTimeZone;
00258 }
00259
00260
00261 int TVVessel::Arrival(int aTime)
00262 {
00263 mArrival = aTime;
00264 return mArrival;
00265 }
00266
00267
00268 int TVVessel::Departure(int aTime)
00269 {
00270 mDeparture = aTime;
00271 return mDeparture;
00272 }
00273
00274
00275 int TVVessel::Section(int aSection)
00276 {
00277 mSection = aSection;
00278 return mSection;
00279 }
00280
00281
00282 void TVVessel::AddNeighbour(int aVessel)
00283 {
00284 assert(!mNeighbours.member(aVessel));
00285 mNeighbours.insert(aVessel);
00286 }
00287
00288
00289 void TVVessel::AddDestination(int aSection)
00290 {
00291 mPotentialDestinations.insert(aSection);
00292 }
00293
00294
00295 void TVVessel::RemoveDestination(int aSection)
00296 {
00297 assert(mPotentialDestinations.member(aSection));
00298 mPotentialDestinations.del(aSection);
00299 }
00300