![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2007 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef WNS_LDK_HARQ_SOFTCOMBINING_CONTAINER_HPP 00029 #define WNS_LDK_HARQ_SOFTCOMBINING_CONTAINER_HPP 00030 00031 #include <WNS/Exception.hpp> 00032 #include <WNS/container/Registry.hpp> 00033 00034 #include <list> 00035 #include <vector> 00036 00037 namespace wns { namespace ldk { namespace harq { namespace softcombining { 00038 00039 template <class T> 00040 class Container 00041 { 00042 public: 00043 00044 typedef std::list<T> EntryList; 00045 00046 typedef std::vector<EntryList> EntryListVector; 00047 00048 typedef typename wns::container::Registry<int, EntryListVector> EntryContainer; 00049 00050 class InvalidRV : 00051 public Exception 00052 { 00053 public: 00054 ~InvalidRV() throw() {} 00055 }; 00056 00057 class InvalidPositionInTB : 00058 public Exception 00059 { 00060 public: 00061 ~InvalidPositionInTB() throw() {}; 00062 }; 00063 00064 Container() 00065 { 00066 numRVs_ = 0; 00067 } 00068 00069 Container(int numRVs) 00070 { 00071 if (numRVs < 0) 00072 { 00073 throw typename Container::InvalidRV(); 00074 } 00075 numRVs_ = numRVs; 00076 } 00077 00078 void 00079 clear() 00080 { 00081 receivedEntries_.clear(); 00082 } 00083 00084 00085 int 00086 getNumRVs() const 00087 { 00088 return numRVs_; 00089 } 00090 00091 std::list<int> 00092 getAvailablePosInTB() const 00093 { 00094 std::list<int> r; 00095 00096 typename EntryContainer::const_iterator it; 00097 00098 for(it = receivedEntries_.begin(); it!=receivedEntries_.end(); ++it) 00099 { 00100 r.push_back(it->first); 00101 } 00102 00103 return r; 00104 } 00105 00106 EntryList 00107 getEntriesForRV(int posInTB, int rv) const 00108 { 00109 if (!receivedEntries_.knows(posInTB)) 00110 { 00111 throw typename Container::InvalidPositionInTB(); 00112 } 00113 00114 checkIfValidRV(rv); 00115 00116 return receivedEntries_.find(posInTB)[rv]; 00117 } 00118 00119 void 00120 appendEntryForRV(int posInTB, int rv, T compound) 00121 { 00122 checkIfValidRV(rv); 00123 00124 if (!receivedEntries_.knows(posInTB)) 00125 { 00126 receivedEntries_.insert(posInTB, EntryListVector(numRVs_)); 00127 } 00128 receivedEntries_.find(posInTB)[rv].push_back(compound); 00129 } 00130 00131 private: 00132 00133 void 00134 checkIfValidRV(int rv) const 00135 { 00136 if (rv < 0 || rv >= getNumRVs()) 00137 { 00138 throw typename Container::InvalidRV(); 00139 } 00140 } 00141 00142 EntryContainer receivedEntries_; 00143 00144 int numRVs_; 00145 }; 00146 00147 } // softcombining 00148 } // harq 00149 } // ldk 00150 } // wns 00151 00152 #endif // WNS_LDK_HARQ_SOFTCOMBINING_CONTAINER_HPP
1.5.5