SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // »missingDescription« 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSBitSetLogic_h 00024 #define MSBitSetLogic_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <bitset> 00037 #include <vector> 00038 #include <cassert> 00039 #include "MSJunctionLogic.h" 00040 #include "MSLogicJunction.h" 00041 00042 00043 // =========================================================================== 00044 // class definitions 00045 // =========================================================================== 00051 template< size_t N > 00052 class MSBitSetLogic : public MSJunctionLogic { 00053 public: 00060 typedef std::vector< std::bitset< N > > Logic; 00061 00064 typedef std::vector< std::bitset< N > > Foes; 00065 00066 00067 public: 00069 MSBitSetLogic(unsigned int nLinks, 00070 Logic* logic, 00071 Foes* foes, 00072 std::bitset<64> conts) 00073 : MSJunctionLogic(nLinks), myLogic(logic), 00074 myInternalLinksFoes(foes), myConts(conts) {} 00075 00076 00078 ~MSBitSetLogic() { 00079 delete myLogic; 00080 delete myInternalLinksFoes; 00081 } 00082 00083 00085 const MSLogicJunction::LinkFoes& getFoesFor(unsigned int linkIndex) const { 00086 return (*myLogic)[linkIndex]; 00087 } 00088 00089 const std::bitset<64> &getInternalFoesFor(unsigned int linkIndex) const { 00090 return (*myInternalLinksFoes)[linkIndex]; 00091 } 00092 00093 bool getIsCont(unsigned int linkIndex) const { 00094 return myConts.test(linkIndex); 00095 } 00096 00097 virtual bool isCrossing() const { 00098 for (typename Logic::const_iterator i = myLogic->begin(); i != myLogic->end(); ++i) { 00099 if ((*i).any()) { 00100 return true; 00101 } 00102 } 00103 return false; 00104 } 00105 00106 private: 00108 Logic* myLogic; 00109 00111 Foes* myInternalLinksFoes; 00112 00113 std::bitset<64> myConts; 00114 00115 private: 00117 MSBitSetLogic(const MSBitSetLogic&); 00118 00120 MSBitSetLogic& operator=(const MSBitSetLogic&); 00121 00122 }; 00123 00124 00128 typedef MSBitSetLogic< 64 > MSBitsetLogic; 00129 00130 00131 #endif 00132 00133 /****************************************************************************/ 00134