/tags/rel-0-5-0/FreeSpeech/data-flow/include/UITerminal.h

# · C++ Header · 113 lines · 61 code · 30 blank · 22 comment · 5 complexity · b7aa694331e63f6a3bd220f699c8f426 MD5 · raw file

  1. // Copyright (C) 2001 Jean-Marc Valin
  2. #ifndef UITERMINAL_H
  3. #define UITERMINAL_H
  4. using namespace std;
  5. //#include <gnome.h>
  6. #include <vector>
  7. #include <string>
  8. #include <fstream>
  9. #include <pthread.h>
  10. class UINode;
  11. class UILink;
  12. class UINetTerminal;
  13. class ItemInfo;
  14. class UITerminal {
  15. protected:
  16. /**The terminal name*/
  17. string name;
  18. /**The terminal type*/
  19. string type;
  20. /**The description of the terminal */
  21. string description;
  22. /**The node that owns this terminal*/
  23. UINode *node;
  24. /**position relative to node group*/
  25. double x,y;
  26. /**Whether it's an input of the node (otherwise, output)*/
  27. bool isInput;
  28. /**All connected links (only one allowed for inputs)*/
  29. vector <UILink *> connections;
  30. /**The net input/output connected to the terminal (NULL if none)*/
  31. UINetTerminal *netTerminal;
  32. public:
  33. UITerminal (ItemInfo *terminalInfo, UINode *_node, bool _isInput,
  34. double _x, double _y);
  35. virtual ~UITerminal();
  36. UINode *getNode() {return node;}
  37. /**returns the position in world coord*/
  38. virtual void getPos(double &wx, double &wy)
  39. {
  40. wx=x;
  41. wy=y;
  42. //gnome_canvas_item_i2w(item->parent, &wx, &wy);
  43. }
  44. /**returns the position in item coord*/
  45. void getItemPos(double &wx, double &wy)
  46. {
  47. wx=x;
  48. wy=y;
  49. }
  50. /**connect to a link*/
  51. void connect(UILink *link) {connections.insert(connections.end(), link);}
  52. /**disconnect from a link*/
  53. void disconnect(UILink *link)
  54. {
  55. //Now, this should comply to ANSI C++
  56. vector<UILink *>::iterator i=connections.begin();
  57. while (i != connections.end())
  58. {
  59. if (*i == link)
  60. {
  61. connections.erase(i);
  62. break;
  63. }
  64. ++i;
  65. }
  66. /*for (int i=0;i<connections.size();i++)
  67. if (connections[i]==link)
  68. connections.erase(&connections[i]);
  69. */
  70. }
  71. /**connect to a network terminal*/
  72. void connectNetTerminal(UINetTerminal *term);
  73. /**connect to a network terminal*/
  74. void disconnectNetTerminal();
  75. const string &getName() {return name;}
  76. const string &getType() {return type;}
  77. const string &getDescription() {return description;}
  78. bool isInputTerminal() {return isInput;}
  79. bool isConnected() {return connections.size()!=0 || netTerminal;}
  80. void export2net (ostream &out);
  81. vector<UILink *> getConnections() {return connections;}
  82. };
  83. #endif