Licensing MenuTunes under the GNU General Public License version 2.
[MenuTunes.git] / PlaylistNode.m
1 #import "PlaylistNode.h"
2
3
4 @implementation PlaylistNode
5
6 + (PlaylistNode *)playlistNodeWithName:(NSString *)n type:(ITMTNodeType)t index:(int)i
7 {
8         return [[[PlaylistNode alloc] initWithName:n type:t index:i] autorelease];
9 }
10
11 - (id)initWithName:(NSString *)n type:(ITMTNodeType)t index:(int)i
12 {
13         if ( (self = [super init]) ) {
14                 _name = [n retain];
15                 _type = t;
16                 _index = i;
17                 _children = nil;
18                 _parent = nil;
19         }
20         return self;
21 }
22
23 - (void)dealloc
24 {
25         [_name release];
26         [_children release];
27         [_parent release];
28         [super dealloc];
29 }
30
31 - (NSString *)description
32 {
33         return [NSString stringWithFormat:@"{%@, index: %i, type: %i, parent: %@, children: %@}", _name, _index, _type, [_parent name], _children];
34 }
35
36 - (NSString *)name
37 {
38         return _name;
39 }
40
41 - (NSMutableArray *)children
42 {
43         if (!_children) {
44                 _children = [[NSMutableArray alloc] init];
45         }
46         return _children;
47 }
48
49 - (int)index
50 {
51         return _index;
52 }
53
54 - (void)setType:(ITMTNodeType)t
55 {
56         _type = t;
57 }
58
59 - (ITMTNodeType)type
60 {
61         return _type;
62 }
63
64 - (PlaylistNode *)parent
65 {
66         return _parent;
67 }
68
69 - (void)setParent:(PlaylistNode *)p
70 {
71         [_parent release];
72         _parent = [p retain];
73 }
74
75 - (ITMTRemotePlayerSource)sourceType
76 {
77         return _sourceType;
78 }
79
80 - (void)setSourceType:(ITMTRemotePlayerSource)t
81 {
82         _sourceType = t;
83 }
84
85 @end