Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
OOModelVerifierStage.m
Go to the documentation of this file.
1/*
2
3OOModelVerifierStage.m
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22MA 02110-1301, USA.
23
24*/
25
27
28#if OO_OXP_VERIFIER_ENABLED
29
31
32static NSString * const kStageName = @"Testing models";
33
34static id NSNULL = nil;
35
36
37@interface OOModelVerifierStage (OOPrivate)
38
39- (void)checkModel:(NSString *)name
40 context:(NSString *)context
41 materials:(NSDictionary *)materials
42 shaders:(NSDictionary *)shaders;
43
44@end
45
46
47@implementation OOModelVerifierStage
48
49- (id)init
50{
51 self = [super init];
52 if (self != nil)
53 {
54 NSNULL = [[NSNull null] retain];
55 _modelsToCheck = [[NSMutableSet alloc] init];
56 }
57 return self;
58}
59
60
61- (void)dealloc
62{
63 [_modelsToCheck release];
64
65 [super dealloc];
66}
67
68
69+ (NSString *)nameForReverseDependencyForVerifier:(OOOXPVerifier *)verifier
70{
71 OOModelVerifierStage *stage = [verifier stageWithName:kStageName];
72 if (stage == nil)
73 {
74 stage = [[OOModelVerifierStage alloc] init];
75 [verifier registerStage:stage];
76 [stage release];
77 }
78
79 return kStageName;
80}
81
82
83- (NSString *)name
84{
85 return kStageName;
86}
87
88
89- (BOOL)shouldRun
90{
91 return [_modelsToCheck count] != 0;
92}
93
94
95- (void)run
96{
97 NSEnumerator *nameEnum = nil;
98 NSDictionary *info = nil;
99 NSAutoreleasePool *pool = nil;
100 NSString *name = nil,
101 *context = nil;
102 NSDictionary *materials = nil,
103 *shaders = nil;
104
105 OOLog(@"verifyOXP.models.unimplemented", @"%@", @"TODO: implement model verifier.");
106
107 for (nameEnum = [_modelsToCheck objectEnumerator]; (info = [nameEnum nextObject]); )
108 {
109 pool = [[NSAutoreleasePool alloc] init];
110
111 name = [info objectForKey:@"name"];
112 context = [info objectForKey:@"context"];
113 if (context == NSNULL) context = nil;
114 materials = [info objectForKey:@"materials"];
115 if (materials == NSNULL) materials = nil;
116 shaders = [info objectForKey:@"shaders"];
117 if (shaders == NSNULL) shaders = nil;
118
119 [self checkModel:name
120 context:context
121 materials:materials
122 shaders:shaders];
123
124 [pool release];
125 }
126 [_modelsToCheck release];
127 _modelsToCheck = nil;
128}
129
130
131- (BOOL) modelNamed:(NSString *)name
132 usedForEntry:(NSString *)entryName
133 inFile:(NSString *)fileName
134 withMaterials:(NSDictionary *)materials
135 andShaders:(NSDictionary *)shaders
136{
137 OOFileScannerVerifierStage *fileScanner = nil;
138 NSDictionary *info = nil;
139 NSString *context = nil;
140
141 if (name == nil) return NO;
142
143 if (entryName != nil) context = [NSString stringWithFormat:@"entry \"%@\" of %@", entryName, fileName];
144 else context = fileName;
145
146 fileScanner = [[self verifier] fileScannerStage];
147 if (![fileScanner fileExists:name
148 inFolder:@"Models"
149 referencedFrom:context
150 checkBuiltIn:YES])
151 {
152 return NO;
153 }
154
155 if (context == nil) context = NSNULL;
156 if (materials == nil) materials = NSNULL;
157 if (shaders == nil) shaders = NSNULL;
158
159 info = [NSDictionary dictionaryWithObjectsAndKeys:
160 name, @"name",
161 context, @"context",
162 materials, @"materials",
163 shaders, @"shaders",
164 nil];
165
166 [_modelsToCheck addObject:info];
167
168 return YES;
169}
170
171@end
172
173
174@implementation OOModelVerifierStage (OOPrivate)
175
176
177- (void)checkModel:(NSString *)name
178 context:(NSString *)context
179 materials:(NSDictionary *)materials
180 shaders:(NSDictionary *)shaders
181{
182 OOLog(@"verifyOXP.verbose.model.unimp", @"- Pretending to verify model %@ referenced in %@.", name, context);
183 // FIXME: this should check DAT files.
184}
185
186@end
187
188
190
191- (OOModelVerifierStage *)modelVerifierStage
192{
193 return [self stageWithName:kStageName];
194}
195
196@end
197
198#endif
static NSString *const kStageName
#define OOLog(class, format,...)
Definition OOLogging.h:88
static NSString *const kStageName
static id NSNULL
return nil
id stageWithName:(NSString *name)
void registerStage:(OOOXPVerifierStage *stage)