Hi.
I have an custom object that I coded, and I would like to store pointers to other instances of this object within the dataspace.
To clarify, pretend I have 2 instances of the obj on my canvas. Then I receive an input to obj_1 that calls a specific method. I would like that method to be able to look into that object's dataspace to see if it is 'linked' with any other objects, and execute methods in those objects.
I don't want to use regular pd send/receive/connections/etc because I want to be able to dynamically specify these 'links' during runtime.
Also, this technique should also hold if the objects are not on the same canvas (possibly anywhere in other patches). I guess this means that I have to pass an ID of some sort when I want to specify a connection. For example, if each object has a unique numeric ID, I would send a message 'connect 12345' to an object, and a handler would search the entire pd object space for an object that had that ID and then store a pointer to that object in the dataspace.
Is this possible? Does anyone know how I can search the entire pd object space? How do I find these pointers?
Thanks, Mike Wozniewski
A follow-up question that might provide a solution to this problem:
Perhaps I could create a 'list' during my obj_setup() method which would be accessible by all instances of my class?
Since obj_setup() is only called once when the library is loaded, the initial empty list would be created at that time. Then, in the obj_new() method - that is called whenever a new object is instantiated - I would just push an ID onto the list. Then I need to only search that list when I make 'links' between objects.
Is this possible? How would I go about creating this list? Where should the 'list' variable be defined?
Thanks, Mike Wozniewski
Hi.
I have an custom object that I coded, and I would like to store pointers to other instances of this object within the dataspace.
To clarify, pretend I have 2 instances of the obj on my canvas. Then I receive an input to obj_1 that calls a specific method. I would like that method to be able to look into that object's dataspace to see if it is 'linked' with any other objects, and execute methods in those objects.
I don't want to use regular pd send/receive/connections/etc because I want to be able to dynamically specify these 'links' during runtime.
Also, this technique should also hold if the objects are not on the same canvas (possibly anywhere in other patches). I guess this means that I have to pass an ID of some sort when I want to specify a connection. For example, if each object has a unique numeric ID, I would send a message 'connect 12345' to an object, and a handler would search the entire pd object space for an object that had that ID and then store a pointer to that object in the dataspace.
Is this possible? Does anyone know how I can search the entire pd object space? How do I find these pointers?
Mike Wozniewski wrote:
A follow-up question that might provide a solution to this problem:
Perhaps I could create a 'list' during my obj_setup() method which would be accessible by all instances of my class?
Yes, that's the way to go.
Is this possible? How would I go about creating this list? Where should the 'list' variable be defined?
As a global variable in your code (not part of the t_yourobject struct and not defined as static). You might also need another variable (being declared the same way) counting the number of instances of your object since the first one will probably have to do some initilization work.
Olaf