OpenASIP 2.2
Loading...
Searching...
No Matches
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 */
64public:
66 virtual ~FilterSearch();
67
68 SearchStrategy* copy() const;
70 const CostDBEntryKey& searchKey,
71 CostDBTypes::EntryTable components,
72 const CostDBTypes::MatchTypeTable& match);
73
74private:
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.
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.
124 /// Assignment not allowed.
126};
127
128#endif
std::vector< MatchType * > MatchTypeTable
Table of types of match.
std::vector< CostDBEntry * > EntryTable
Table of database entries.
CostDBEntryKey * searchKey_
Search key of the query for these results.
CostDBTypes::MatchTypeTable matchType_
Type of match used for these results.
CostDBTypes::EntryTable entries() const
CostDBTypes::EntryTable entries_
Resulting database entries. Not owned by this class.
Cache(const Cache &)
Copying not allowed.
Cache * copy() const
bool isEqual(CostDBTypes::MatchTypeTable matchingType, const CostDBEntryKey *key) const
Cache & operator=(const Cache &)
Assignment not allowed.
friend class FilterSearchTest
MatcherTable matcherStorage_
Storage for all matchers. They cannot be deleted before search strategy itself is deleted....
FilterSearch & operator=(const FilterSearch &)
Assignment not allowed.
FilterSearch(const FilterSearch &)
Copying not allowed.
CacheTable entryCache_
Results of the previous queries.
CostDBTypes::EntryTable findFromCache(const CostDBEntryKey &searchKey, const CostDBTypes::MatchTypeTable &match)
CostDBTypes::EntryTable search(const CostDBEntryKey &searchKey, CostDBTypes::EntryTable components, const CostDBTypes::MatchTypeTable &match)
std::vector< Matcher * > MatcherTable
Table of matcher types.
SearchStrategy * copy() const
std::vector< Cache * > CacheTable
Table of cache entries.
MatcherTable createMatchers(const CostDBTypes::MatchTypeTable &match)
virtual ~FilterSearch()