00001 #ifndef TRANS_CACHE_ENTRY_CPP 00002 #define TRANS_CACHE_ENTRY_CPP 00003 00004 //-------------------------------------------------------------------- 00005 // 00006 // This file is part of PEACE. 00007 // 00008 // PEACE is free software: you can redistribute it and/or modify it 00009 // under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation, either version 3 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // PEACE is distributed in the hope that it will be useful, but 00014 // WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 // General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with PEACE. If not, see <http://www.gnu.org/licenses/>. 00020 // 00021 // Miami University makes no representations or warranties about the 00022 // suitability of the software, either express or implied, including 00023 // but not limited to the implied warranties of merchantability, 00024 // fitness for a particular purpose, or non-infringement. Miami 00025 // University shall not be liable for any damages suffered by licensee 00026 // as a result of using, result of using, modifying or distributing 00027 // this software or its derivatives. 00028 // 00029 // By using or copying this Software, Licensee agrees to abide by the 00030 // intellectual property laws, and all other applicable laws of the 00031 // U.S., and the terms of GNU General Public License (version 3). 00032 // 00033 // Authors: Dhananjai M. Rao raodm@muohio.edu 00034 // 00035 //--------------------------------------------------------------------- 00036 00037 #include "TransCacheEntry.h" 00038 #include "Utilities.h" 00039 00040 TransCacheEntry::TransCacheEntry(const int refEstIdx) : estIdx(refEstIdx) { 00041 peerInfo = new TransCacheMap; 00042 // Currently we have nothing else to be done here. 00043 } 00044 00045 TransCacheEntry::~TransCacheEntry() { 00046 delete peerInfo; 00047 } 00048 00049 void 00050 TransCacheEntry::addEntries(const CachedESTInfo& reference, 00051 const SMList& metrics, 00052 const int UNREFERENCED_PARAMETER(startIndex), 00053 const int UNREFERENCED_PARAMETER(endIndex)) { 00054 // Add the related metric information to the peerInfo map 00055 for(size_t index = 0; (index < metrics.size()); index++) { 00056 const CachedESTInfo& entry = metrics[index]; 00057 // Don't add entries referring to ourselves. 00058 if (entry.estIdx != estIdx) { 00059 // Metric is minimum of peer metric and parent metric, 00060 // as according to conditional transitivity. 00061 float tmp = std::min(reference.metric, entry.metric); 00062 //TransCacheMap::const_iterator peerEntry = 00063 // peerInfo->find(entry.estIdx); 00064 //if (peerEntry == peerInfo->end() || 00065 // peerEntry->second.metric > tmp) { 00066 (*peerInfo)[entry.estIdx] = 00067 CachedESTInfo(estIdx, entry.estIdx, 00068 tmp, 00069 entry.alignmentData, 00070 entry.directionData); 00071 //} 00072 } 00073 } 00074 } 00075 00076 bool 00077 TransCacheEntry::getMetric(const int otherESTidx, float& metric) const { 00078 // First see if our peerInfo hash map has an entry for otherESTidx. 00079 TransCacheMap::const_iterator peerEntry = peerInfo->find(otherESTidx); 00080 if (peerEntry == peerInfo->end()) { 00081 // No, we don't have an entry. Can't determine metric using 00082 // transitivity in this case. 00083 return false; 00084 } 00085 // OK, found a peer entry. 00086 metric = peerEntry->second.metric; 00087 // Return true to indicate we did find an entry. 00088 return true; 00089 } 00090 00091 #endif