How to keep reference of abstractions called & placed dynamically in patchers ?
I’m looking for a way to keep reference of abstractions called & placed dynamically in my Patcher.
I’d like to communicate with them, be able to remove them, to alter some properties (which would be stored inside each abstractions) etc.
I did something using JS & I keep my objects reference in JS arrays.
BUT, I’d like to be able to move further and to use not indexed stuff in order to be able to remove/add easily stuff.
The C++ Map structure is ideal.
I tried to use JAVA for that in order to use other data structures, but I didn’t succeed to place any abstraction using JAVA : http://cycling74.com/forums/topic.php?id=40215
What could I use here? Dictionaries ?
Any help would be appreciated :)
I had to do that a couple of times. Object-oriented programming, dictionaries, etc… is of course the elegant way, but you now, you can do it in a much simpler (and I think more efficient) way:
. each instance of an abstraction (let’s call it the "client") has a unique ID, like "#0-blabla", that it sends to a common send/receive bus to the global patch (let’s call it the "server")
. the server has a collfile, for instance, where it stores all IDs of all clients
. the server can communicate with the client by sending requests to a client-specific receive box, for example called "r #0-blabla-requests". The client examinates the requests, modifies its properties if requested, and sends back some relevant info to the server, again if requested.
Therefore, you don’t need an object-oriented structure on the server side (which avoids the use of java or equivalent), since all info is anyway stored and accessible in each client. The key point is that the server keeps the trace (i.e. the ID) about each client.
I like that way.
In my case, this need is included in a huge project (= http://cycling74.com/forums/topic.php?id=40222)
I’d need to save properties, attributes, etc to XML or whatever and this is the reason why I thought about code at first even for that part.
Indeed, I could request stuff using that way
Maybe it also could answer to this : http://cycling74.com/forums/topic.php?id=40230&replies=2#post-195206
Indeed, I’d need update on attributes change.. maybe I could use other max object to avoid to do permanent polling or to that in the code
As you wrote, storing data and requesting it are two different things. So you can request them the way I suggested, and store them the way you want.
I don’t think anyway that the method I suggested will help to query and modify the attributes of an object, and js in max is limited in that way. For this you’ll probably have to code an external.
requesting them could be avoid if I use the core (JS or JAVA) to interact with my object.
that way, the core would have their position at anytime.
if I want to make some movements of objects, the core (or another routine/patch attached to the core) would handle this, informing the core even before it informs the target.
Does it make sense to you ?