Line data Source code
1 0 : /* 2 : 3 : OOEntityFilterPredicate.h 4 : 5 : Filters used to select entities in various contexts. Callers are required to 6 : ensure that the "entity" argument is non-nil and the "parameter" argument is 7 : valid and relevant. 8 : 9 : To reduce header spaghetti, the EntityFilterPredicate type is declared in 10 : Universe.h, which is included just about everywhere anyway. This file just 11 : declares a set of widely-useful predicates. 12 : 13 : 14 : Oolite 15 : Copyright (C) 2004-2013 Giles C Williams and contributors 16 : 17 : This program is free software; you can redistribute it and/or 18 : modify it under the terms of the GNU General Public License 19 : as published by the Free Software Foundation; either version 2 20 : of the License, or (at your option) any later version. 21 : 22 : This program is distributed in the hope that it will be useful, 23 : but WITHOUT ANY WARRANTY; without even the implied warranty of 24 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 : GNU General Public License for more details. 26 : 27 : You should have received a copy of the GNU General Public License 28 : along with this program; if not, write to the Free Software 29 : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 30 : MA 02110-1301, USA. 31 : 32 : */ 33 : 34 : 35 : #import "Universe.h" 36 : 37 : 38 0 : typedef struct 39 : { 40 0 : EntityFilterPredicate predicate; 41 0 : void *parameter; 42 : } ChainedEntityPredicateParameter; 43 : 44 0 : typedef struct 45 : { 46 0 : EntityFilterPredicate predicate1; 47 0 : void *parameter1; 48 0 : EntityFilterPredicate predicate2; 49 0 : void *parameter2; 50 : } BinaryOperationPredicateParameter; 51 : 52 : 53 0 : BOOL YESPredicate(Entity *entity, void *parameter); // Parameter: ignored. Always returns YES. 54 0 : BOOL NOPredicate(Entity *entity, void *parameter); // Parameter: ignored. Always returns NO. 55 : 56 0 : BOOL NOTPredicate(Entity *entity, void *parameter); // Parameter: ChainedEntityPredicateParameter. Reverses effect of chained predicate. 57 : 58 0 : BOOL ANDPredicate(Entity *entity, void *parameter); // Parameter: BinaryOperationPredicateParameter. Short-circuiting AND operator. 59 0 : BOOL ORPredicate(Entity *entity, void *parameter); // Parameter: BinaryOperationPredicateParameter. Short-circuiting OR operator. 60 0 : BOOL NORPredicate(Entity *entity, void *parameter); // Parameter: BinaryOperationPredicateParameter. Short-circuiting NOR operator. 61 0 : BOOL XORPredicate(Entity *entity, void *parameter); // Parameter: BinaryOperationPredicateParameter. XOR operator. 62 0 : BOOL NANDPredicate(Entity *entity, void *parameter); // Parameter: BinaryOperationPredicateParameter. NAND operator. 63 : 64 0 : BOOL HasScanClassPredicate(Entity *entity, void *parameter); // Parameter: NSNumber (int) 65 0 : BOOL HasClassPredicate(Entity *entity, void *parameter); // Parameter: Class 66 0 : BOOL IsShipPredicate(Entity *entity, void *parameter); // Parameter: ignored. Tests isShip and !isSubentity. 67 0 : BOOL IsStationPredicate(Entity *entity, void *parameter); // Parameter: ignored. Tests isStation. 68 0 : BOOL IsPlanetPredicate(Entity *entity, void *parameter); // Parameter: ignored. Tests isPlanet and planetType == STELLAR_TYPE_NORMAL_PLANET. 69 0 : BOOL IsSunPredicate(Entity *entity, void *parameter); // Parameter: ignored. Tests isSun. 70 0 : BOOL IsVisualEffectPredicate(Entity *entity, void *parameter); // Parameter: ignored. Tests isVisualEffect and !isSubentity. 71 : 72 : // These predicates assume their parameter is a ShipEntity. 73 0 : BOOL HasRolePredicate(Entity *ship, void *parameter); // Parameter: NSString 74 0 : BOOL HasPrimaryRolePredicate(Entity *ship, void *parameter); // Parameter: NSString 75 0 : BOOL HasRoleInSetPredicate(Entity *ship, void *parameter); // Parameter: NSSet 76 0 : BOOL HasPrimaryRoleInSetPredicate(Entity *ship, void *parameter); // Parameter: NSSet 77 0 : BOOL IsHostileAgainstTargetPredicate(Entity *ship, void *parameter); // Parameter: ShipEntity