Change in the unittype and linktype interface

Georg Seidel <[email protected]>
Newsgroups gmane.comp.video.gephex.devel
Message-ID <[email protected]>
I would like to propose a change of the interface of UnitType and 
LinkType (as exported from the plugins).

I will just describe units, as links will work analogously.
The current signature vor unittype is (C-version):

     int init(void* logger, void (*)(void* logger, int, const char*));
     void deinit();

     void* new_instance();
     void delete_instance(void* instance);

     const char* get_spec(void);
     const char* get_port_spec(int port);

     int set_port(void* instance, int port, void* link, void** vtable);

     int update(void* instance, double, int**);

     void  strong_deps_done( ,int** );

The equivalent version in the interface definition language (that is 
used by idlc) is:

     interface Unit
     {
       bool init(Logger)                                : function;
       void deinit()                                    : function;

       new_instance()                                   : constructor;
       delete_instance()                                : destructor;

       ptr char get_spec()                              : function;

       ptr char get_port_spec(in int index)             : function;

       void set_port(in int index, in Link l)           : method;

       bool update(in double time, out ptr int patch)   : method;

       void strong_deps_done(out ptr int needed_ports)  : method;
     }


The problem I have with this interface is that is mixes two different 
concepts: the Unit type (which is the type of instances of an effect)
and the UnitType type (which is the type of instances that describe 
properties for all Units of this type).
If this is confusing please just look at the interfaces below, because 
it's actually quite simple ;)

My suggestion is to split it into two interfaces:

     interface UnitType
     {
       bool init(Logger)                                : constructor;
       void deinit()                                    : destructor;

       Unit new_instance()                              : method;

       ptr char get_spec()                              : method;

       ptr char get_port_spec(in int index)             : method;
     }

and

     interface Unit
     {
       delete_instance()                                : destructor;

       void set_port(in int index, in Link l)           : method;

       bool update(in double time, out ptr int patch)   : method;

       void strong_deps_done(out ptr int needed_ports)  : method;
     }
.

Note that the methods in UnitType were functions in the old Unit interface.
With these interfaces it will be possible to create the Unit, UnitType, 
Link and LinkType wrappers in gphxcore automatically with idlc.

Also, it will be possible to store common data for several units in
the in the UnitType object that created them (thus avoiding the use of
static data in unit implementations).

Third the automatich code that pluc/idlc produces for plugins will be
easier to create.


On the negative side, the only argument against this change seems to be 
that some more glue code for the higher number of interfaces has to be 
created. But since this will be automated I don't think that this is a 
too bad thing.


Regards,

Georg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.