29 #include <arcs/arcssheet.h>
30 #include <arcs/arcsinternaltypes.h>
32 #include <QMutableListIterator>
33 #include <QListIterator>
52 context = sheet.context;
54 connections = sheet.connections;
55 preconnects = sheet.preconnects;
56 postconnects = sheet.postconnects;
57 cleanups = sheet.cleanups;
58 properties = sheet.properties;
64 void ARCSSheet::reset()
76 QSet<QString> componentSet ;
78 QListIterator<ARCSConnection> i(connections);
82 componentSet.insert(c.getSourceName());
83 componentSet.insert(c.getDestinationName());
86 listComponentInit(preconnects,componentSet);
87 listComponentInit(postconnects,componentSet);
88 listComponentInit(cleanups,componentSet);
89 return componentSet.toList();
92 void ARCSSheet::removeInitWithComponent(QList<ARCSInit>& lst,QString name)
94 QMutableListIterator<ARCSInit> i(lst);
98 if (i.value().getDestinationName() == name)
105 void ARCSSheet::removeComponent(QString name)
107 QMutableListIterator<ARCSConnection> i(connections);
112 if (connect.getSourceName() == name)
118 if (connect.getDestinationName() == name)
122 removeInitWithComponent(preconnects,name);
123 removeInitWithComponent(postconnects,name);
124 removeInitWithComponent(cleanups,name);
127 void ARCSSheet::listComponentInit(QList<ARCSInit> &lst, QSet<QString> &set)
129 QListIterator<ARCSInit> i(lst);
133 set.insert(init.getDestinationName());
138 void ARCSSheet::batchInit(QList<ARCSInit> & lst)
140 QListIterator<ARCSInit> i(lst);
163 QListIterator<ARCSConnection> i(connections);
174 QListIterator<ARCSConnection> i(connections);
191 std::cerr <<
"Cannot find component named" << qPrintable(src) << std::endl;
198 connections.prepend(c);
199 return connections.first();
202 connections.append(c);
203 return connections.last();
213 int idx= connections.indexOf(c);
216 return connections[idx];
223 int ARCSSheet::getConnectionIndex(QString src, QString sgn, QString dst, QString slt)
228 return connections.indexOf(c);
231 void ARCSSheet::swapConnections(
int x,
int y)
233 if (x < connections.count() && y < connections.count() && x >= 0 && y >=0 )
234 connections.swap(x,y);
238 ARCSInit& ARCSSheet::createInit(QList<ARCSInit> & lst, QString dst, QString slt, QString t, QString val)
241 QVariant value = context->createValue(t,val);
242 ARCSInit i(destination, slt, value);
249 QStringList& destinations, QStringList& slts)
253 destinations.clear();
256 QListIterator<ARCSConnection> i(connections);
261 sources << c.getSourceName();
263 destinations << c.getDestinationName();
269 void ARCSSheet::getInits(QList<ARCSInit> &lst, QStringList & destinations,
270 QStringList & slts, QStringList & types, QStringList& values)
272 destinations.clear();
277 QListIterator<ARCSInit> i(lst);
282 destinations << init.getDestinationName();
290 ARCSInit& ARCSSheet::getInit(QList<ARCSInit> &lst, QString dst, QString slt, QString t, QString val)
294 QVariant value = context->createValue(t,val);
295 ARCSInit i(destination, slt, value);
297 int idx= lst.indexOf(i);
302 return ARCSInit::null;
307 void ARCSSheet::swapInits(QList<ARCSInit> &lst,
int x,
int y)
309 if (x < lst.count() && y < lst.count() && x >=0 && y >=0)
ARCSSheet(ARCSContext *ctx=0, QString n=QString::null)
Constructor.
bool disconnect()
Disconnects the connection.
Desribes an initialization over a component.
Class handling the generic description of a component.
QStringList getComponentList()
Retrieves the list of components that are used in this sheet.
bool connect()
Make the connection happen.
ARCSAbstractComponent * getComponent(QString name)
Retrieves a component by its id.
void getConnections(QStringList &sources, QStringList &signls, QStringList &destinations, QStringList &slts)
Allows to retrieve connections.
QVariant getConstant(QString name)
Retrieves a constant by its id.
This class manages components and constants in a given context.
ARCSConnection & addConnection(QString src, QString sgn, QString dst, QString slt, bool q=false, bool head=false)
Adds a connection to the sheet structure.
ARCSConnection & getConnection(QString source, QString sgn, QString dst, QString slt)
returns a reference to a connection in the sheet structure
Maintains connections between objects.