00001 // Copyright (C) 2006 University of Louisiana at Lafayette 00002 // Authors: Suresh Golconda 00003 00004 #ifndef CAJUN_BLOCKED_LANE_CONTAINTER_H 00005 #define CAJUN_BLOCKED_LANE_CONTAINTER_H 00006 00007 #include "data_type.H" 00008 #include <vector> 00009 #include <map> 00010 00011 namespace cajun 00012 { 00013 class blocked_lane_container_t 00014 { 00015 public: 00016 blocked_lane_container_t () { } 00017 bool update_blocked_lanes ( 00018 const std::vector<blocked_lane_data_t> &blk_lanes_); 00019 void update_blocked_lane (const blocked_lane_data_t &blk_lane_); 00020 /*\brief Returns true if any lanes blocked and fills up the input 00021 * vector with all blockages of all blocked lanes information, else 00022 * returns * false */ 00023 bool get_all_blockages ( 00024 std::vector<blocked_lane_data_t> &blk_lanes_, 00025 double threshold_tstamp_) const; 00026 /*\brief Returns true if any specified lane is blocked and fills up the 00027 * input vector with all blockages on the lane, else returns false */ 00028 bool get_lane_blockages ( 00029 std::vector<blocked_lane_data_t> &blk_lanes_, 00030 unsigned sid, unsigned lid, double threshold_tstamp_) const; 00031 private: 00034 struct lane_id_t 00035 { 00036 public: 00037 lane_id_t (unsigned sid_, unsigned lid_) : 00038 sid (sid_), lid (lid_) { } 00039 bool operator < (lane_id_t const &l_) const 00040 { 00041 return ((sid < l_.sid) || 00042 ((sid == l_.sid) && 00043 (lid < l_.lid))); 00044 } 00045 unsigned sid; 00046 unsigned lid; 00047 }; 00048 //fixme: For efficiency reasons, it is better to change 00049 //blocked_lane_data_t to *blocked_lane_data_t, as its passed around 00050 //bunch of times 00051 typedef std::multimap<lane_id_t, blocked_lane_data_t> blk_lane_list_t; 00052 00053 blk_lane_list_t m_blk_lane_list; 00054 }; 00055 }; 00056 00057 00058 #endif