Oolite
Loading...
Searching...
No Matches
OOSystemDescriptionManager(OOPrivate) Category Reference

Instance Methods

(void) - setProperties:inDescription:
(NSDictionary *) - calculatePropertiesForSystemKey:
(void) - updateCacheEntry:
(void) - updateCacheEntry:forProperty:
(id) - getProperty:forSystemKey:withUniversal:
(id) - getProperty:orProperty:forSystemKey:withUniversal:
(void) - saveScriptedChangeToProperty:forSystemKey:andLayer:toValue:fromManifest:

Detailed Description

Definition at line 43 of file OOSystemDescriptionManager.m.

Method Documentation

◆ calculatePropertiesForSystemKey:

- (NSDictionary *) calculatePropertiesForSystemKey: (NSString *) key

Extends class OOSystemDescriptionManager.

Definition at line 424 of file OOSystemDescriptionManager.m.

424 :(NSString*)key
425{
426 NSMutableDictionary* dict = [NSMutableDictionary dictionaryWithCapacity:OO_LIKELY_PROPERTIES_PER_SYSTEM];
427 NSString* property = nil;
428 id val = nil;
429 BOOL interstellar = [key hasPrefix:@"interstellar:"];
430 foreach (property, propertiesInUse) {
431 // don't use universal properties on interstellar specific regions
432 val = [self getProperty:property forSystemKey:key withUniversal:!interstellar];
433
434 if (val != nil) {
435 [dict setObject:val forKey:property];
436 } else if (interstellar) {
437 // interstellar is always overridden by specific regions
438 // universal properties for interstellar get picked up here
439 val = [self getProperty:property forSystemKey:@"interstellar"];
440 if (val != nil) {
441 [dict setObject:val forKey:property];
442 }
443 }
444 }
445 return dict;
446}
return nil

References OOSystemDescriptionManager::getProperty:forSystemKey:, OOSystemDescriptionManager::getProperty:forSystemKey:withUniversal:, and nil.

Referenced by OOSystemDescriptionManager::getPropertiesForSystemKey:, and updateCacheEntry:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProperty:forSystemKey:withUniversal:

- (id) getProperty: (NSString *) property
forSystemKey: (NSString *) key
withUniversal: (BOOL) universal 

Extends class OOSystemDescriptionManager.

Definition at line 339 of file OOSystemDescriptionManager.m.

339 :(NSString*)property forSystemKey:(NSString*)key withUniversal:(BOOL)universal
340{
341 OOSystemDescriptionEntry* desc = nil;
342 if (EXPECT_NOT([key isEqualToString:@"interstellar"])) {
343 desc = interstellarSpace;
344 } else {
345 desc = [systemDescriptions objectForKey:key];
346 }
347 if (desc == nil) {
348 return nil;
349 }
350 id result = nil;
351 result = [desc getProperty:property forLayer:OO_LAYER_OXP_PRIORITY];
352 if (result == nil) {
353 result = [desc getProperty:property forLayer:OO_LAYER_OXP_DYNAMIC];
354 }
355 if (result == nil) {
356 result = [desc getProperty:property forLayer:OO_LAYER_OXP_STATIC];
357 }
358 if (result == nil && universal) {
359 result = [universalProperties objectForKey:property];
360 }
361 if (result == nil) {
362 result = [desc getProperty:property forLayer:OO_LAYER_CORE];
363 }
364 return result;
365}
#define EXPECT_NOT(x)
id getProperty:forLayer:(NSString *property,[forLayer] OOSystemLayer layer)

References EXPECT_NOT, OOSystemDescriptionEntry::getProperty:forLayer:, and nil.

Referenced by calculatePropertiesForSystemKey:, and OOSystemDescriptionManager::getProperty:forSystemKey:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getProperty:orProperty:forSystemKey:withUniversal:

- (id) getProperty: (NSString *) property1
orProperty: (NSString *) property2
forSystemKey: (NSString *) key
withUniversal: (BOOL) universal 

Extends class OOSystemDescriptionManager.

Definition at line 367 of file OOSystemDescriptionManager.m.

367 :(NSString*)property1 orProperty:(NSString*)property2 forSystemKey:(NSString*)key withUniversal:(BOOL)universal
368{
369 OOSystemDescriptionEntry* desc = [systemDescriptions objectForKey:key];
370 if (desc == nil) {
371 return nil;
372 }
373 id result = nil;
374 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_PRIORITY];
375 if (result == nil) {
376 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_PRIORITY];
377 }
378 if (result == nil) {
379 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_DYNAMIC];
380 }
381 if (result == nil) {
382 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_DYNAMIC];
383 }
384 if (result == nil) {
385 result = [desc getProperty:property1 forLayer:OO_LAYER_OXP_STATIC];
386 }
387 if (result == nil) {
388 result = [desc getProperty:property2 forLayer:OO_LAYER_OXP_STATIC];
389 }
390 if (universal) {
391 if (result == nil) {
392 result = [universalProperties objectForKey:property1];
393 }
394 if (result == nil) {
395 result = [universalProperties objectForKey:property2];
396 }
397 }
398 if (result == nil) {
399 result = [desc getProperty:property1 forLayer:OO_LAYER_CORE];
400 }
401 if (result == nil) {
402 result = [desc getProperty:property2 forLayer:OO_LAYER_CORE];
403 }
404 return result;
405}

References OOSystemDescriptionEntry::getProperty:forLayer:, and nil.

Here is the call graph for this function:

◆ saveScriptedChangeToProperty:forSystemKey:andLayer:toValue:fromManifest:

- (void) saveScriptedChangeToProperty: (NSString *) property
forSystemKey: (NSString *) key
andLayer: (OOSystemLayer) layer
toValue: (id) value
fromManifest: (NSString *) manifest 

Extends class OOSystemDescriptionManager.

Definition at line 188 of file OOSystemDescriptionManager.m.

188 :(NSString*)property forSystemKey:(NSString*)key andLayer:(OOSystemLayer)layer toValue:(id)value fromManifest:(NSString*)manifest
189{
190 // if OXP doesn't have a manifest, cancel saving the change
191 if (manifest == nil) {
192 return;
193 }
194 // OOLog(@"saving change",@"%@ %@ %@ %d",manifest,key,property,layer);
195 NSArray* overrideKey = [NSArray arrayWithObjects:manifest, key, property, [[NSNumber numberWithInt:layer] stringValue], nil];
196 // Obj-C copes with NSArray keys to dictionaries fine, but the
197 // plist format doesn't, so they can't be saved.
198 NSString* overrideKeyStr = [overrideKey componentsJoinedByString:kOOScriptedChangeJoiner];
199 if (value != nil) {
200 [scriptedChanges setObject:value forKey:overrideKeyStr];
201 } else {
202 [scriptedChanges removeObjectForKey:overrideKeyStr];
203 }
204}

References nil.

Referenced by OOSystemDescriptionManager::setProperty:forSystemKey:andLayer:toValue:fromManifest:.

Here is the caller graph for this function:

◆ setProperties:inDescription:

- (void) setProperties: (NSDictionary *) properties
inDescription: (OOSystemDescriptionEntry *) desc 

Extends class OOSystemDescriptionManager.

Definition at line 407 of file OOSystemDescriptionManager.m.

407 :(NSDictionary*)properties inDescription:(OOSystemDescriptionEntry*)desc
408{
409 OOSystemLayer layer = [properties oo_unsignedIntForKey:kOOSystemLayerProperty defaultValue:OO_LAYER_OXP_STATIC];
410 if (layer > OO_LAYER_OXP_PRIORITY) {
411 OOLog(@"system.description.error", @"Layer %u is not a valid layer number in system information.", layer);
412 layer = OO_LAYER_OXP_PRIORITY;
413 }
414 NSString* key = nil;
415 foreachkey(key, properties)
416 {
417 if (![key isEqualToString:kOOSystemLayerProperty]) {
418 [propertiesInUse addObject:key];
419 [desc setProperty:key forLayer:layer toValue:[properties objectForKey:key]];
420 }
421 }
422}
#define foreachkey(VAR, DICT)
#define OOLog(class, format,...)
Definition OOLogging.h:84
static NSString * kOOSystemLayerProperty
void setProperty:forLayer:toValue:(NSString *property,[forLayer] OOSystemLayer layer,[toValue] id value)

References foreachkey, kOOSystemLayerProperty, nil, OO_LAYER_OXP_PRIORITY, OOLog, and OOSystemDescriptionEntry::setProperty:forLayer:toValue:.

Referenced by OOSystemDescriptionManager::setInterstellarProperties:, and OOSystemDescriptionManager::setProperties:forSystemKey:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateCacheEntry:

- (void) updateCacheEntry: (NSUInteger) i

Extends class OOSystemDescriptionManager.

Definition at line 448 of file OOSystemDescriptionManager.m.

448 :(NSUInteger)i
449{
450 NSAssert(i < OO_SYSTEM_CACHE_LENGTH, @"Invalid cache entry number");
451 NSString* key = [NSString stringWithFormat:@"%zu %zu", i / OO_SYSTEMS_PER_GALAXY, i % OO_SYSTEMS_PER_GALAXY];
452 NSDictionary* current = [self calculatePropertiesForSystemKey:key];
453
454 [propertyCache[i] removeAllObjects];
455 [propertyCache[i] addEntriesFromDictionary:current];
456}
#define OO_SYSTEM_CACHE_LENGTH

References OOSystemDescriptionManager::calculatePropertiesForSystemKey:, and OO_SYSTEM_CACHE_LENGTH.

Referenced by OOSystemDescriptionManager::setProperties:forSystemKey:, and OOSystemDescriptionManager::setUniversalProperties:.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateCacheEntry:forProperty:

- (void) updateCacheEntry: (NSUInteger) i
forProperty: (NSString *) property 

Extends class OOSystemDescriptionManager.

Definition at line 458 of file OOSystemDescriptionManager.m.

458 :(NSUInteger)i forProperty:(NSString*)property
459{
460 NSAssert(i < OO_SYSTEM_CACHE_LENGTH, @"Invalid cache entry number");
461 NSString* key = [NSString stringWithFormat:@"%zu %zu", i / OO_SYSTEMS_PER_GALAXY, i % OO_SYSTEMS_PER_GALAXY];
462 id current = [self getProperty:property forSystemKey:key];
463 if (current == nil) {
464 [propertyCache[i] removeObjectForKey:property];
465 } else {
466 [propertyCache[i] setObject:current forKey:property];
467 }
468}

References OOSystemDescriptionManager::getProperty:forSystemKey:, nil, and OO_SYSTEM_CACHE_LENGTH.

Referenced by OOSystemDescriptionManager::setProperty:forSystemKey:andLayer:toValue:fromManifest:.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this category was generated from the following file: