[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-multimedia
Subject:    'default ' keyword working.
From:       Nicolas Brodu <nicolas.brodu () free ! fr>
Date:       2000-03-20 21:36:18
[Download RAW message or body]

Hi all!

I coded the 'default' port feature today. It works fine. To sum it up, it
enables connecting objects in a simpler way. It should also enable automatic
left to left and right to right connection for stereo objects (in fact, the
mapping is done according to the order found in the idl, as there is no concept
of 'left' and 'right' in the streams).

The syntax is simple: just add a 'default' keyword in front of the stream
definition, or on a single line. The syntax are equivalent and can be mixed.
Only the order is important.

example with a default of 2 streams in input (and since there is only one
output, it is automatically the default one):
  interface Synth_ADD : SynthModule {
      default in audio stream invalue1,invalue2;
      out audio stream outvalue;
  };

same on a single line:
  interface Synth_MUL : SynthModule {
      in audio stream invalue1,invalue2;
      out audio stream outvalue;
      default invalue1, invalue2;
  };

And the use in practice (from flow.cc):
// object initialization
  setValue(&freq, 440.0);
// object connection
  connect(&freq, &sin);
  connect(&sin, &play, "invalue_left");
  connect(&sin, &play, "invalue_right");

The code is generated inside the smartwrappers. If needs be, it can easily be
moved to the _base object or anywhere else. There are 2 functions
defaultPortsIn() and defaultPortsOut() that return a vector<std::string>
containing the default port names for each direction.

Issue: When inheriting from a parent, the parent defaults are added _after_ the
object defaults (and in the inheritance list order), so that the object has
priority. There is still a problem because if a parent has only one stream and
the child also one, then this will end up with having a default of 2 streams for
the child (where we might want to have only one default).

The connection asserts that the number of defaults match for the input/output of
the connected objects, when the ports aren't specified explicitely. Another
possibility would be to do as many connections as possible between the source
and destination objects. This would partially solve the inheritance issue above,
but then one must be more careful when connecting 2 objects. What do you prefer?

On another topic, I didn't have time to investigate but it seems that the
smartwrapper code have a minor reference counting bug somewhere for remote
connection. More precisely, artscat ends up after a few seconds when the
reference clean finds a not so 'unused' object and frees it.


That's all, folks!
Nicolas
-- 
A shortcut is the longest distance between two points. (unknown author)

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic