//
//  TeXDistributionBridge.m
//  TeXDist
//
//  Created by coder on 08/12/06.
//  Copyright 2006 Laurens'Tribune. All rights reserved.
//

#import "TeXDistArchitecture.h"
#import "TeXDistCommon.h"

@interface TeXDistArchitecture()
@property (readwrite,copy) NSString * name;
@property (readwrite,copy) NSString * destinationPath;
@property (readwrite,copy) NSString * source;
@property (readwrite,copy) NSString * distributionName;
@property (readwrite,retain) NSMutableSet * names;
@end
@implementation TeXDistArchitecture
@synthesize name = iVarName, source = iVarSource, names = iVarNames, destinationPath = iVarDestinationPath, distributionName = iVarDistributionName;
@synthesize minimumSystemVersion = iVarMinimumSystemVersion;
@synthesize maximumSystemVersion = iVarMaximumSystemVersion;
- (id)initWithName:(NSString *)aName source:(NSString *)aSource destinationPath:(NSString *)aPath distributionName:(NSString *)aDistributionName;
{
    if ((self = [self init])) {
        self.name = aName;
        self.names = [NSMutableSet set];
        [self addName:self.name];
        self.source = aSource;
        self.destinationPath = aPath?:aName;
        self.distributionName = aDistributionName;
        self.minimumSystemVersion = [TeXDistSystemVersion firstSystemVersion];
        self.maximumSystemVersion = [TeXDistSystemVersion lastSystemVersion];
    }
    return self;
}
- (void)dealloc;
{
    self.name = nil;
    self.names = nil;
    self.source = nil;
    self.destinationPath = nil;
    self.distributionName = nil;
    self.minimumSystemVersion = nil;
    self.maximumSystemVersion = nil;
    [super dealloc];
}
- (void) addName:(NSString *)aName;
{
    if (aName.length) {
        [self.names addObject:aName];
    }
}
- (NSString *)localizedDescription;
{
    return NSLocalizedStringFromTableInBundle(self.name, nil, [NSBundle bundleForClass:[TeXDistArchitecture class]], @"None");
}
- (NSString *)description;
{
    return [NSString stringWithFormat:@"<Architecture: %@ -> %@ (%@) %#x>", self.name, self.localizedDescription, self.distributionName,self];
}
- (NSString *)longDescription;
{
    return [NSString stringWithFormat:@"< Architecture: %#x\n"
    @"  Localized description: %@\n"
    @"  Distribution: %@\n"
    @"  Name: %@\n"
    @"  Source (in Programs folder): %@\n"
    @"  Destination Folder: %@\n"
    @"  Minimum OS (including): %@\n"
    @"  Maximum OS (excluding): %@\n"
    @"  All names:\n%@\n>",
        self, self.localizedDescription, self.distributionName, self.name, self.source, self.destinationPath,
        self.minimumSystemVersion, ([self.maximumSystemVersion isEqual:[TeXDistSystemVersion lastSystemVersion]]?@"None":self.maximumSystemVersion.description),self.names];
}
@end
