SUMO - Simulation of Urban MObility
NIVissimTL.h
Go to the documentation of this file.
00001 /****************************************************************************/
00008 // -------------------
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 #ifndef NIVissimTL_h
00022 #define NIVissimTL_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 
00035 #include <map>
00036 #include <string>
00037 #include <vector>
00038 #include <utils/geom/PositionVector.h>
00039 #include <utils/geom/AbstractPoly.h>
00040 #include <utils/common/SUMOTime.h>
00041 
00042 
00043 class NBTrafficLightLogicCont;
00044 
00045 
00046 
00047 // ===========================================================================
00048 // class declarations
00049 // ===========================================================================
00050 class NBLoadedTLDef;
00051 class NBEdgeCont;
00052 
00053 class NIVissimTL {
00054 public:
00055     NIVissimTL(int id, const std::string& type, const std::string& name,
00056                SUMOTime absdur, SUMOTime offset);
00057     ~NIVissimTL();
00058 //    void computeBounding();
00059     std::string getType() const;
00060     int getID() const;
00061 
00062 public:
00063     static bool dictionary(int id, const std::string& type,
00064                            const std::string& name, SUMOTime absdur, SUMOTime offset);
00065     static bool dictionary(int id, NIVissimTL* o);
00066     static NIVissimTL* dictionary(int id);
00067 //    static std::vector<int> getWithin(const AbstractPoly &poly, SUMOReal offset);
00068     static void clearDict();
00069     static bool dict_SetSignals(NBTrafficLightLogicCont& tlc,
00070                                 NBEdgeCont& ec);
00071 
00072 public:
00073     class NIVissimTLSignal;
00074     class NIVissimTLSignalGroup;
00075     typedef std::map<int, NIVissimTLSignal*> SSignalDictType;
00076     typedef std::map<int, NIVissimTLSignalGroup*> SGroupDictType;
00077     typedef std::map<int, SSignalDictType> SignalDictType;
00078     typedef std::map<int, SGroupDictType> GroupDictType;
00079 
00083     class NIVissimTLSignal {
00084     public:
00085         NIVissimTLSignal(int lsaid, int id, const std::string& name,
00086                          const std::vector<int>& groupids, int edgeid, int laneno,
00087                          SUMOReal position, const std::vector<int>& assignedVehicleTypes);
00088         ~NIVissimTLSignal();
00089         bool isWithin(const PositionVector& poly) const;
00090         Position getPosition() const;
00091         bool addTo(NBEdgeCont& ec, NBLoadedTLDef* node) const;
00092 
00093     public:
00094         static bool dictionary(int lsaid, int id, NIVissimTLSignal* o);
00095         static NIVissimTLSignal* dictionary(int lsaid, int id);
00096         static void clearDict();
00097         static SSignalDictType getSignalsFor(int tlid);
00098 
00099     protected:
00100         int myLSA;
00101         int myID;
00102         std::string myName;
00103         std::vector<int> myGroupIDs;
00104         int myEdgeID;
00105         int myLane;
00106         SUMOReal myPosition;
00107         std::vector<int> myVehicleTypes;
00108         static SignalDictType myDict;
00109     };
00110 
00111     class NIVissimTLSignalGroup {
00112     public:
00113         NIVissimTLSignalGroup(int lsaid, int id, const std::string& name,
00114                               bool isGreenBegin, const std::vector<SUMOReal>& times,
00115                               SUMOTime tredyellow, SUMOTime tyellow);
00116         ~NIVissimTLSignalGroup();
00117         bool addTo(NBLoadedTLDef* node) const;
00118     public:
00119         static bool dictionary(int lsaid, int id, NIVissimTLSignalGroup* o);
00120         static NIVissimTLSignalGroup* dictionary(int lsaid, int id);
00121         static void clearDict();
00122         static SGroupDictType getGroupsFor(int tlid);
00123 
00124     private:
00125         int myLSA;
00126         int myID;
00127         std::string myName;
00128         std::vector<SUMOReal> myTimes;
00129         bool myFirstIsRed;
00130         SUMOTime myTRedYellow, myTYellow;
00131         static GroupDictType myDict;
00132     };
00133 
00134 protected:
00135     int myID;
00136     std::string myName;
00137     SUMOTime myAbsDuration;
00138     SUMOTime myOffset;
00139     NIVissimTLSignalGroup* myCurrentGroup;
00140     std::string myType;
00141 private:
00142     typedef std::map<int, NIVissimTL*> DictType;
00143     static DictType myDict;
00144 };
00145 
00146 
00147 #endif
00148 
00149 /****************************************************************************/
00150 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines