discretelogic.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by David Saxton                                    *
00003  *   david@bluehaze.org                                                    *
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 
00011 #ifndef DISCRETELOGIC_H
00012 #define DISCRETELOGIC_H
00013 
00014 #include "component.h"
00015 #include "logic.h"
00016 
00017 class Simulator;
00018 
00019 /*
00020 NOTE: There is probably a better way to do this. I would suggest creating a single
00021 generic discrete logic class with a database containing the shape, rules for input/output pins, (eg how many there can be, whether the number is variable.), and the boolean expression the gate implements. It may also be useful to allow the user to invert selected inputs to the gate. (denoted by a small circle)
00022 */
00023 
00028 class Inverter : public CallbackClass, public Component
00029 {
00030         public:
00031                 Inverter( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00032                 ~Inverter();
00033         
00034                 static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00035                 static LibraryItem *libraryItem();
00036         
00037         protected:
00038                 void inStateChanged( bool newState );
00039                 virtual void drawShape( QPainter &p );
00040                 
00041                 LogicIn * m_pIn;
00042                 LogicOut * m_pOut;
00043 };
00044 
00049 class Buffer : public CallbackClass, public Component
00050 {
00051 public:
00052         Buffer( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00053         ~Buffer();
00054 
00055         static Item* construct(ItemDocument *itemDocument, bool newItem, const char *id);
00056         static LibraryItem *libraryItem();
00057 
00058 private:
00059         void inStateChanged( bool newState );
00060         virtual void drawShape( QPainter &p );
00061         
00062         LogicIn * m_pIn;
00063         LogicOut * m_pOut;
00064 };
00065 
00070 class ECLogicInput : public Component
00071 {
00072 public:
00073         ECLogicInput( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00074         ~ECLogicInput();
00075 
00076         static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00077         static LibraryItem *libraryItem();
00078         virtual void buttonStateChanged( const QString &id, bool state );
00079 
00080 private:
00081         virtual void dataChanged();
00082         virtual void drawShape( QPainter &p );
00083         LogicOut * m_pOut;
00084         bool b_state;
00085 };
00086 
00091 class ECLogicOutput : public CallbackClass, public Component
00092 {
00093         public:
00094                 ECLogicOutput( ICNDocument *icnDocument, bool newItem, const char *id = 0 );
00095                 ~ECLogicOutput();
00096 
00097                 static Item* construct( ItemDocument *itemDocument, bool newItem, const char *id );
00098                 static LibraryItem *libraryItem();
00099 
00100         protected:
00101                 void inStateChanged( bool newState );
00102                 virtual void drawShape( QPainter &p );
00103 
00104                 unsigned long long m_lastDrawTime;
00105                 unsigned long long m_lastSwitchTime;
00106                 unsigned long long m_highTime;
00107                 bool m_bLastState;
00108 
00109                 double m_lastDrawState;
00110                 LogicIn * m_pIn;
00111                 Simulator * m_pSimulator;
00112 };
00113 
00114 #endif

Generated on Tue May 8 17:05:29 2007 for KTechLab by  doxygen 1.5.1