Oolite
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 NSDictionary *info = nil;
98 NSAutoreleasePool *pool = nil;
99 NSString *name = nil,
100 *context = nil;
101 NSDictionary *materials = nil,
102 *shaders = nil;
103
104 OOLog(@"verifyOXP.models.unimplemented", @"%@", @"TODO: implement model verifier.");
105
106 foreach (info, _modelsToCheck)
107 {
108 pool = [[NSAutoreleasePool alloc] init];
109
110 name = [info objectForKey:@"name"];
111 context = [info objectForKey:@"context"];
112 if (context == NSNULL) context = nil;
113 materials = [info objectForKey:@"materials"];
114 if (materials == NSNULL) materials = nil;
115 shaders = [info objectForKey:@"shaders"];
116 if (shaders == NSNULL) shaders = nil;
117
118 [self checkModel:name
119 context:context
120 materials:materials
121 shaders:shaders];
122
123 [pool release];
124 }
125 [_modelsToCheck release];
126 _modelsToCheck = nil;
127}
128
129
130- (BOOL) modelNamed:(NSString *)name
131 usedForEntry:(NSString *)entryName
132 inFile:(NSString *)fileName
133 withMaterials:(NSDictionary *)materials
134 andShaders:(NSDictionary *)shaders
135{
136 OOFileScannerVerifierStage *fileScanner = nil;
137 NSDictionary *info = nil;
138 NSString *context = nil;
139
140 if (name == nil) return NO;
141
142 if (entryName != nil) context = [NSString stringWithFormat:@"entry \"%@\" of %@", entryName, fileName];
143 else context = fileName;
144
145 fileScanner = [[self verifier] fileScannerStage];
146 if (![fileScanner fileExists:name
147 inFolder:@"Models"
148 referencedFrom:context
149 checkBuiltIn:YES])
150 {
151 return NO;
152 }
153
154 if (context == nil) context = NSNULL;
155 if (materials == nil) materials = NSNULL;
156 if (shaders == nil) shaders = NSNULL;
157
158 info = [NSDictionary dictionaryWithObjectsAndKeys:
159 name, @"name",
160 context, @"context",
161 materials, @"materials",
162 shaders, @"shaders",
163 nil];
164
165 [_modelsToCheck addObject:info];
166
167 return YES;
168}
169
170@end
171
172
173@implementation OOModelVerifierStage (OOPrivate)
174
175
176- (void)checkModel:(NSString *)name
177 context:(NSString *)context
178 materials:(NSDictionary *)materials
179 shaders:(NSDictionary *)shaders
180{
181 OOLog(@"verifyOXP.verbose.model.unimp", @"- Pretending to verify model %@ referenced in %@.", name, context);
182 // FIXME: this should check DAT files.
183}
184
185@end
186
187
189
190- (OOModelVerifierStage *)modelVerifierStage
191{
192 return [self stageWithName:kStageName];
193}
194
195@end
196
197#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)