hallo again. i wonder if there is a way to defer the instantiation of an object if this object depends on the instantiation of another one. my use case: i'm writing an external that allows to use sqlite3 databases in pd. i have an object called "database" that associates a file path to an alias. this alias is used by other objects called "query". by now i'm deferring the binding between the two as far as possible since i have no control on who is instantiated first when a patch is loaded. but i could certainly make many improvements if in the "new method" of the query i was sure that the database object has already been instantiated. (it's a little more complex than that, but anyway...) thanks m.
Hi max, first of all, using a library of externals or a shared library for common code makes the task easier for sure - because the objects don't have to rely on communication via PD messages. Concerning the deferred loading - that's not too hard, if the query object consists of a PD external object and separated from that, an object that does the work which the external object points at. If database is loaded first and query afterwards, query can construct both the external and the underlying object and connect them. If query is loaded first, it constructs the external and stores an entry in a list of pending objects. Upon construction of database, this list gets processed and the pending query objects are created and connected to the external objects.
Messages to the query objects would get lost of course, if no database has been created. This is no problem for patcher loading, since loadbangs get sent after all objects have been created.
best greetings, Thomas
max jacob schrieb:
hallo again. i wonder if there is a way to defer the instantiation of an object if this object depends on the instantiation of another one. my use case: i'm writing an external that allows to use sqlite3 databases in pd. i have an object called "database" that associates a file path to an alias. this alias is used by other objects called "query". by now i'm deferring the binding between the two as far as possible since i have no control on who is instantiated first when a patch is loaded. but i could certainly make many improvements if in the "new method" of the query i was sure that the database object has already been instantiated. (it's a little more complex than that, but anyway...) thanks m.
PD-dev mailing list PD-dev@iem.at http://iem.at/cgi-bin/mailman/listinfo/pd-dev