bob.h

00001 /***************************************************************************
00002  *   Copyright (C) 2004 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 General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef BOB_H
00021 #define BOB_H
00022 
00023 #define __GEDDEI_BUILD
00024 
00025 #include "properties.h"
00026 #include "processor.h"
00027 using namespace Geddei;
00028 
00029 #include <qptrlist.h>
00030 #include <qstring.h>
00031 #include <qrect.h>
00032 #include <qcanvas.h>
00033 
00034 #include "refresher.h"
00035 
00036 class QDomDocument;
00037 class QDomElement;
00038 class QPainter;
00039 class QPoint;
00040 class QTimer;
00041 
00042 class BobPort;
00043 class GeddeiNite;
00044 
00048 class Bob: public QObject, public QCanvasRectangle, public Refresher
00049 {
00050 Q_OBJECT
00051  friend class GeddeiNite;
00052 
00053  QPtrList<BobPort> theInputs, theOutputs;
00054  QTimer *theProfileTimer, *theRedrawTimer;
00055 
00056  virtual void drawShape(QPainter &p);
00057 
00058 private slots:
00059  virtual void slotRedraw();
00060 
00061 protected:
00062  QString theName;
00063  Processor *theProcessor;
00064  QCanvas *theCanvas;
00065 
00066 public:
00067  static int RTTI;
00068  virtual int rtti() const { return 1000; }
00069 
00070  void setPos(QPoint p);
00071 
00072  QRect rope();
00073  const QString name();
00074  GeddeiNite *geddeiNite();
00075  Processor *processor() { return theProcessor; }
00076  BobPort *inputPort(int index) { return theInputs.at(index); }
00077 
00078  bool connectYourself();
00079  void disconnectYourself();
00080  const bool connected() const { return theProfileTimer != 0; }
00081  virtual void saveYourself(QDomElement &element, QDomDocument &doc);
00082  virtual void loadYourselfPre(QDomElement &element);
00083  virtual void loadYourselfPost(QDomElement &element);
00084 
00085  void updatePorts();
00086  void redoPorts();
00087  bool portCollision(BobPort *p);
00088 
00089  void refresh() { updatePorts(); }
00090 
00091  void init(const int x, const int y);
00092 
00093  Bob(const QString &name, QCanvas *c);
00094  virtual ~Bob();
00095 };
00096 
00097 #endif

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