00001 // 00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH) 00003 // 00004 // This program is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU General Public License 00006 // as published by the Free Software Foundation; either version 2 00007 // of the License, or (at your option) any later version. 00008 // 00009 // This program is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with this program; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 // 00018 00024 #include <vector> 00025 00026 #include "GiaKeyList.h" 00027 00028 00029 void GiaKeyList::addKeyItem(const OverlayKey& item) 00030 { 00031 if(!contains(item)) 00032 keyList.push_back(item); 00033 } 00034 00035 void GiaKeyList::removeKeyItem(const OverlayKey& item) 00036 { 00037 std::vector<OverlayKey>::iterator it = keyList.begin(); 00038 if(contains(item)) 00039 keyList.erase(it + getPosition(item)); 00040 } 00041 00042 bool GiaKeyList::contains(const OverlayKey& item) 00043 { 00044 if(getPosition(item) != -1) 00045 return true; 00046 return false; 00047 } 00048 00049 int GiaKeyList::getPosition(const OverlayKey& item) 00050 { 00051 for(uint32_t i = 0; i < keyList.size(); i++) 00052 if(keyList[i] == item) 00053 return i; 00054 return -1; 00055 } 00056 00057 const std::vector<OverlayKey>& GiaKeyList::getVector() 00058 { 00059 return keyList; 00060 } 00061 00062 uint32_t GiaKeyList::getSize() 00063 { 00064 return keyList.size(); 00065 } 00066 00067 const OverlayKey& GiaKeyList::get 00068 (uint32_t i) 00069 { 00070 return keyList[i]; 00071 } 00072 00073 std::ostream& operator<<(std::ostream& os, const GiaKeyList& k) 00074 { 00075 for ( uint32_t i = 0; i<k.keyList.size(); i++ ) 00076 os << k.keyList[i]; 00077 return os; 00078 }