Added 2 more methods
[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          * Get criteria element or null if not found for 'choice' type
114          *
115          * @param       $criteriaKey    The requested criteria key
116          * @return      $value                  Whether the value of the critera or null
117          */
118         function getCriteriaChoiceElemnent ($criteriaKey);
119
120         /**
121          * Get criteria element or null if not found for 'exclude' type
122          *
123          * @param       $criteriaKey    The requested criteria key
124          * @return      $value                  Whether the value of the critera or null
125          */
126         function getCriteriaExcludeElemnent ($criteriaKey);
127
128         /**
129          * Checks whether given array entry matches
130          *
131          * @param       $entryArray             Array with the entries to find
132          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
133          * @return      $matches                Whether the entry matches or not
134          */
135         function ifEntryMatches (array $entryArray, $criteriaType = 'default');
136
137         /**
138          * Checks whether given array 'choice' entry matches
139          *
140          * @param       $entryArray             Array with the entries to find
141          * @return      $matches                Whether the entry matches or not
142          */
143         function ifChoiceMatches (array $entryArray);
144
145         /**
146          * Checks whether given array 'exclude' entry matches
147          *
148          * @param       $entryArray             Array with the entries to find
149          * @return      $matches                Whether the entry matches or not
150          */
151         function ifExcludeMatches (array $entryArray);
152
153         /**
154          * "Getter" for a cache key
155          *
156          * @param       $onlyKeys       Only use these keys for a cache key
157          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
158          * @return      $cacheKey       The key suitable for the cache system
159          */
160         function getCacheKey ($onlyKeys = array(), $criteriaType = 'default');
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          * "Getter" for a cache key ('exclude' type)
172          *
173          * @param       $onlyKeys       Only use these keys for a cache key
174          * @return      $cacheKey       The key suitable for the cache system
175          */
176         function getCacheKeyExclude ($onlyKeys = array());
177
178         /**
179          * Count the criteria, e.g. useful to find out if a database query has no
180          * limitation (search criteria).
181          *
182          * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
183          * @return      $count  Count of all criteria entries
184          */
185         function count ($criteriaType = 'default');
186
187         /**
188          * Count 'choice' 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 countChoice ();
194
195         /**
196          * Count 'exclude' criteria, e.g. useful to find out if a database query
197          * has no limitation (search criteria).
198          *
199          * @return      $count  Count of all criteria entries
200          */
201         function countExclude ();
202 }
203
204 // [EOF]
205 ?>