#pragma once #include "iostream.hfa" forall( E ) trait Bounded { E lowerBound(); E upperBound(); }; forall( E | Bounded( E ) ) trait Serial { unsigned fromInstance( E e ); E fromInt( unsigned i ); E succ( E e ); E pred( E e ); }; // Design one forall( E, V | Serial( E ) ) trait CfaEnum { char * label( E e ); unsigned int posn( E e ); V value( E e ); }; // I/O forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) ) istype & ?|?( istype &, E ); forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) { ostype & ?|?( ostype &, E ); OSTYPE_VOID( E ); } forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) { ostype & ?|?( ostype &, E ); OSTYPE_VOID( E ); } // Design two <- should go for this if we have change the cost model // forall( E | Serial( E ) ) trait CfaEnum { // char * label( E e ); // unsigned int posn( E e ); // }; // forall( E, V| CfaEnum( E)) trait TypedEnum { // V value( E e); // }; forall( E, V | CfaEnum( E, V ) ) { // relational operators int ?==?( E, E ); int ?!=?( E, E ); int ??( E, E ); int ?>=?( E, E ); int ++?( E &); int ?++( E &); int --?( E &); int ?--( E &); }