//
//  NSMutableDictionary+ModelSettings.m
//  iPhly
//
//  Created by Ari Krupnik on 4/30/10.
//  Copyright 2010 lib.aero. All rights reserved.
//

#import "NSMutableDictionary+ModelConfig.h"


@implementation NSMutableDictionary (ModelConfig)

- (NSString *) name {
	return [self objectForKey: @"name"];
}
- (void) setName: (NSString *) name {
	[self setObject: name forKey: @"name"];
}

- (float) accelerometerSensitivity {
	return [[self objectForKey:@"accelerometerSensitivity"] floatValue];
}
- (void) setAccelerometerSensitivity: (float) s {
	[self setObject: [NSNumber numberWithFloat: s] forKey:@"accelerometerSensitivity"];
}

- (BOOL) isAirplane {
	return [[self objectForKey:@"model-type"] isEqualToString:@"airplane"];
}
- (BOOL) isCar {
	return [[self objectForKey:@"model-type"] isEqualToString:@"car"];
}

- (int) numChannels {
	return [(NSArray *) [self objectForKey: @"channels"] count];
}
- (NSMutableDictionary *) channel: (int) number {
	return [(NSArray *) [self objectForKey: @"channels"] objectAtIndex: number];
}

- (BOOL) reversing {
	return [[self objectForKey: @"reversing"] boolValue];
}
- (void) setReversing: (BOOL) reversing {
	[self setObject: [NSNumber numberWithBool: reversing] forKey:@"reversing"];
}

- (float) trim {
	return [[self objectForKey: @"trim"] floatValue];
}
- (void) setTrim: (float) trim {
	[self setObject: [NSNumber numberWithFloat: trim] forKey:@"trim"];
}

- (float) rate {
	return [[self objectForKey: @"rate"] floatValue];
}
- (void) setRate: (float) rate {
	[self setObject: [NSNumber numberWithFloat: rate] forKey:@"rate"];
}

@end
