OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
FilterSearch::Cache Class Reference
Collaboration diagram for FilterSearch::Cache:
Collaboration graph

Public Member Functions

 Cache (CostDBTypes::MatchTypeTable matchingType, CostDBEntryKey *key, CostDBTypes::EntryTable &entry)
 
 ~Cache ()
 
Cachecopy () const
 
bool isEqual (CostDBTypes::MatchTypeTable matchingType, const CostDBEntryKey *key) const
 
CostDBTypes::EntryTable entries () const
 

Private Member Functions

 Cache (const Cache &)
 Copying not allowed.
 
Cacheoperator= (const Cache &)
 Assignment not allowed.
 

Private Attributes

CostDBTypes::MatchTypeTable matchType_
 Type of match used for these results.
 
CostDBEntryKeysearchKey_
 Search key of the query for these results.
 
CostDBTypes::EntryTable entries_
 Resulting database entries. Not owned by this class.
 

Friends

class FilterSearchTest
 

Detailed Description

Represents a cache entry.

Definition at line 78 of file FilterSearch.hh.

Constructor & Destructor Documentation

◆ Cache() [1/2]

FilterSearch::Cache::Cache ( CostDBTypes::MatchTypeTable  matchingType,
CostDBEntryKey key,
CostDBTypes::EntryTable entry 
)

Constructor.

Parameters
matchingTypeType of match.
keySearch key.
entryDatabase entries.

Definition at line 218 of file FilterSearch.cc.

221 :
222 searchKey_(key), entries_(entry) {
223
224 for (CostDBTypes::MatchTypeTable::iterator i = matchingType.begin();
225 i != matchingType.end(); i++) {
226 matchType_.push_back(new MatchType(*(*i)));
227 }
228}
CostDBEntryKey * searchKey_
Search key of the query for these results.
CostDBTypes::MatchTypeTable matchType_
Type of match used for these results.
CostDBTypes::EntryTable entries_
Resulting database entries. Not owned by this class.

References matchType_.

◆ ~Cache()

FilterSearch::Cache::~Cache ( )

Destructor.

Deallocates memory reserved for search key and type of match. Not responsible of deleting entries.

Definition at line 236 of file FilterSearch.cc.

236 {
237
238 assert(searchKey_ != NULL);
239 delete searchKey_;
240 searchKey_ = NULL;
241
242 for (CostDBTypes::MatchTypeTable::iterator i = matchType_.begin();
243 i != matchType_.end(); i++) {
244
245 assert(*i != NULL);
246 delete *i;
247 *i = NULL;
248 }
249}
#define assert(condition)

References assert.

◆ Cache() [2/2]

FilterSearch::Cache::Cache ( const Cache )
private

Copying not allowed.

Member Function Documentation

◆ copy()

FilterSearch::Cache * FilterSearch::Cache::copy ( ) const

Returns a copy of this cache.

Client is responsible of deallocating the memory reserved for the returned object.

Returns
Copy of this cache.

Definition at line 260 of file FilterSearch.cc.

260 {
261
262 CostDBEntryKey* newSearchKey = searchKey_->copy();
263 CostDBTypes::MatchTypeTable newMatchType;
264
265 for (CostDBTypes::MatchTypeTable::const_iterator i = matchType_.begin();
266 i != matchType_.end(); i++) {
267 newMatchType.push_back(
268 new MatchType((*i)->fieldType(), (*i)->matchingType()));
269 }
270
271 CostDBTypes::EntryTable newEntries;
272 for (CostDBTypes::EntryTable::const_iterator i = entries_.begin();
273 i != entries_.end(); i++) {
274 newEntries.push_back(*i);
275 }
276
277 return new FilterSearch::Cache(newMatchType, newSearchKey, newEntries);
278}
CostDBEntryKey * copy() const
std::vector< MatchType * > MatchTypeTable
Table of types of match.
std::vector< CostDBEntry * > EntryTable
Table of database entries.

References CostDBEntryKey::copy().

Here is the call graph for this function:

◆ entries()

CostDBTypes::EntryTable FilterSearch::Cache::entries ( ) const

Returns entries.

Returns
Cached entries.

Definition at line 325 of file FilterSearch.cc.

325 {
326 return entries_;
327}

◆ isEqual()

bool FilterSearch::Cache::isEqual ( CostDBTypes::MatchTypeTable  matchingType,
const CostDBEntryKey key 
) const

Tests if cache matches to the type of match and search key.

Parameters
matchingTypeType of match.
keySearch key.
Returns
true If cache matches to the type of match and search key, false otherwise.

Definition at line 289 of file FilterSearch.cc.

291 {
292
293 // warning: there could be different keys that yield the same result
294 if (!searchKey_->isEqual(*key)) {
295 return false;
296 }
297
298 // warning: a search may succeed if it's cached and fail if not
299 // since the order of match types accepted is insignificant
300 for (CostDBTypes::MatchTypeTable::const_iterator i = matchingType.begin();
301 i != matchingType.end(); i++) {
302
303 bool isThere = false;
304 for (CostDBTypes::MatchTypeTable::const_iterator j =
305 matchType_.begin(); j != matchType_.end(); j++) {
306
307 if ((*i)->isEqual(*(*j))) {
308 isThere = true;
309 break;
310 }
311 }
312 if (!isThere) {
313 return false;
314 }
315 }
316 return true;
317}
bool isEqual(const CostDBEntryKey &entryKey) const

◆ operator=()

Cache & FilterSearch::Cache::operator= ( const Cache )
private

Assignment not allowed.

Friends And Related Symbol Documentation

◆ FilterSearchTest

friend class FilterSearchTest
friend

Definition at line 79 of file FilterSearch.hh.

Member Data Documentation

◆ entries_

CostDBTypes::EntryTable FilterSearch::Cache::entries_
private

Resulting database entries. Not owned by this class.

Definition at line 97 of file FilterSearch.hh.

◆ matchType_

CostDBTypes::MatchTypeTable FilterSearch::Cache::matchType_
private

Type of match used for these results.

Definition at line 93 of file FilterSearch.hh.

Referenced by Cache().

◆ searchKey_

CostDBEntryKey* FilterSearch::Cache::searchKey_
private

Search key of the query for these results.

Definition at line 95 of file FilterSearch.hh.


The documentation for this class was generated from the following files: