multiprocessor.h

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_MULTIPROCESSOR_H
00012 #define _GEDDEI_MULTIPROCESSOR_H
00013 
00014 #include <qstring.h>
00015 #include <qvaluevector.h>
00016 
00017 #ifdef __GEDDEI_BUILD
00018 #include "multisource.h"
00019 #include "multisink.h"
00020 #include "properties.h"
00021 #else
00022 #include <geddei/multisource.h>
00023 #include <geddei/multisink.h>
00024 #include <geddei/properties.h>
00025 #endif
00026 using namespace Geddei;
00027 
00028 namespace Geddei
00029 {
00030 
00031 class Processor;
00032 class ProcessorGroup;
00033 class MultiProcessorCreator;
00034 
00071 class MultiProcessor: public MultiSource, public MultiSink
00072 {
00073  friend class Processor;
00074  friend class ProcessorPort;
00075 
00076  MultiProcessorCreator *theCreator;
00077  Processor *theSource;
00078 
00079  bool theIsInitialised;
00080  QValueVector<Processor *> theProcessors;
00081 
00085  const bool knowMultiplicity() const { return theIsInitialised; }
00086 
00093  const uint multiplicity() const { return theProcessors.count(); }
00094 
00098  const bool initGiven() const { return theIsInitialised || theDeferredInit; }
00099 
00100  //* Reimplementation from Multiplicative
00101  virtual void doInit(const QString &name, ProcessorGroup *g, const Properties &properties);
00102 
00103  //* Reimplementation from MultiSource
00104  virtual ProcessorPort sourcePort(const uint i) { return (*theProcessors[i])[0]; }
00105 
00106  //* Reimplementation from MultiSink
00107  virtual ProcessorPort sinkPort(const uint i) { return (*theProcessors[i])[0]; }
00108 
00109 public:
00123  void init(const QString &name, ProcessorGroup &group, const Properties &properties = Properties()) { doInit(name, &group, properties); }
00124 
00140  void init(const QString &name = "", const Properties &properties = Properties()) { doInit(name, 0, properties); }
00141 
00151  MultiProcessor(MultiProcessorCreator *c): theCreator(c), theSource(0), theIsInitialised(false) {}
00152 
00156  ~MultiProcessor();
00157 };
00158 
00159 };
00160 
00161 #endif

Generated on Thu Jul 13 06:56:33 2006 for Exscalibar by  doxygen 1.4.7