12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /******************************************************************
- *
- * uEcho for ObjC
- *
- * Copyright (C) Satoshi Konno 2015
- *
- * This is licensed under BSD-style license, see file COPYING.
- *
- ******************************************************************/
- #import "CGEchoNode.h"
- #import "CGEchoObject.h"
- #include <uecho/node.h>
- @implementation CGEchoNode {
- }
- @synthesize cObject;
- - (id)initWithCObject:(uEchoNode*)cobj
- {
- if ((self = [super init]) == nil)
- return nil;
- cObject = cobj;
- return self;
- }
- - (void)dealloc
- {
- }
- - (NSString*)address
- {
- if (!cObject)
- return nil;
- const char* addr = uecho_node_getaddress(cObject);
- if (!addr)
- return nil;
- return [NSString stringWithUTF8String:addr];
- }
- - (NSArray*)objects;
- {
- if (!cObject)
- return [NSArray array];
- NSMutableArray* objs = [NSMutableArray array];
- for (uEchoNode* cObj = uecho_node_getobjects(cObject); cObj; cObj = uecho_object_next(cObj)) {
- CGEchoObject* obj = [[CGEchoObject alloc] initWithCObject:cObj];
- [objs addObject:obj];
- }
- return objs;
- }
- @end
|