1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #include "Aliasing.h"
23 
24 namespace U2 {
25 namespace Workflow {
26 
SlotAlias(const Port * port,const QString & slotId,const QString & alias)27 SlotAlias::SlotAlias(const Port *port, const QString &slotId, const QString &alias)
28     : port(port), slotId(slotId), alias(alias) {
29 }
30 
getSourcePort() const31 const Port *SlotAlias::getSourcePort() const {
32     return port;
33 }
34 
getSourceSlotId() const35 QString SlotAlias::getSourceSlotId() const {
36     return slotId;
37 }
38 
getAlias() const39 QString SlotAlias::getAlias() const {
40     return alias;
41 }
42 
PortAlias(const Port * sourcePort,const QString & alias,const QString & description)43 PortAlias::PortAlias(const Port *sourcePort, const QString &alias, const QString &description)
44     : port(sourcePort), alias(alias), description(description) {
45 }
46 
operator ==(const PortAlias & another)47 bool PortAlias::operator==(const PortAlias &another) {
48     return (alias == another.getAlias());
49 }
50 
addSlot(const SlotAlias & newSlot)51 bool PortAlias::addSlot(const SlotAlias &newSlot) {
52     foreach (const SlotAlias &slot, slotAliases) {
53         if (slot.getSourcePort() == newSlot.getSourcePort()) {
54             if (slot.getAlias() == newSlot.getAlias() ||
55                 slot.getSourceSlotId() == newSlot.getSourceSlotId()) {
56                 return false;
57             }
58         }
59     }
60 
61     slotAliases.append(newSlot);
62     return true;
63 }
64 
addSlot(const Port * sourcePort,const QString & slotId,const QString & alias)65 bool PortAlias::addSlot(const Port *sourcePort, const QString &slotId, const QString &alias) {
66     SlotAlias newSlot(sourcePort, slotId, alias);
67 
68     return this->addSlot(newSlot);
69 }
70 
getSourcePort() const71 const Port *PortAlias::getSourcePort() const {
72     return port;
73 }
74 
getAlias() const75 QString PortAlias::getAlias() const {
76     return alias;
77 }
78 
getDescription() const79 QString PortAlias::getDescription() const {
80     return description;
81 }
82 
getSlotAliases() const83 const QList<SlotAlias> &PortAlias::getSlotAliases() const {
84     return slotAliases;
85 }
86 
setNewSlotAliases(const QList<SlotAlias> & newSlotAliases)87 void PortAlias::setNewSlotAliases(const QList<SlotAlias> &newSlotAliases) {
88     slotAliases = newSlotAliases;
89 }
90 
setNewSourcePort(const Port * sourcePort)91 void PortAlias::setNewSourcePort(const Port *sourcePort) {
92     port = sourcePort;
93 }
94 
isInput() const95 bool PortAlias::isInput() const {
96     return port->isInput();
97 }
98 
99 }  // namespace Workflow
100 }  // namespace U2
101