vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
OSCNode.h
1 
2 #if IPHONE
3 #import <UIKit/UIKit.h>
4 #else
5 #import <Cocoa/Cocoa.h>
6 #endif
7 #import "OSCMessage.h"
8 #import <VVBasics/MutNRLockArray.h>
9 #import <VVBasics/VVBasicMacros.h>
10 #import <libkern/OSAtomic.h>
11 
12 
13 
15 
20 - (void) node:(id)n receivedOSCMessage:(OSCMessage *)msg;
22 - (void) nodeNameChanged:(id)node;
24 - (void) nodeDeleted:(id)node;
25 @end
26 
27 
29 
34 - (NSMutableArray *) namespaceArrayForNode:(id)n;
36 - (NSString *) docStringForNode:(id)n;
38 - (NSString *) typeSignatureForNode:(id)n;
40 - (OSCValue *) currentValueForNode:(id)n;
42 - (NSString *) returnTypeStringForNode:(id)n;
43 @end
44 
45 
46 
47 
49 
57 @interface OSCNode : NSObject {
58  id addressSpace; // the class OSCAddressSpace is a subclass of OSCNode, and is essentially the "root" node. all OSCNodes have a pointer to the root node!
59  BOOL deleted;
60 
61  OSSpinLock nameLock;
62  NSString *nodeName; // "local" name: name of the node at /a/b/c is "c"
63  NSString *fullName; // "full" name: name of the node at /a/b/c is "/a/b/c"
64  MutLockArray *nodeContents; // Contains OSCNode instances- this OSCNode's sub-nodes. type 'MutLockArray'- this should all be threadsafe...
65  OSCNode *parentNode; // my "parent" node (or nil). NOT retained!
66  OSCNodeType nodeType; // What 'type' of node i am
67  BOOL hiddenInMenu; // NO by default. if YES, this node (and all its sub-nodes) will be omitted from menus!
68 
70  OSSpinLock lastReceivedMessageLock;
71  MutNRLockArray *delegateArray; // type 'MutNRLockArray'. contents are NOT retained! could be anything!
72 
73  BOOL autoQueryReply; // NO by default
74  id <OSCNodeQueryDelegate> queryDelegate; // NOT RETAINED
75 }
76 
77 /* only called by the address space to craft a formatted string for logging purposes */
78 - (void) _logDescriptionToString:(NSMutableString *)s tabDepth:(int)d;
79 
80 // Creates and returns an auto-released instance of OSCNode with the passed name. Returns nil if passed a nil name.
81 + (id) createWithName:(NSString *)n;
82 // Inits an instance of OSCNode with the passed name. Returns nil if passed a nil name.
83 - (id) initWithName:(NSString *)n;
84 - (id) init;
85 
86 - (void) prepareToBeDeleted;
87 
89 - (NSComparisonResult) nodeNameCompare:(OSCNode *)comp;
90 
91 // Adds the passed node to my ndoe contents
92 - (void) addLocalNode:(OSCNode *)n;
93 // Adds the passed nodes to my node contents
94 - (void) addLocalNodes:(NSArray *)n;
95 // Call this to remove the passed node from my contents. This method releases the passed node, but doesn't try to deactivate it! If the node was only retained by the address space, this is equivalent to "deleteLocalNode:".
96 - (void) removeLocalNode:(OSCNode *)n;
97 // Call this to remove the passed node from my contents. This method releases the passed node and deactivates it (calls "prepareToBeDeleted" so it stops sending delegate methods/responding).
98 - (void) deleteLocalNode:(OSCNode *)n;
100 - (void) removeFromAddressSpace;
101 
102 // It's assumed that the passed name doesn't have any wildcards/regex. If the receiver contains a node with the identical name as the passed string, the node will be returned. This is not a "deep" search, it's restricted to the receiver's nodeContents array.
103 - (OSCNode *) findLocalNodeNamed:(NSString *)n;
104 // Same as findLocalNodeNamed:, but if any of the interim nodes don't exist they will be created.
105 - (OSCNode *) findLocalNodeNamed:(NSString *)n createIfMissing:(BOOL)c;
106 
107 // Compares the names of all the receiver's sub-nodes to the passed POSIX regex string, returns an array with all the nodes whose nodeNames match the regex. If there are no sub-nodes or none of the sub-nodes match the regex, returns nil.
108 - (NSMutableArray *) findLocalNodesMatchingPOSIXRegex:(NSString *)regex;
109 - (void) _addLocalNodesMatchingRegex:(NSString *)regex toMutArray:(NSMutableArray *)a;
110 
111 // these "findNode" methods DO NOT USE regex! it is assumed that the passed string is NOT a regex algorithm (the language "findNode" implies a single result, precluding the use of regex)
112 - (OSCNode *) findNodeForAddress:(NSString *)p;
113 // It's assumed that the passed address doesn't have any wildcards/regex (no checking is done). The receiver tries to locate the node at the passed address (relative to the receiver). If c is YES, any OSCNodes missing in the passed address are automatically created. If they have sub-nodes, the auto-created nodes' types are set to OSCNodeDirectory; if not, the auto-created nodes' types are OSCNodeTypeUnknown
114 - (OSCNode *) findNodeForAddress:(NSString *)p createIfMissing:(BOOL)c;
115 - (OSCNode *) findNodeForAddressArray:(NSArray *)a;
116 - (OSCNode *) findNodeForAddressArray:(NSArray *)a createIfMissing:(BOOL)c;
117 // THESE METHODS ALWAYS USE REGEX TO FIND MATCHES! path components may be regex strings- this returns all the nodes that match every component in the passed address/address array!
118 - (NSMutableArray *) findNodesMatchingAddress:(NSString *)a;
119 - (NSMutableArray *) findNodesMatchingAddressArray:(NSArray *)a;
120 
121 // If you want to receive OSC messages and other info (OSCNodeDelegateProtocol) from an OSCNode, you need to be its delegate.
122 // NODE DELEGATES ARE __NOT__ RETAINED!
123 // NODE DELEGATES __MUST__ REMOVE THEMSELVES FROM THE DELEGATE ARRAY!
125 - (void) addDelegate:(id <OSCNodeDelegateProtocol>)d;
127 - (void) removeDelegate:(id)d;
128 - (void) informDelegatesOfNameChange;
129 - (void) addDelegatesFromNode:(OSCNode *)n;
130 
132 - (void) dispatchMessage:(OSCMessage *)m;
133 
135 - (OSCMessage *) generateAutomaticResponseForQuery:(OSCMessage *)m;
136 
137 @property (assign, readwrite) id addressSpace;
139 @property (assign, readwrite) NSString *nodeName;
140 - (void) _setNodeName:(NSString *)n;
142 @property (readonly) NSString *fullName;
144 @property (readonly) MutLockArray *nodeContents;
145 @property (assign, readwrite) OSCNode *parentNode;
147 @property (assign, readwrite) OSCNodeType nodeType;
148 @property (assign, readwrite) BOOL hiddenInMenu;
150 @property (readonly) OSCMessage *lastReceivedMessage;
152 @property (readonly) OSCValue *lastReceivedValue;
153 @property (readonly) id delegateArray;
155 @property (assign,readwrite) BOOL autoQueryReply;
157 @property (assign,readwrite) id<OSCNodeQueryDelegate> queryDelegate;
158 
159 @end
OSCMessage * lastReceivedMessage
The last message sent to this node is retained (the message is retained instead of the value because ...
Definition: OSCNode.h:69
NSString * fullName
Sets or gets the node's full address. The node "/A/B/C" would return "/A/B/C".
Definition: OSCNode.h:63
MutLockArray * nodeContents
Read-only, returns nil or a threadsafe array of OSCNode instances "inside" me.
Definition: OSCNode.h:64
Corresponds to an OSC message: contains zero or more values, and the address path the values have to ...
Definition: OSCMessage.h:18
Subclass of MutLockArray; this class does NOT retain the objects in its array!
Definition: MutNRLockArray.h:21
An OSCNode's queryDelegate must respond to these methods, which are called when a query-type OSCMessa...
Definition: OSCNode.h:32
OSCNodeType
OSCNodeType.
Definition: OSCConstants.h:85
OSCNode describes a single destination for OSC addresses. The OSC address space is made up of many di...
Definition: OSCNode.h:57
BOOL autoQueryReply
Only used for the OSC query protocol. NO by default. if YES and the queryDelegate is nil or doesn't r...
Definition: OSCNode.h:73
NSString * nodeName
Sets or gets the node's local name. The node "/A/B/C" would return "C".
Definition: OSCNode.h:62
Delegates of OSCNode must respond to all three of these methods.
Definition: OSCNode.h:18
OSCValue encapsulates any value you can send or receive via OSC. It is NOT mutable at this time...
Definition: OSCValue.h:21
OSCNodeType nodeType
Nodes can have a basic "type", which is useful for sorting and organization.
Definition: OSCNode.h:66
id< OSCNodeQueryDelegate > queryDelegate
Only used for the OSC query protocol. nil by default, NOT retained, must respond to the OSCNodeQueryD...
Definition: OSCNode.h:74
Similar to NSMutableArray, but thread-safe. Internally, uses an NSMutableArray and a rwlock...
Definition: MutLockArray.h:20