<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -71,7 +71,7 @@
 	[addressSpace findNodeForAddress:@&quot;/asdf/s/1&quot; createIfMissing:YES];
 	[addressSpace findNodeForAddress:@&quot;/asdf/s/2&quot; createIfMissing:YES];
 	[addressSpace findNodeForAddress:@&quot;/asdf/s/3&quot; createIfMissing:YES];
-	NSLog(@&quot;%@&quot;,addressSpace);
+	//NSLog(@&quot;%@&quot;,addressSpace);
 	*/
 }
 </diff>
      <filename>AppSrc/AppController.m</filename>
    </modified>
    <modified>
      <diff>@@ -16,20 +16,23 @@
 
 
 
-id _mainAddressSpace;
+@protocol OSCAddressSpaceDelegateProtocol
+	- (void) newNodeCreated:(OSCNode *)n;
+@end
 
 
 
 
-@interface OSCAddressSpace : OSCNode {
+id _mainAddressSpace;
 
-}
 
-+ (OSCAddressSpace *) mainSpace;
 
 
+@interface OSCAddressSpace : OSCNode {
+	id			delegate;
+}
 
-//- (void) setNode:(OSCNode *)n atArray:(NSArray *)a;
++ (OSCAddressSpace *) mainSpace;
 
 - (void) renameAddress:(NSString *)before to:(NSString *)after;
 - (void) renameAddressArray:(NSArray *)before toArray:(NSArray *)after;
@@ -46,4 +49,7 @@ id _mainAddressSpace;
 - (void) addDelegate:(id)d forPath:(NSString *)p;
 - (void) removeDelegate:(id)d forPath:(NSString *)p;
 
+@property (assign, readwrite) id delegate;
+
+
 @end</diff>
      <filename>FrameworkSrc/OSCAddressSpace.h</filename>
    </modified>
    <modified>
      <diff>@@ -22,6 +22,7 @@
 + (void) initialize	{
 	//NSLog(@&quot;%s&quot;,__func__);
 	_mainAddressSpace = [[OSCAddressSpace alloc] init];
+	[_mainAddressSpace setAddressSpace:_mainAddressSpace];
 }
 
 - (NSString *) description	{
@@ -45,6 +46,7 @@
 - (id) init	{
 	//NSLog(@&quot;%s&quot;,__func__);
 	if (self = [super init])	{
+		delegate = nil;
 		return self;
 	}
 	[self release];
@@ -57,6 +59,7 @@
 
 - (void) renameAddress:(NSString *)before to:(NSString *)after	{
 	//NSLog(@&quot;%s ... %@ -&gt; %@&quot;,__func__,before,after);
+	
 	if (before==nil)	{
 		NSLog(@&quot;\terr: before was nil %s&quot;,__func__);
 		return;
@@ -66,10 +69,12 @@
 		return;
 	}
 	[self renameAddressArray:[[before trimFirstAndLastSlashes] pathComponents] toArray:[[after trimFirstAndLastSlashes] pathComponents]];
+	
 }
 
 - (void) renameAddressArray:(NSArray *)before toArray:(NSArray *)after	{
-	//NSLog(@&quot;%s ... %@ -&gt; %@&quot;,__func__,before,after);
+	//NSLog(@&quot;%s&quot;,__func__);
+	
 	if (before==nil)	{
 		NSLog(@&quot;\terr: before was nil %s&quot;,__func__);
 		return;
@@ -81,7 +86,6 @@
 	
 	OSCNode			*beforeNode = [self findNodeForAddressArray:before];
 	OSCNode			*afterNode = [self findNodeForAddressArray:after];
-	//OSCNode			*beforeParentNode = nil;
 	
 	//	if the 'beforeNode' is nil
 	if (beforeNode == nil)	{
@@ -96,6 +100,7 @@
 	else	{
 		[self setNode:beforeNode forAddressArray:after];
 	}
+	
 }
 
 	
@@ -107,7 +112,7 @@
 		[self setNode:n forAddressArray:[[a trimFirstAndLastSlashes] pathComponents]];
 }
 - (void) setNode:(OSCNode *)n forAddressArray:(NSArray *)a	{
-	//NSLog(@&quot;%s&quot;,__func__);
+	//NSLog(@&quot;%s ... %@ - %@&quot;,__func__,n,a);
 	if ((a==nil)||([a count]&lt;1))	{
 		NSLog(@&quot;\terr: a was %@ in %s&quot;,a,__func__);
 		return;
@@ -124,10 +129,15 @@
 	//	make sure the node's got the proper name (it could be different from the passed array's last object)
 	if (n != nil)
 		[n setNodeName:[a lastObject]];
-	//	find the new parent node
+	//	find the new parent node for the destination
 	NSMutableArray		*parentAddressArray = [[a mutableCopy] autorelease];
 	[parentAddressArray removeLastObject];
-	afterParent = [self findNodeForAddressArray:parentAddressArray];
+	//	if the parent's address array is empty, the root level node is the parent
+	if ([parentAddressArray count] == 0)
+		afterParent = self;
+	else
+		afterParent = [self findNodeForAddressArray:parentAddressArray];
+	
 	//	if there isn't a parent node (if i have to make one)
 	if (afterParent == nil)	{
 		//	if i passed a non-nil node (if i'm actually moving a node), i'll have to make the parent
@@ -168,6 +178,8 @@
 //	this method is called whenever a new node is added to the address space- subclasses can override this for custom notifications
 - (void) newNodeCreated:(OSCNode *)n	{
 	//NSLog(@&quot;%s ... %@&quot;,__func__,[n fullName]);
+	if (delegate != nil)
+		[delegate newNodeCreated:n];
 }
 - (void) dispatchMessage:(OSCMessage *)m	{
 	//NSLog(@&quot;%s ... %@&quot;,__func__,m);
@@ -200,5 +212,12 @@
 		[foundNode addDelegate:d];
 }
 
+- (void) setDelegate:(id)n	{
+	delegate = n;
+}
+- (id) delegate	{
+	return delegate;
+}
+
 
 @end</diff>
      <filename>FrameworkSrc/OSCAddressSpace.m</filename>
    </modified>
    <modified>
      <diff>@@ -85,6 +85,7 @@ typedef enum	{
 //	simply sends the passed message to all my delegates
 - (void) dispatchMessage:(OSCMessage *)m;
 
+@property (assign, readwrite) id addressSpace;
 @property (assign, readwrite) NSString *nodeName;
 @property (readonly) NSString *fullName;
 @property (readonly) id nodeContents;</diff>
      <filename>FrameworkSrc/OSCNode.h</filename>
    </modified>
    <modified>
      <diff>@@ -263,6 +263,7 @@
 			foundNode = [OSCNode createWithName:pathComponent];
 			[nodeToSearch addNode:foundNode];
 			[addressSpace newNodeCreated:foundNode];
+			
 		}
 		nodeToSearch = foundNode;
 	}
@@ -308,6 +309,16 @@
 		NSLog(@&quot;\terr: couldn't find delegate to remove- %s&quot;,__func__);
 }
 - (void) informDelegatesOfNameChange	{
+	//NSLog(@&quot;%s ... %@&quot;,__func__,self);
+	//	first of all, recalculate my full name (this could have been called by a parent changing its name)
+	if (fullName != nil)
+		[fullName release];
+	fullName = nil;
+	if (parentNode == addressSpace)
+		fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
+	else if (parentNode != nil)
+		fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
+	
 	//	tell my delegates that there's been a name change
 	if ((delegateArray!=nil)&amp;&amp;([delegateArray count]&gt;0))	{
 		[delegateArray rdlock];
@@ -318,10 +329,22 @@
 				}
 			}
 			@catch (NSException *err)	{
-				NSLog(@&quot;\terr: exception %@ in %s&quot;,err,__func__);
+				NSLog(@&quot;\terr: exception %@ in part A of %s&quot;,err,__func__);
 			}
 		[delegateArray unlock];
 	}
+	//	tell all my sub-nodes that their name has also changed
+	if ((nodeContents!=nil)&amp;&amp;([nodeContents count]&gt;0))	{
+		[nodeContents rdlock];
+			@try	{
+				for (OSCNode *nodePtr in [nodeContents array])
+					[nodePtr informDelegatesOfNameChange];
+			}
+			@catch (NSException *err)	{
+				NSLog(@&quot;\terr: exception %@ in part B of %s&quot;,err,__func__);
+			}
+		[nodeContents unlock];
+	}
 }
 - (void) addDelegatesFromNode:(OSCNode *)n	{
 	//	put together an array of the delegates i'll be adding
@@ -350,7 +373,14 @@
 }
 
 
+- (void) setAddressSpace:(id)n	{
+	addressSpace = n;
+}
+- (id) addressSpace	{
+	return addressSpace;
+}
 - (void) setNodeName:(NSString *)n	{
+	//NSLog(@&quot;%s ... %@ -&gt; %@&quot;,__func__,nodeName,n);
 	//	first of all, make sure that i'm not trying to rename it to the same name...
 	if ((n!=nil)&amp;&amp;(nodeName!=nil)&amp;&amp;([n isEqualToString:nodeName]))
 		return;
@@ -361,26 +391,22 @@
 	if (n != nil)
 		nodeName = [n retain];
 	
-	if (fullName != nil)
-		[fullName autorelease];
-	fullName = nil;
+	//if (fullName != nil)
+	//	[fullName autorelease];
+	//fullName = nil;
 	if (n != nil)	{
-		if (parentNode == addressSpace)
-			fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
-		else if (parentNode != nil)
-			fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
-		/*
-		if (parentNode != addressSpace)
-			fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
-		else
-			fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
-		*/
+		//if (parentNode == addressSpace)
+		//	fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
+		//else if (parentNode != nil)
+		//	fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
 		//NSLog(@&quot;\tfullName = %@, %s&quot;,fullName,__func__);
 	}
 	
 	//	if there's a parent node (if it's actually in the address space), tell my delegates about the name change
-	if (parentNode != nil)
+	if (parentNode != nil)	{
+		//NSLog(@&quot;\tparent node isn't nil, informing delegates of name change&quot;);
 		[self informDelegatesOfNameChange];
+	}
 }
 - (NSString *) nodeName	{
 	return nodeName;
@@ -395,20 +421,14 @@
 	//NSLog(@&quot;%s&quot;,__func__);
 	parentNode = n;
 	
-	if (fullName != nil)
-		[fullName autorelease];
-	fullName = nil;
+	//if (fullName != nil)
+	//	[fullName autorelease];
+	//fullName = nil;
 	
-	if (parentNode == addressSpace)
-		fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
-	else if (parentNode != nil)
-		fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
-	/*
-	if (parentNode != addressSpace)
-		fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
-	else if (parentNode == addressSpace)
-		fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
-	*/
+	//if (parentNode == addressSpace)
+	//	fullName = [[NSString stringWithFormat:@&quot;/%@&quot;,nodeName] retain];
+	//else if (parentNode != nil)
+	//	fullName = [[NSString stringWithFormat:@&quot;%@/%@&quot;,[parentNode fullName],nodeName] retain];
 	//NSLog(@&quot;\tfullName = %@, %s&quot;,fullName,__func__);
 	
 	//	if there's a parent node (if it's actually in the address space), tell my delegates about the name change</diff>
      <filename>FrameworkSrc/OSCNode.m</filename>
    </modified>
    <modified>
      <diff>@@ -17,5 +17,7 @@
 
 - (NSString *) trimFirstAndLastSlashes;
 - (NSString *) stringByDeletingFirstPathComponent;
+- (NSString *) firstPathComponent;
+- (NSString *) stringBySanitizingForOSCPath;
 
 @end</diff>
      <filename>FrameworkSrc/OSCStringAdditions.h</filename>
    </modified>
    <modified>
      <diff>@@ -52,6 +52,36 @@
 	return nil;
 	*/
 }
+- (NSString *) firstPathComponent	{
+	NSString	*trimmedString = [self trimFirstAndLastSlashes];
+	NSArray		*pathComponents = [trimmedString pathComponents];
+	return [pathComponents objectAtIndex:0];
+}
+- (NSString *) stringBySanitizingForOSCPath	{
+	int				length = [self length];
+	NSRange			desiredRange = NSMakeRange(0,length);
+	
+	if ([self characterAtIndex:desiredRange.length-1] == '/')
+		--desiredRange.length;
+	
+	//	if i start with a slash...
+	if ([self characterAtIndex:0] == '/')	{
+		//	if the length didn't change, i don't end with a slash- i can just return myself
+		if (length == desiredRange.length)
+			return self;
+		//	else if the length did change, just return a substring
+		return [self substringWithRange:desiredRange];
+	}
+	//	else if i don't start with a slash, i'll have to add one
+	else	{
+		//	if the length didn't change, i don't end with a slash- i just have to add one
+		if (length == desiredRange.length)
+			return [NSString stringWithFormat:@&quot;/%@&quot;,self];
+		//	else if the length changed, i have to add a slash at the start and delete one at the end
+		else
+			return [NSString stringWithFormat:@&quot;/%@&quot;,[self substringWithRange:desiredRange]];
+	}
+}
 
 
 @end</diff>
      <filename>FrameworkSrc/OSCStringAdditions.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>29a6b5e09f99a0902ae692ea3c3e861edf5067d6</id>
    </parent>
  </parents>
  <author>
    <name>mrRay</name>
    <email>ray@vidvox.net</email>
  </author>
  <url>http://github.com/mrRay/vvosc/commit/d28864562f41cca0b796dc779e379399391e13e9</url>
  <id>d28864562f41cca0b796dc779e379399391e13e9</id>
  <committed-date>2009-03-25T23:07:13-07:00</committed-date>
  <authored-date>2009-03-25T23:07:13-07:00</authored-date>
  <message>more work on the address space</message>
  <tree>4c683b9c79eedd86c7ecece73044dc190474868e</tree>
  <committer>
    <name>mrRay</name>
    <email>ray@vidvox.net</email>
  </committer>
</commit>
