[Tdg] Intelligent 'enum's in C++

Graham Wakefield wakefield at mat.ucsb.edu
Tue Feb 20 17:40:17 PST 2007


Except that, on closer inspection, you need to define BOTH an enum,  
and a Map_t, for each event type, so we still have duplication in  
different locations.  Might as well have a static function with a  
switch to look up the event name from the event enum.

On Feb 20, 2007, at 1:34 PM, Alex Norman wrote:

> Nice, I was thinking that events have both an enum and a classname  
> (string), I
> was doing something like what wes showed for class names... but  
> grouping the
> enum and classname into one unit like this is a really good way to  
> do it I
> think.
>
> -Alex
>
> On  0, Wesley Smith <wesley.hoke at gmail.com> wrote:
>> EState::Map_t EState::m_Map[] =
>>  {
>>      {Unknown, "Unknown"},
>>      {Solid,   "Solid Matter"},
>>      {Liquid,  "Liquid Matter "},
>>      {Gas,     "Vapour"}
>>  };
>>
>> These can be generated with the macro
>>
>> TABLE_ENTRY(val)      {val, #val}
>>
>> so you don't have to type as much or have any mistakes.
>>
>> wes
>> _______________________________________________
>> Tdg mailing list
>> Tdg at mat.ucsb.edu
>> http://zydeco.mat.ucsb.edu/mailman/listinfo/tdg
> _______________________________________________
> Tdg mailing list
> Tdg at mat.ucsb.edu
> http://zydeco.mat.ucsb.edu/mailman/listinfo/tdg




More information about the Tdg mailing list