MSVehicleContainer.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // vehicles sorted by their departures
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright 2001-2010 DLR (http://www.dlr.de/) and contributors
00011 /****************************************************************************/
00012 //
00013 //   This program is free software; you can redistribute it and/or modify
00014 //   it under the terms of the GNU General Public License as published by
00015 //   the Free Software Foundation; either version 2 of the License, or
00016 //   (at your option) any later version.
00017 //
00018 /****************************************************************************/
00019 #ifndef MSVehicleContainer_h
00020 #define MSVehicleContainer_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
00025 // ===========================================================================
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031 
00032 #include <vector>
00033 #include <iostream>
00034 #include "MSNet.h"
00035 
00036 
00037 // ===========================================================================
00038 // class declarations
00039 // ===========================================================================
00040 class MSVehicle;
00041 
00042 
00043 // ===========================================================================
00044 // class definitions
00045 // ===========================================================================
00052 class MSVehicleContainer {
00053 public:
00055     typedef std::vector<MSVehicle*> VehicleVector;
00056 
00059     typedef std::pair<SUMOTime, VehicleVector> VehicleDepartureVector;
00060 
00061 public:
00063     MSVehicleContainer(size_t capacity=10);
00064 
00066     ~MSVehicleContainer();
00067 
00069     void add(MSVehicle *veh);
00070 
00072     void add(SUMOTime time, const VehicleVector &cont);
00073 
00075     bool anyWaitingFor(SUMOTime time) const;
00076 
00078     const VehicleVector &top();
00079 
00081     SUMOTime topTime() const;
00082 
00084     void pop();
00085 
00087     bool isEmpty() const;
00088 
00090     size_t size() const;
00091 
00093     void showArray() const;
00094 
00096     friend std::ostream &operator << (std::ostream &strm,
00097                                       MSVehicleContainer &cont);
00098 
00099 private:
00102     void addReplacing(const VehicleDepartureVector &cont);
00103 
00105     bool isFull() const;
00106 
00108     class VehicleDepartureVectorSortCrit {
00109     public:
00111         bool operator()(const VehicleDepartureVector& e1,
00112                         const VehicleDepartureVector& e2) const;
00113     };
00114 
00116     class DepartFinder {
00117     public:
00119         explicit DepartFinder(SUMOTime time);
00120 
00122         bool operator()(const VehicleDepartureVector& e) const;
00123 
00124     private:
00126         SUMOTime myTime;
00127     };
00128 
00130     int currentSize;
00131 
00133     typedef std::vector<VehicleDepartureVector> VehicleHeap;
00134 
00136     VehicleHeap array;
00137 
00139     void percolateDown(int hole);
00140 
00141 };
00142 
00143 
00144 #endif
00145 
00146 /****************************************************************************/
00147 

Generated on Wed May 5 00:06:32 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6