SUMO - Simulation of Urban MObility

MSBitSetLogic.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 //  »missingDescription«
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 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 MSBitSetLogic_h
00020 #define MSBitSetLogic_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 <bitset>
00033 #include <vector>
00034 #include <cassert>
00035 #include "MSJunctionLogic.h"
00036 #include "MSLogicJunction.h"
00037 
00038 
00039 // ===========================================================================
00040 // class definitions
00041 // ===========================================================================
00047 template< size_t N >
00048 class MSBitSetLogic : public MSJunctionLogic {
00049 public:
00056     typedef std::vector< std::bitset< N > > Logic;
00057 
00060     typedef std::vector< std::bitset< N > > Foes;
00061 
00062 
00063 public:
00065     MSBitSetLogic(unsigned int nLinks,
00066                   Logic* logic,
00067                   Foes* foes,
00068                   std::bitset<64> conts)
00069         : MSJunctionLogic(nLinks), myLogic(logic),
00070           myInternalLinksFoes(foes), myConts(conts) {}
00071 
00072 
00074     ~MSBitSetLogic() {
00075         delete myLogic;
00076         delete myInternalLinksFoes;
00077     }
00078 
00079 
00081     const MSLogicJunction::LinkFoes& getFoesFor(unsigned int linkIndex) const throw() {
00082         return (*myLogic)[linkIndex];
00083     }
00084 
00085     const std::bitset<64> &getInternalFoesFor(unsigned int linkIndex) const throw() {
00086         return (*myInternalLinksFoes)[linkIndex];
00087     }
00088 
00089     bool getIsCont(unsigned int linkIndex) const throw() {
00090         return myConts.test(linkIndex);
00091     }
00092 
00093     virtual bool isCrossing() const throw() {
00094         for (typename Logic::const_iterator i=myLogic->begin(); i!=myLogic->end(); ++i) {
00095             if ((*i).any()) {
00096                 return true;
00097             }
00098         }
00099         return false;
00100     }
00101 
00102 private:
00104     Logic* myLogic;
00105 
00107     Foes* myInternalLinksFoes;
00108 
00109     std::bitset<64> myConts;
00110 
00111 private:
00113     MSBitSetLogic(const MSBitSetLogic&);
00114 
00116     MSBitSetLogic& operator=(const MSBitSetLogic&);
00117 
00118 };
00119 
00120 
00124 typedef MSBitSetLogic< 64 > MSBitsetLogic;
00125 
00126 
00127 #endif
00128 
00129 /****************************************************************************/
00130 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines