blob: 04821d0e32091154d7b12573b03187f00589319b [file] [log] [blame]
Alexander Afanasyev14b09482013-10-11 18:24:45 +02001/* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
Ilya Moiseenkob4aca052013-10-06 15:10:19 -07002/*
3 * @copyright See LICENCE for copyright and license information.
4 *
5 * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
6 * @author Ilya Moiseenko <iliamo@ucla.edu>
7 */
8
9#include "config.h"
10#import "fib-table-controller.h"
11
12@implementation FibTableController
13
14- (void)loadStatus:(NSXMLDocument *)document
15{
16 m_document = document;
17}
18
19- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
20{
21 if (m_document == nil)
22 {
23 return 0;
24 }
25 else
26 {
27 return [[m_document rootElement] childCount];
28 }
29}
30
31-(id)tableView:(NSTableView *)aTableView
32 objectValueForTableColumn:(NSTableColumn *)aTableColumn
33 row:(NSInteger)rowIndex
34{
35 NSXMLNode *element = [[m_document rootElement] childAtIndex:rowIndex];
36
37 if([[[aTableColumn headerCell] stringValue] isEqual:@"NDN prefix"])
38 {
39 return [[element childAtIndex:2] stringValue];
40 }
41 else if([[[aTableColumn headerCell] stringValue] isEqual:@"Face ID"])
42 {
43 return [[element childAtIndex:0] stringValue];
44 }
45 else if([[[aTableColumn headerCell] stringValue] isEqual:@"Endpoint"])
46 {
47 return [[element childAtIndex:1] stringValue];
48 }
49
50 return nil;
51}
52
53///////////////////////////////////////////////////////////////////////////////////////
54///////////////////////////////////////////////////////////////////////////////////////
55///////////////////////////////////////////////////////////////////////////////////////
56
57- (NSString *)getFaceByRowIndex:(NSInteger)index
58{
59 NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
60 return [[element childAtIndex:0] stringValue];
61}
62
63- (NSString *)getPrefixByRowIndex:(NSInteger)index
64{
65 NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
66 return [[element childAtIndex:2] stringValue];
67}
68
69@end