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@interface OOModelVerifierStage (OOPrivate)
37
38- (void)checkModel:(NSString*)name
39 context:(NSString*)context
40 materials:(NSDictionary*)materials
41 shaders:(NSDictionary*)shaders;
42
43@end
44
45@implementation OOModelVerifierStage
46
47- (id)init
48{
49 self = [super init];
50 if (self != nil) {
51 NSNULL = [[NSNull null] retain];
52 _modelsToCheck = [[NSMutableSet alloc] init];
53 }
54 return self;
55}
56
57- (void)dealloc
58{
59 [_modelsToCheck release];
60
61 [super dealloc];
62}
63
64+ (NSString*)nameForReverseDependencyForVerifier:(OOOXPVerifier*)verifier
65{
66 OOModelVerifierStage* stage = [verifier stageWithName:kStageName];
67 if (stage == nil) {
68 stage = [[OOModelVerifierStage alloc] init];
69 [verifier registerStage:stage];
70 [stage release];
71 }
72
73 return kStageName;
74}
75
76- (NSString*)name
77{
78 return kStageName;
79}
80
81- (BOOL)shouldRun
82{
83 return [_modelsToCheck count] != 0;
84}
85
86- (void)run
87{
88 NSDictionary* info = nil;
89 NSAutoreleasePool* pool = nil;
90 NSString *name = nil,
91 *context = nil;
92 NSDictionary *materials = nil,
93 *shaders = nil;
94
95 OOLog(@"verifyOXP.models.unimplemented", @"%@", @"TODO: implement model verifier.");
96
97 foreach (info, _modelsToCheck) {
98 pool = [[NSAutoreleasePool alloc] init];
99
100 name = [info objectForKey:@"name"];
101 context = [info objectForKey:@"context"];
102 if (context == NSNULL)
103 context = nil;
104 materials = [info objectForKey:@"materials"];
105 if (materials == NSNULL)
106 materials = nil;
107 shaders = [info objectForKey:@"shaders"];
108 if (shaders == NSNULL)
109 shaders = nil;
110
111 [self checkModel:name
112 context:context
113 materials:materials
114 shaders:shaders];
115
116 [pool release];
117 }
118 [_modelsToCheck release];
120}
121
122- (BOOL)modelNamed:(NSString*)name
123 usedForEntry:(NSString*)entryName
124 inFile:(NSString*)fileName
125 withMaterials:(NSDictionary*)materials
126 andShaders:(NSDictionary*)shaders
127{
128 OOFileScannerVerifierStage* fileScanner = nil;
129 NSDictionary* info = nil;
130 NSString* context = nil;
131
132 if (name == nil)
133 return NO;
134
135 if (entryName != nil)
136 context = [NSString stringWithFormat:@"entry \"%@\" of %@", entryName, fileName];
137 else
138 context = fileName;
139
140 fileScanner = [[self verifier] fileScannerStage];
141 if (![fileScanner fileExists:name
142 inFolder:@"Models"
143 referencedFrom:context
144 checkBuiltIn:YES]) {
145 return NO;
146 }
147
148 if (context == nil)
149 context = NSNULL;
150 if (materials == nil)
151 materials = NSNULL;
152 if (shaders == nil)
153 shaders = NSNULL;
154
155 info = [NSDictionary dictionaryWithObjectsAndKeys:
156 name, @"name",
157 context, @"context",
158 materials, @"materials",
159 shaders, @"shaders",
160 nil];
161
162 [_modelsToCheck addObject:info];
163
164 return YES;
165}
166
167@end
168
169@implementation OOModelVerifierStage (OOPrivate)
170
171- (void)checkModel:(NSString*)name
172 context:(NSString*)context
173 materials:(NSDictionary*)materials
174 shaders:(NSDictionary*)shaders
175{
176 OOLog(@"verifyOXP.verbose.model.unimp", @"- Pretending to verify model %@ referenced in %@.", name, context);
177 // FIXME: this should check DAT files.
178}
179
180@end
181
182@implementation OOOXPVerifier (OOModelVerifierStage)
183
185{
186 return [self stageWithName:kStageName];
187}
188
189@end
190
191#endif
static NSString *const kStageName
#define OOLog(class, format,...)
Definition OOLogging.h:84
static id NSNULL
return nil
void checkModel:context:materials:shaders:(NSString *name,[context] NSString *context,[materials] NSDictionary *materials,[shaders] NSDictionary *shaders)
OOOXPVerifier * verifier()
id stageWithName:(NSString *name)
OOFileScannerVerifierStage * fileScannerStage()
void registerStage:(OOOXPVerifierStage *stage)