arcsconnection.h
1 /*
2  name: include/arcs/arcsconnection.h
3 
4  This file is part of ARCS - Augmented Reality Component System
5  (version 2-current), written by Jean-Yves Didier
6  for IBISC Laboratory (http://www.ibisc.univ-evry.fr)
7 
8  Copyright (C) 2013 Université d'Evry-Val d'Essonne
9 
10  This program is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 2 of the License, or
13  (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with this program. If not, see <http://www.gnu.org/licenses/>.
22 
23 
24  Please send bugreports with examples or suggestions to
25  jean-yves.didier__at__ibisc.univ-evry.fr
26 */
27 
28 
29 #ifndef __ARCSCONNECTION_H__
30 #define __ARCSCONNECTION_H__
31 
32 #include <arcs/arcsabstractcomponent.h>
33 #include <iostream>
34 #include <QPointF>
35 #include <QList>
36 #include <arcs/arcsdll.h>
37 
39 
46 class DLL_POINT ARCSConnection
47 {
48 public:
52  ARCSConnection(const ARCSConnection & a);
54 
60  ARCSConnection(ARCSAbstractComponent* s, QString sgn, ARCSAbstractComponent * d, QString slt, bool q = false);
61 
63  void setSource(ARCSAbstractComponent* a) { source = a ; }
65  void setDestination(ARCSAbstractComponent* a) { destination = a; }
67  void setSlotName(QString s) { slotName = s; }
69  void setSignalName(QString s) { signalName = s; }
71 
76  void setQueued(bool b) { queued = b; }
77 
78  QList<QPointF>& getCoordinates() { return coordinates; }
79  void setCoordinates(QList<QPointF> coords) { coordinates.clear(); coordinates += coords; }
80 
82  ARCSAbstractComponent* getSource() { return source; }
84  ARCSAbstractComponent* getDestination() { return destination; }
85 
86  QString getSourceName() { return source->getProperty("id").toString(); }
87  QString getDestinationName() { return destination->getProperty("id").toString(); }
88 
90  QString getSlotName() { return slotName; }
92  QString getSignalName() { return signalName; }
94  bool isQueued() { return queued; }
95 
97 
99  bool connect() ;
101 
103  bool disconnect();
104 
107  {
108  return ((source == c.source) && (destination == c.destination) &&
109  (slotName == c.slotName) && (signalName == c.signalName) );
110  }
111 
112  bool isComplete() { return source && destination && !slotName.isEmpty() && !signalName.isEmpty(); }
113 
114  static ARCSConnection null;
115 
116 private:
117  ARCSAbstractComponent* source;
118  ARCSAbstractComponent* destination;
119  QString slotName;
120  QString signalName;
121  QList<QPointF> coordinates;
122  bool queued;
123 
124 };
125 
126 #endif //__ARCSCONNECTION_H__
QString getSlotName()
void setSource(ARCSAbstractComponent *a)
ARCSAbstractComponent * getSource()
Describes a connection.
QVariant getProperty(QString name)
Gets a meta-property from this component.
ARCSAbstractComponent * getDestination()
Class handling the generic description of a component.
QString getSignalName()
bool operator==(ARCSConnection c)
void setSignalName(QString s)
void setQueued(bool b)
Tells wether the connection will be queued or not.
void setDestination(ARCSAbstractComponent *a)
void setSlotName(QString s)