| 92 | }; |
| 93 | |
| 94 | SimpleHistogram *SimpleHistogramCache::operator[](BaseData::Pointer sp_BaseData) |
| 95 | { |
| 96 | BaseData *p_BaseData = sp_BaseData.GetPointer(); |
| 97 | |
| 98 | if (!p_BaseData) |
| 99 | { |
| 100 | MITK_WARN << "SimpleHistogramCache::operator[] with null base data called"; |
| 101 | return nullptr; |
| 102 | } |
| 103 | |
| 104 | Element *elementToUpdate = nullptr; |
| 105 | |
| 106 | bool first = true; |
| 107 | |
| 108 | for (auto iter = cache.begin(); iter != cache.end(); iter++) |
| 109 | { |
| 110 | Element *e = *iter; |
| 111 | BaseData *p_tmp = e->baseData.Lock(); |
| 112 | |
| 113 | if (p_tmp == p_BaseData) |
| 114 | { |
| 115 | if (!first) |
| 116 | { |
| 117 | cache.erase(iter); |
| 118 | cache.push_front(e); |
| 119 | } |
| 120 | if (p_BaseData->GetMTime() > e->m_LastUpdateTime.GetMTime()) |
| 121 | { |
| 122 | elementToUpdate = e; |
| 123 | goto recomputeElement; |
| 124 | } |
| 125 | |
| 126 | // MITK_INFO << "using a cached histogram"; |
| 127 | |
| 128 | return e->GetHistogram(); |
| 129 | } |
| 130 | |
| 131 | first = false; |
| 132 | } |
| 133 | |
| 134 | if (dynamic_cast<Image *>(p_BaseData)) |
| 135 | { |
| 136 | elementToUpdate = new ImageHistogramCacheElement(); |
| 137 | } |
| 138 | else |
| 139 | { |
| 140 | MITK_WARN << "not supported: " << p_BaseData->GetNameOfClass(); |
| 141 | return nullptr; |
| 142 | } |
| 143 | |
| 144 | elementToUpdate->baseData = p_BaseData; |
| 145 | cache.push_front(elementToUpdate); |
| 146 | TrimCache(); |
| 147 | |
| 148 | recomputeElement: |
| 149 | |
| 150 | // MITK_INFO << "computing a new histogram"; |
| 151 |
nothing calls this directly
no test coverage detected