Implement async FIB table manipulation
Implementation reuses the status information from NdnStatusOperation and
uses XSLT for basic preprocessing.
Change-Id: Id3dba1779e02451772d09bdc919fdc68475171a9
diff --git a/osx/fib-table-controller.mm b/osx/fib-table-controller.mm
new file mode 100644
index 0000000..2f8e96e
--- /dev/null
+++ b/osx/fib-table-controller.mm
@@ -0,0 +1,69 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * @copyright See LICENCE for copyright and license information.
+ *
+ * @author Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ * @author Ilya Moiseenko <iliamo@ucla.edu>
+ */
+
+#include "config.h"
+#import "fib-table-controller.h"
+
+@implementation FibTableController
+
+- (void)loadStatus:(NSXMLDocument *)document
+{
+ m_document = document;
+}
+
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
+{
+ if (m_document == nil)
+ {
+ return 0;
+ }
+ else
+ {
+ return [[m_document rootElement] childCount];
+ }
+}
+
+-(id)tableView:(NSTableView *)aTableView
+ objectValueForTableColumn:(NSTableColumn *)aTableColumn
+ row:(NSInteger)rowIndex
+{
+ NSXMLNode *element = [[m_document rootElement] childAtIndex:rowIndex];
+
+ if([[[aTableColumn headerCell] stringValue] isEqual:@"NDN prefix"])
+ {
+ return [[element childAtIndex:2] stringValue];
+ }
+ else if([[[aTableColumn headerCell] stringValue] isEqual:@"Face ID"])
+ {
+ return [[element childAtIndex:0] stringValue];
+ }
+ else if([[[aTableColumn headerCell] stringValue] isEqual:@"Endpoint"])
+ {
+ return [[element childAtIndex:1] stringValue];
+ }
+
+ return nil;
+}
+
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////////////
+
+- (NSString *)getFaceByRowIndex:(NSInteger)index
+{
+ NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
+ return [[element childAtIndex:0] stringValue];
+}
+
+- (NSString *)getPrefixByRowIndex:(NSInteger)index
+{
+ NSXMLNode *element = [[m_document rootElement] childAtIndex:index];
+ return [[element childAtIndex:2] stringValue];
+}
+
+@end