Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

UITerminal.h

00001 // Copyright (C) 2001 Jean-Marc Valin
00002 
00003 #ifndef UITERMINAL_H
00004 #define UITERMINAL_H
00005 
00006 
00007 
00008 #include <vector>
00009 #include <string>
00010 #include <fstream>
00011 #include <pthread.h>
00012 
00013 namespace FD {
00014 
00015 class UINode;
00016 class UILink;
00017 class UINetTerminal;
00018 class ItemInfo;
00019 
00020 class UITerminal {
00021 protected:
00022 
00024    std::string name;
00025    
00027    std::string type;
00028   
00030    std::string description;
00031 
00033    UINode *node;
00034 
00036    double x,y;
00037 
00039    bool isInput;
00040 
00042    std::vector <UILink *> connections;
00043 
00045    UINetTerminal *netTerminal;
00046 
00047 public:
00048    UITerminal (ItemInfo *terminalInfo, UINode *_node, bool _isInput, double _x, double _y);
00049 
00050    virtual ~UITerminal();
00051 
00052 
00053    UINode *getNode() const {return node;}
00054 
00055 
00057    virtual void getPos(double &wx, double &wy) const
00058    {
00059       wx=x;
00060       wy=y;
00061       //gnome_canvas_item_i2w(item->parent, &wx, &wy);
00062    }
00063 
00065    void getItemPos(double &wx, double &wy) const 
00066    {
00067       wx=x;
00068       wy=y;
00069    }
00070 
00072    void connect(UILink *link) {connections.insert(connections.end(), link);}
00073    
00075    void disconnect(UILink *link) 
00076    {
00077       //Now, this should comply to ANSI C++
00078       std::vector<UILink *>::iterator i=connections.begin();
00079       while (i != connections.end())
00080       {
00081          if (*i == link)
00082          {
00083             connections.erase(i);
00084             break;
00085          }
00086          ++i;
00087       }
00088       /*for (int i=0;i<connections.size();i++)
00089          if (connections[i]==link)
00090             connections.erase(&connections[i]);
00091       */
00092    }
00093 
00095    void connectNetTerminal(UINetTerminal *term);
00096 
00098    void disconnectNetTerminal();
00099 
00100    const std::string &getName() const {return name;}
00101    const std::string &getType() const {return type;}
00102    const std::string &getDescription() const {return description;}
00103    bool isInputTerminal() const {return isInput;}
00104    
00105    bool isConnected() const {return connections.size()!=0 || netTerminal;}
00106    
00107    std::vector<UILink *> getConnections() const {return connections;}
00108 
00109    UINetTerminal* getNetTerminal() {return netTerminal;}
00110 
00111 };
00112 
00113 }//namespace FD
00114 
00115 #endif

Generated on Wed Oct 5 14:28:56 2005 for FlowDesigner by  doxygen 1.4.4