> at the very least, without auto generation, you need :
> 
> 1 place for the commandtag (commandtags.h)
> 1 place for the invoke method (lyxfunc.C)
> 1 place for the instantiation of the lyxfunc (LyXAction.C)

What about nuking the commandtags and putting everything in a
std::map<string, whatever>, where the index is the (first word of)
the command?

Comparing strings instead numbers should cost only a constant factor of
time more than comparing enums, starting off from a very tiny amount.
Morover, lookup in the map is O(ln n) compared to O(n) in the
big case scwitch. So it shold not really be noticable.

The "big loss" is "type safety": We don't notice at compile time a
misspelled command. OTOH at some time we might wish to dynamically 
extend lyx - say by a newly installed converter - without quitting the
current work. In this case the infrastructure would be in place already.

I have a similar scheme working in my current project: There everything is
pretty modular and I can get different versions off the program simply by
linking different sets of modules. Every modul has a global static object
which registers on construction the modules' commands with a big
central dispatcher (basically a map<string, command>).

Dependencies are basically resolved by the linker and the dynamic loader.
Upon entrace of main() the central dispatcher knows exactly the commands of
the available modules without the need to query them individually.

I don't have any performance problems in this corner of the program.

Andre'

-- 
André Pönitz ........................................ [EMAIL PROTECTED]

Reply via email to