Alexander Afanasyev | 14b0948 | 2013-10-11 18:24:45 +0200 | [diff] [blame] | 1 | /* -*- Mode: objc; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 2 | /** |
| 3 | * Copyright (c) 2013-2014, Regents of the University of California, |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 4 | * |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 5 | * 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 Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 21 | */ |
| 22 | |
Alexander Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 23 | #include "config.hpp" |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 24 | #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 Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 46 | objectValueForTableColumn:(NSTableColumn *)aTableColumn |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 47 | 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 Afanasyev | b6392e3 | 2014-05-12 23:43:50 -0700 | [diff] [blame] | 63 | |
Ilya Moiseenko | b4aca05 | 2013-10-06 15:10:19 -0700 | [diff] [blame] | 64 | 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 |