Added methods for 'choice' and 'exclude' criteria
[core.git] / inc / classes / interfaces / criteria / class_Criteria.php
1 <?php
2 /**
3  * An interface for criterias
4  *
5  * @author              Roland Haeder <webmaster@ship-simu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.ship-simu.org
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 3 of the License, or
14  * (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program. If not, see <http://www.gnu.org/licenses/>.
23  */
24 interface Criteria extends FrameworkInterface {
25         /**
26          * Setter for wrapper class name
27          *
28          * @param       $wrapperConfigEntry             Configuration entry which hold the wrapper class' name
29          * @return      void
30          */
31         function setWrapperConfigEntry ($wrapperConfigEntry);
32
33         /**
34          * Getter for wrapper class name
35          *
36          * @return      $wrapperConfigEntry             Configuration entry which hold the wrapper class' name
37          */
38         function getWrapperConfigEntry ();
39
40         /**
41          * Getter for criteria array
42          *
43          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
44          * @return      $criteria
45          */
46         function getCriteriaArray ($criteriaType = 'default');
47
48         /**
49          * Getter for criteria array 'choice' type
50          *
51          * @return      $criteria
52          */
53         function getCriteriaChoiceArray ();
54
55         /**
56          * Getter for criteria array 'exclude' type
57          *
58          * @return      $criteria
59          */
60         function getCriteriaExcludeArray ();
61
62         /**
63          * Add criteria, this method converts dashes to underscores because dashes
64          * are not valid for criteria keys.
65          *
66          * @param       $criteriaKey    Criteria key
67          * @param       $criteriaValue  Criteria value
68          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
69          * @return      void
70          */
71         function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
72
73         /**
74          * Add "choice" criteria, this method converts dashes to underscores because
75          * dashes are not valid for criteria keys.
76          *
77          * @param       $criteriaKey    Criteria key
78          * @param       $criteriaValue  Criteria value
79          * @return      void
80          */
81         function addChoiceCriteria ($criteriaKey, $criteriaValue);
82
83         /**
84          * Add "exclude" criteria, this method converts dashes to underscores because
85          * dashes are not valid for criteria keys.
86          *
87          * @param       $criteriaKey    Criteria key
88          * @param       $criteriaValue  Criteria value
89          * @return      void
90          */
91         function addExcludeCriteria ($criteriaKey, $criteriaValue);
92
93         /**
94          * Add configured criteria
95          *
96          * @param       $criteriaKey    Criteria key
97          * @param       $configEntry    Configuration entry
98          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
99          * @return      void
100          */
101         function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
102
103         /**
104          * Get criteria element or null if not found
105          *
106          * @param       $criteriaKey    The requested criteria key
107          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
108          * @return      $value                  Whether the value of the critera or null
109          */
110         function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
111
112         /**
113          * Checks whether given array entry matches
114          *
115          * @param       $entryArray             Array with the entries to find
116          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
117          * @return      $matches                Whether the entry matches or not
118          */
119         function ifEntryMatches (array $entryArray, $criteriaType = 'default');
120
121         /**
122          * Checks whether given array 'choice' entry matches
123          *
124          * @param       $entryArray             Array with the entries to find
125          * @return      $matches                Whether the entry matches or not
126          */
127         function ifChoiceMatches (array $entryArray);
128
129         /**
130          * Checks whether given array 'exclude' entry matches
131          *
132          * @param       $entryArray             Array with the entries to find
133          * @return      $matches                Whether the entry matches or not
134          */
135         function ifExcludeMatches (array $entryArray);
136
137         /**
138          * "Getter" for a cache key
139          *
140          * @param       $onlyKeys       Only use these keys for a cache key
141          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
142          * @return      $cacheKey       The key suitable for the cache system
143          */
144         function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
145
146         /**
147          * "Getter" for a cache key ('choice' type)
148          *
149          * @param       $onlyKeys       Only use these keys for a cache key
150          * @return      $cacheKey       The key suitable for the cache system
151          */
152         function getCacheKeyChoice ($onlyKeys = array());
153
154         /**
155          * "Getter" for a cache key ('exclude' type)
156          *
157          * @param       $onlyKeys       Only use these keys for a cache key
158          * @return      $cacheKey       The key suitable for the cache system
159          */
160         function getCacheKeyExclude ($onlyKeys = array());
161
162         /**
163          * "Getter" for a cache key ('choice' type)
164          *
165          * @param       $onlyKeys       Only use these keys for a cache key
166          * @return      $cacheKey       The key suitable for the cache system
167          */
168         function getCacheKeyChoice ($onlyKeys = array());
169
170         /**
171          * Count the criteria, e.g. useful to find out if a database query has no
172          * limitation (search criteria).
173          *
174          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
175          * @return      $count  Count of all criteria entries
176          */
177         function count ($criteriaType = 'default');
178
179         /**
180          * Count 'choice' criteria, e.g. useful to find out if a database query
181          * has no limitation (search criteria).
182          *
183          * @return      $count  Count of all criteria entries
184          */
185         function countChoice ();
186
187         /**
188          * Count 'exclude' criteria, e.g. useful to find out if a database query
189          * has no limitation (search criteria).
190          *
191          * @return      $count  Count of all criteria entries
192          */
193         function countExclude ();
194 }
195
196 // [EOF]
197 ?>