00001 /*************************************************************************** 00002 * Copyright (C) 2003 by Gav Wood * 00003 * gav@cs.york.ac.uk * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU Library General Public License as * 00007 * published by the Free Software Foundation; either version 2 of the * 00008 * License, or (at your option) any later version. * 00009 ***************************************************************************/ 00010 00011 #ifndef _GEDDEI_MULTIPROCESSORCREATOR_H 00012 #define _GEDDEI_MULTIPROCESSORCREATOR_H 00013 00014 #ifdef __GEDDEI_BUILD 00015 #include "processor.h" 00016 #else 00017 #include <geddei/processor.h> 00018 #endif 00019 using namespace Geddei; 00020 00021 namespace Geddei 00022 { 00023 00040 class MultiProcessorCreator 00041 { 00042 friend class MultiProcessor; 00043 virtual Processor *newProcessor() const = 0; 00044 protected: 00045 virtual ~MultiProcessorCreator() {} 00046 }; 00047 00055 template<class X> 00056 class BasicCreator: public MultiProcessorCreator 00057 { 00058 virtual Processor *newProcessor() const { return dynamic_cast<Processor *>(new X); } 00059 }; 00060 00068 template<class X> 00069 class BasicSubCreator: public MultiProcessorCreator 00070 { 00071 virtual Processor *newProcessor() const { return dynamic_cast<Processor *>(new DomProcessor(new X)); } 00072 }; 00073 00082 class FactoryCreator: public MultiProcessorCreator 00083 { 00084 QString theType; 00085 virtual Processor *newProcessor() const; 00086 00087 public: 00096 FactoryCreator(const QString &type) : theType(type) {} 00097 }; 00098 00108 class SubFactoryCreator: public MultiProcessorCreator 00109 { 00110 QString theType; 00111 virtual Processor *newProcessor() const; 00112 00113 public: 00124 SubFactoryCreator(const QString &type) : theType(type) {} 00125 }; 00126 00127 }; 00128 00129 #endif