Hiroyuki Komatsu
komat****@users*****
2005年 3月 7日 (月) 19:01:57 JST
Index: prime/lib/Makefile.am diff -u prime/lib/Makefile.am:1.5 prime/lib/Makefile.am:1.6 --- prime/lib/Makefile.am:1.5 Mon Mar 7 16:51:32 2005 +++ prime/lib/Makefile.am Mon Mar 7 19:01:57 2005 @@ -1,5 +1,5 @@ # Makefile.am: Template of Automake for prime/lib. -# $Id: Makefile.am,v 1.5 2005/03/07 07:51:32 komatsu Exp $ +# $Id: Makefile.am,v 1.6 2005/03/07 10:01:57 komatsu Exp $ # # Copyright (C) 2003 Hiroyuki Komatsu <komat****@taiya*****> # All rights reserved. @@ -11,7 +11,7 @@ SUBDIRS = engine grammar makedict RUBY_FILES = prime.rb prime2.rb prime-japanese.rb prime-mixed.rb \ protocol.rb server.rb session.rb \ - taiyaki.rb array-agent.rb \ + taiyaki.rb array-agent.rb engines.rb \ session-japanese.rb session-english.rb \ session-prime08.rb prime08.rb composer.rb Index: prime/lib/engines.rb diff -u /dev/null prime/lib/engines.rb:1.1 --- /dev/null Mon Mar 7 19:01:57 2005 +++ prime/lib/engines.rb Mon Mar 7 19:01:57 2005 @@ -0,0 +1,44 @@ +# engines.rb: +# $Id: engines.rb,v 1.1 2005/03/07 10:01:57 komatsu Exp $ +# +# Copyright (C) 2005 Hiroyuki Komatsu <komat****@taiya*****> +# All rights reserved. +# This is free software with ABSOLUTELY NO WARRANTY. +# +# You can redistribute it and/or modify it under the terms of +# the GNU General Public License version 2. + +require 'prime/engine/engine-basic' +require 'prime/engine/engine-userdict2' +require 'prime/engine/engine-personaldict' +require 'prime/engine/engine-alphabet' +require 'prime/engine/engine-number' + +require 'prime/engine/engine-english' +require 'prime/engine/engine-userdict2-en' + +require 'prime/engine/engine-network' +require 'prime/engine/engine-userdict2-static' + +## This class is like a factory pattern. +class PrimeEngines + @@engine_cache = {} + + def PrimeEngines::initialize_engines (engine_classes) + engines = engine_classes.map { | engine_class | + if @@engine_cache.has_key?( engine_class ) then + @@engine_cache[ engine_class ] + else + @@engine_cache[ engine_class ] = eval( engine_class.to_s ).new() + end + } + + def engines.command (method, *args) + self.map {|engine| + engine.send(method, *args) + } + end + + return engines + end +end