blob: 8d56cea6bab05ba25d531035b19d9cf85e212e70 [file] [log] [blame]
Alexander Afanasyev14b09482013-10-11 18:24:45 +02001/* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07002/**
3 * Copyright (c) 2013-2014, Regents of the University of California,
Ilya Moiseenkob4aca052013-10-06 15:10:19 -07004 *
Alexander Afanasyevb6392e32014-05-12 23:43:50 -07005 * This file is part of NFD Control Center. See AUTHORS.md for complete list of NFD
6 * authors and contributors.
7 *
8 * NFD Control Center is free software: you can redistribute it and/or modify it under the
9 * terms of the GNU General Public License as published by the Free Software Foundation,
10 * either version 3 of the License, or (at your option) any later version.
11 *
12 * NFD Control Center is distributed in the hope that it will be useful, but WITHOUT ANY
13 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along with NFD
17 * Control Center, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * \author Alexander Afanasyev <http://lasr.cs.ucla.edu/afanasyev/index.html>
20 * \author Ilya Moiseenko <http://ilyamoiseenko.com/>
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070021 */
22
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070023#include "config.hpp"
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070024#import "fib-table-controller.h"
25
26@implementation FibTableController
27
28- (void)loadStatus:(NSXMLDocument *)document
29{
30 m_document = document;
31}
32
33- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
34{
35 if (m_document == nil)
36 {
37 return 0;
38 }
39 else
40 {
41 return [[m_document rootElement] childCount];
42 }
43}
44
45-(id)tableView:(NSTableView *)aTableView
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070046 objectValueForTableColumn:(NSTableColumn *)aTableColumn
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070047 row:(NSInteger)rowIndex
48{
49 NSXMLNode *element = [[m_document rootElement] childAtIndex:rowIndex];
50
51 if([[[aTableColumn headerCell] stringValue] isEqual:@"NDN prefix"])
52 {
53 return [[element childAtIndex:2] stringValue];
54 }
55 else if([[[aTableColumn headerCell] stringValue] isEqual:@"Face ID"])
56 {
57 return [[element childAtIndex:0] stringValue];
58 }
59 else if([[[aTableColumn headerCell] stringValue] isEqual:@"Endpoint"])
60 {
61 return [[element childAtIndex:1] stringValue];
62 }
Alexander Afanasyevb6392e32014-05-12 23:43:50 -070063
Ilya Moiseenkob4aca052013-10-06 15:10:19 -070064 return nil;
65}
66
67///////////////////////////////////////////////////////////////////////////////////////
68///////////////////////////////////////////////////////////////////////////////////////
69///////////////////////////////////////////////////////////////////////////////////////
70
71- (NSString *)getFaceByRowIndex:(NSInteger)index
72{
73 NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
74 return [[element childAtIndex:0] stringValue];
75}
76
77- (NSString *)getPrefixByRowIndex:(NSInteger)index
78{
79 NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
80 return [[element childAtIndex:2] stringValue];
81}
82
83@end