Updated copyright:
[core.git] / inc / classes / interfaces / criteria / class_Criteria.php
1 <?php
2 /**
3  * An interface for criterias
4  *
5  * @author              Roland Haeder <webmaster@shipsimu.org>
6  * @version             0.0.0
7  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core Developer Team
8  * @license             GNU GPL 3.0 or any newer version
9  * @link                http://www.shipsimu.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          * Checks whether given key is set
42          *
43          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
44          * @param       $criteriaKey    Criteria key
45          * @return      $isSet                  Whether key is set
46          */
47         function isKeySet ($criteriaType, $criteriaKey);
48
49         /**
50          * Checks whether given key is set for 'choice' type
51          *
52          * @param       $criteriaKey    Criteria key
53          * @return      $isSet                  Whether key is set
54          */
55         function isChoiceKeySet ($criteriaKey);
56
57         /**
58          * Checks whether given key is set for 'exclude' type
59          *
60          * @param       $criteriaKey    Criteria key
61          * @return      $isSet                  Whether key is set
62          */
63         function isExcludeKeySet ($criteriaKey);
64
65         /**
66          * Getter for criteria array
67          *
68          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
69          * @return      $criteria
70          */
71         function getCriteriaArray ($criteriaType = 'default');
72
73         /**
74          * Getter for criteria array 'choice' type
75          *
76          * @return      $criteria
77          */
78         function getCriteriaChoiceArray ();
79
80         /**
81          * Getter for criteria array 'exclude' type
82          *
83          * @return      $criteria
84          */
85         function getCriteriaExcludeArray ();
86
87         /**
88          * Unsets a criteria key from all criteria types
89          *
90          * @param       $criteriaKey    Criteria key to unset
91          * @return      void
92          */
93         function unsetCriteria ($criteriaKey);
94
95         /**
96          * Add criteria, this method converts dashes to underscores because dashes
97          * are not valid for criteria keys.
98          *
99          * @param       $criteriaKey    Criteria key
100          * @param       $criteriaValue  Criteria value
101          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
102          * @return      void
103          */
104         function addCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default');
105
106         /**
107          * Add "choice" criteria, this method converts dashes to underscores because
108          * dashes are not valid for criteria keys.
109          *
110          * @param       $criteriaKey    Criteria key
111          * @param       $criteriaValue  Criteria value
112          * @return      void
113          */
114         function addChoiceCriteria ($criteriaKey, $criteriaValue);
115
116         /**
117          * Add "exclude" criteria, this method converts dashes to underscores because
118          * dashes are not valid for criteria keys.
119          *
120          * @param       $criteriaKey    Criteria key
121          * @param       $criteriaValue  Criteria value
122          * @return      void
123          */
124         function addExcludeCriteria ($criteriaKey, $criteriaValue);
125
126         /**
127          * Add configured criteria
128          *
129          * @param       $criteriaKey    Criteria key
130          * @param       $configEntry    Configuration entry
131          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
132          * @return      void
133          */
134         function addConfiguredCriteria ($criteriaKey, $configEntry, $criteriaType = 'default');
135
136         /**
137          * Get criteria element or FALSE if not found
138          *
139          * @param       $criteriaKey    The requested criteria key
140          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
141          * @return      $value                  Whether the value of the critera or FALSE
142          */
143         function getCriteriaElemnent ($criteriaKey, $criteriaType = 'default');
144
145         /**
146          * Get criteria element or FALSE if not found for 'choice' type
147          *
148          * @param       $criteriaKey    The requested criteria key
149          * @return      $value                  Whether the value of the critera or FALSE
150          */
151         function getCriteriaChoiceElemnent ($criteriaKey);
152
153         /**
154          * Get criteria element or FALSE if not found for 'exclude' type
155          *
156          * @param       $criteriaKey    The requested criteria key
157          * @return      $value                  Whether the value of the critera or FALSE
158          */
159         function getCriteriaExcludeElemnent ($criteriaKey);
160
161         /**
162          * Checks whether given array entry matches
163          *
164          * @param       $entryArray             Array with the entries to find
165          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
166          * @return      $matches                Whether the entry matches or not
167          */
168         function ifEntryMatches (array $entryArray, $criteriaType = 'default');
169
170         /**
171          * Checks whether given array 'choice' entry matches
172          *
173          * @param       $entryArray             Array with the entries to find
174          * @return      $matches                Whether the entry matches or not
175          */
176         function ifChoiceMatches (array $entryArray);
177
178         /**
179          * Checks whether given array 'exclude' entry matches
180          *
181          * @param       $entryArray             Array with the entries to find
182          * @return      $matches                Whether the entry matches or not
183          */
184         function ifExcludeMatches (array $entryArray);
185
186         /**
187          * "Getter" for a cache key
188          *
189          * @param       $onlyKeys       Only use these keys for a cache key
190          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
191          * @return      $cacheKey       The key suitable for the cache system
192          */
193         function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
194
195         /**
196          * "Getter" for a cache key ('choice' type)
197          *
198          * @param       $onlyKeys       Only use these keys for a cache key
199          * @return      $cacheKey       The key suitable for the cache system
200          */
201         function getCacheKeyChoice ($onlyKeys = array());
202
203         /**
204          * "Getter" for a cache key ('exclude' type)
205          *
206          * @param       $onlyKeys       Only use these keys for a cache key
207          * @return      $cacheKey       The key suitable for the cache system
208          */
209         function getCacheKeyExclude ($onlyKeys = array());
210
211         /**
212          * Count the criteria, e.g. useful to find out if a database query has no
213          * limitation (search criteria).
214          *
215          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
216          * @return      $count  Count of all criteria entries
217          */
218         function count ($criteriaType = 'default');
219
220         /**
221          * Count 'choice' criteria, e.g. useful to find out if a database query
222          * has no limitation (search criteria).
223          *
224          * @return      $count  Count of all criteria entries
225          */
226         function countChoice ();
227
228         /**
229          * Count 'exclude' criteria, e.g. useful to find out if a database query
230          * has no limitation (search criteria).
231          *
232          * @return      $count  Count of all criteria entries
233          */
234         function countExclude ();
235 }
236
237 // [EOF]
238 ?>