OpenASIP  2.0
FilterSearch.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file FilterSearch.hh
26  *
27  * Declaration of FilterSearch class.
28  *
29  * @author Tommi Rantanen 2003 (tommi.rantanen-no.spam-tut.fi)
30  * @author Jari Mäntyneva 2005 (jari.mantyneva-no.spam-tut.fi)
31  * @note rating: red
32  */
33 
34 #ifndef TTA_FILTER_SEARCH_HH
35 #define TTA_FILTER_SEARCH_HH
36 
37 
38 #include <vector>
39 
40 #include "CostDBTypes.hh"
41 #include "SearchStrategy.hh"
42 #include "MatchType.hh"
43 #include "CostDBEntry.hh"
44 #include "Matcher.hh"
45 #include "Exception.hh"
46 
47 
48 /**
49  * Implementation of the queries from the cost database.
50  *
51  * Using the FilterSearch algorithm requires only a Search() function
52  * call.
53  *
54  * Search is based on filtering non-matching entries out according to
55  * information of one field at a time. Thus, it is very generic
56  * accepting field changes to entries without touching to the searrch
57  * algorithms.
58  *
59  * Cache and quick filtering is used for optimisation. Cache contains
60  * all the results from the previous queries. Quick filtering removes
61  * unneccessary entries in linear time in the beginning of the search.
62  */
64 public:
65  FilterSearch();
66  virtual ~FilterSearch();
67 
68  SearchStrategy* copy() const;
70  const CostDBEntryKey& searchKey,
71  CostDBTypes::EntryTable components,
72  const CostDBTypes::MatchTypeTable& match);
73 
74 private:
75  /**
76  * Represents a cache entry.
77  */
78  class Cache {
79  friend class FilterSearchTest;
80  public:
81  Cache(
82  CostDBTypes::MatchTypeTable matchingType,
83  CostDBEntryKey* key,
85  ~Cache();
86  Cache* copy() const;
87  bool isEqual(
88  CostDBTypes::MatchTypeTable matchingType,
89  const CostDBEntryKey* key) const;
91  private:
92  /// Type of match used for these results.
94  /// Search key of the query for these results.
96  /// Resulting database entries. Not owned by this class.
98 
99  /// Copying not allowed.
100  Cache(const Cache&);
101  /// Assignment not allowed.
102  Cache& operator=(const Cache&);
103  };
104 
105  /// Table of cache entries.
106  typedef std::vector<Cache*> CacheTable;
107  /// Table of matcher types.
108  typedef std::vector<Matcher*> MatcherTable;
109 
111  const CostDBEntryKey& searchKey,
112  const CostDBTypes::MatchTypeTable& match);
114 
115  /// Results of the previous queries.
117  /// Storage for all matchers. They cannot be deleted before search
118  /// strategy itself is deleted. Thus, this storage exists to
119  /// deallocate the memory reserved by matchers.
121 
122  /// Copying not allowed.
123  FilterSearch(const FilterSearch&);
124  /// Assignment not allowed.
126 };
127 
128 #endif
FilterSearch::findFromCache
CostDBTypes::EntryTable findFromCache(const CostDBEntryKey &searchKey, const CostDBTypes::MatchTypeTable &match)
Definition: FilterSearch.cc:155
FilterSearch::Cache::~Cache
~Cache()
Definition: FilterSearch.cc:236
CostDBTypes::MatchTypeTable
std::vector< MatchType * > MatchTypeTable
Table of types of match.
Definition: CostDBTypes.hh:114
CostDBTypes.hh
FilterSearch::FilterSearch
FilterSearch()
Definition: FilterSearch.cc:47
Exception.hh
CostDBTypes::EntryTable
std::vector< CostDBEntry * > EntryTable
Table of database entries.
Definition: CostDBTypes.hh:111
FilterSearch::Cache::isEqual
bool isEqual(CostDBTypes::MatchTypeTable matchingType, const CostDBEntryKey *key) const
Definition: FilterSearch.cc:289
SearchStrategy
Definition: SearchStrategy.hh:45
FilterSearch::Cache::operator=
Cache & operator=(const Cache &)
Assignment not allowed.
FilterSearch::MatcherTable
std::vector< Matcher * > MatcherTable
Table of matcher types.
Definition: FilterSearch.hh:108
FilterSearch::operator=
FilterSearch & operator=(const FilterSearch &)
Assignment not allowed.
FilterSearch::Cache::copy
Cache * copy() const
Definition: FilterSearch.cc:260
FilterSearch::copy
SearchStrategy * copy() const
Definition: FilterSearch.cc:80
FilterSearch
Definition: FilterSearch.hh:63
FilterSearch::Cache::matchType_
CostDBTypes::MatchTypeTable matchType_
Type of match used for these results.
Definition: FilterSearch.hh:93
CostDBEntry.hh
FilterSearch::entryCache_
CacheTable entryCache_
Results of the previous queries.
Definition: FilterSearch.hh:116
MatchType.hh
FilterSearch::CacheTable
std::vector< Cache * > CacheTable
Table of cache entries.
Definition: FilterSearch.hh:106
SearchStrategy.hh
FilterSearch::Cache::Cache
Cache(CostDBTypes::MatchTypeTable matchingType, CostDBEntryKey *key, CostDBTypes::EntryTable &entry)
Definition: FilterSearch.cc:218
FilterSearch::matcherStorage_
MatcherTable matcherStorage_
Storage for all matchers. They cannot be deleted before search strategy itself is deleted....
Definition: FilterSearch.hh:120
FilterSearch::Cache::entries_
CostDBTypes::EntryTable entries_
Resulting database entries. Not owned by this class.
Definition: FilterSearch.hh:97
FilterSearch::search
CostDBTypes::EntryTable search(const CostDBEntryKey &searchKey, CostDBTypes::EntryTable components, const CostDBTypes::MatchTypeTable &match)
Definition: FilterSearch.cc:110
FilterSearch::Cache::entries
CostDBTypes::EntryTable entries() const
Definition: FilterSearch.cc:325
CostDBEntryKey
Definition: CostDBEntryKey.hh:52
FilterSearch::~FilterSearch
virtual ~FilterSearch()
Definition: FilterSearch.cc:53
FilterSearch::Cache::searchKey_
CostDBEntryKey * searchKey_
Search key of the query for these results.
Definition: FilterSearch.hh:95
FilterSearch::Cache
Definition: FilterSearch.hh:78
Matcher.hh
FilterSearch::Cache::FilterSearchTest
friend class FilterSearchTest
Definition: FilterSearch.hh:79
FilterSearch::createMatchers
MatcherTable createMatchers(const CostDBTypes::MatchTypeTable &match)
Definition: FilterSearch.cc:179