register mixin
Frank Benoit
keinfarbton at nospam.xyz
Thu Apr 13 13:35:40 PDT 2006
/**/ // I want to use mixin very compact, like this:
/**/
/**/ class Speed : Signal!(int){
/**/ mixin Scaling( 0, 1.23, "km/h") scale_kmh;
/**/ mixin NamedRange( 100, 200, "HIGH SPEED" ) highSpeed;
/**/ mixin NamedValue( 250, "MAX" ) maxSpeed;
/**/ }
/**/
/**/ Speed speed = new Speed;
/**/ // set the internal 'Signal!(int).mValue'
/**/ // variable to a scaled value
/**/ speed.scaled_kmh.setValue( 250 );
/**/ // set the internal 'Signal!(int).mValue' variable to 250
/**/ speed.maxSpeed.set();
/**/
/**/ // So far no problem i think.
/**/
/**/ // And now I want the way back:
/**/ // Each mixin should register a class or delegate or ...
/**/ // to give the Signal class the possibility to find the
/**/ // Label "MAX" or print the scaled "km/h"
/**/
/**/ class Signal(T){
/**/ // ....
/**/ public char[] toString(){
/**/ char[] result;
/**/ foreach( SomeThing st; list ){
/**/ result ~= st.toString( mValue );
/**/ }
/**/ return result;
/**/ }
/**/ // ....
/**/ }
/**/
/*******************************/
/* Is there any way? */
/*******************************/
More information about the Digitalmars-d-learn
mailing list