29 #include <arcs/arcsxmlhandler.h>
31 #include <arcs/arcsstatemachine.h>
32 #include <arcs/arcsapplicationcomponent.h>
33 #include <arcs/arcscompositecomponent.h>
34 #include <arcs/arcs.h>
35 #include <arcs/arcslog.h>
41 #include <QTextStream>
51 ARCSXMLHandler::~ARCSXMLHandler()
58 QFileInfo fi(fileName);
59 this->fileName = fi.canonicalFilePath();
63 ARCSLog::logCritical(logSource(),
"file " + this->fileName +
" does not exist.");
68 QFile file(this->fileName);
70 if (!file.open(QIODevice::ReadOnly))
72 ARCSLog::logCritical(logSource(),
"cannot open file " +
79 bool ok = doc.setContent(&file, &error, &line, &col);
83 ARCSLog::logCritical(logSource(line),
84 QString(
"malformed xml: (line: ")+ line +
85 ", col:" + col +
") "+ error);
100 bool ok = doc.setContent(contents, &error, &line, &col);
105 ARCSLog::logCritical(logSource(line), QString(
"malformed xml: (line: ")+ line +
", col:" + col +
") "+ error);
114 QString ARCSXMLHandler::getContents()
116 return doc.toString();
123 this->fileName = QDir::cleanPath(fi.absoluteFilePath());
124 QFile file(this->fileName);
126 if (!file.open(QIODevice::WriteOnly))
128 std::cerr <<
"[SaveFile] Cannot open file " << qPrintable(this->fileName) << std::endl;
132 computeRelativePaths(this->fileName);
134 QTextStream ts(&file);
138 if (ts.status() != QTextStream::Ok)
152 QDomNodeList contexts = doc.elementsByTagName(QString(
"context"));
154 if (contexts.isEmpty())
156 ARCSLog::logWarning(logSource(),
"\"context\" tag undefined.");
160 if (!contexts.at(0).hasChildNodes())
162 ARCSLog::logWarning(logSource(contexts.at(0).lineNumber()),
"\"context\" tag is empty.");
166 QDomNodeList contextChildren = contexts.at(0).childNodes();
168 for (i=0; i < contextChildren.count() ; i++)
170 QDomNode e = contextChildren.at(i);
173 QDomElement elt = e.toElement();
174 if (elt.tagName() ==
"libraries" )
177 parseLibraries(elt,&ok);
182 if (elt.tagName() ==
"components" )
183 parseComponents(elt,ctx);
184 if (elt.tagName() ==
"constants" )
185 parseConstants(elt,ctx);
196 if (father.hasAttribute(
"id"))
197 sheet->
setName(father.attribute(
"id"));
200 QDomNodeList children = father.childNodes();
202 for(i = 0; i< children.count(); i++)
204 QDomElement element = children.at(i).toElement();
205 if (element.tagName() ==
"connections")
207 QDomNodeList eltChildren = element.childNodes();
208 for (j=0; j < eltChildren.count(); j++)
210 QDomElement elt = eltChildren.at(j).toElement();
211 if (elt.tagName() ==
"link" )
213 if (elt.hasAttribute(
"source") &&
214 elt.hasAttribute(
"destination") &&
215 elt.hasAttribute(
"signal") &&
216 elt.hasAttribute(
"slot") )
219 if (elt.hasAttribute(
"queued"))
221 QString sQueued = elt.attribute(
"queued").toLower();
222 if (sQueued ==
"t" || sQueued ==
"1" || sQueued ==
"true")
227 elt.attribute(
"destination"), elt.attribute(
"slot"),b);
228 if (!connect.isComplete())
229 ARCSLog::logError(logSource(elt.lineNumber()),
"could not create complete link." );
232 if (elt.hasAttribute(
"coords"))
234 QList<QPointF> coords;
235 QStringList coordStrings = elt.attribute(
"coords").split(
' ');
236 for (k=0; k < coordStrings.count(); k++)
238 coords.append(QPointF(coordStrings[k].section(
',',0,0).toFloat(),
239 coordStrings[k].section(
',',1,1).toFloat()));
241 connect.setCoordinates(coords);
247 ARCSLog::logWarning(logSource(elt.lineNumber()),
"\"link\" tag is missing either \"source\", \"destination\", \"signal\" or \"slot\" attributes.");
251 if (element.tagName() ==
"preconnections")
254 if (element.tagName() ==
"postconnections")
257 if (element.tagName() ==
"cleanups")
260 if (element.tagName() ==
"properties")
261 parseSheetProperties(element,sheet);
269 void ARCSXMLHandler::parseSheetProperties(QDomElement elt,
ARCSSheet *sheet)
272 QDomNodeList eltChildren = elt.childNodes();
273 for (j=0; j< eltChildren.count(); j++)
275 QDomElement element = eltChildren.at(j).toElement();
276 if (element.tagName() ==
"property")
278 if (element.hasAttribute(
"id"))
279 sheet->
setProperty(element.attribute(
"id"),nodeInternalsToText(element));
281 ARCSLog::logError(logSource(element.lineNumber()),
" \"property\" tag is missing \"id\" attribute.");
289 void ARCSXMLHandler::parseInvocation(QDomElement element,
ARCSSheet* sheet, ARCSSheet::AddInvocationMethod method)
292 QDomNodeList eltChildren = element.childNodes();
293 for (j=0; j< eltChildren.count(); j++)
295 QDomElement elt = eltChildren.at(j).toElement();
296 if (elt.tagName() ==
"invoke")
298 if (elt.hasAttribute(
"destination") &&
299 elt.hasAttribute(
"slot") &&
300 elt.hasAttribute(
"type") )
302 if (!(sheet->*method)(elt.attribute(
"destination"), elt.attribute(
"slot"),
303 elt.attribute(
"type"), nodeInternalsToText(elt)).isComplete())
305 ARCSLog::logError(logSource(elt.lineNumber()),
"could not create invocation.");
309 ARCSLog::logError(logSource(elt.lineNumber()),
"\"invoke\" tag is missing either \"destination\", \"slot\" or \"type\" attribute." );
314 QStringList ARCSXMLHandler::parseLibraries(QDomElement libraries,
bool* ok)
318 QDomNodeList librariesList = libraries.childNodes();
321 for(
int i = 0 ; i < librariesList.count(); i++)
323 if (librariesList.at(i).isElement())
325 QDomElement element = librariesList.at(i).toElement();
326 if( element.tagName() ==
"library")
328 if(element.hasAttribute(
"path"))
330 QString path = element.attribute(
"path");
331 QString finalPath = solveRelativePath(path) ;
333 if (finalPath.isEmpty())
335 ARCSLog::logError(logSource(element.lineNumber()),
"library "+finalPath +
" not found.");
336 if (ok) *ok = *ok &&
false;
344 ARCSLog::logError(logSource(element.lineNumber()),
"failed to load library "+finalPath);
345 if (ok) *ok = *ok &&
false;
350 ARCSLog::logWarning(logSource(element.lineNumber()),
"\"library\" tag is missing \"path\" attribute.");
361 if (doc.documentElement().tagName() !=
"statemachine" )
363 ARCSLog::logCritical(logSource(doc.documentElement().lineNumber()),
"\"statemachine\" tag expected.");
367 QDomNodeList elements = doc.documentElement().childNodes();
368 bool noerror = true ;
369 bool hasTransitions =
false;
371 for ( i=0; i < elements.count() ; i++)
373 if (elements.at(i).isElement())
375 QDomElement element = elements.at(i).toElement();
376 if (element.tagName() ==
"transitions")
378 hasTransitions =
true;
379 QDomNodeList transitions = element.childNodes();
380 for ( j = 0; j < transitions.count(); j++)
382 if (transitions.at(j).isElement())
384 QDomElement transition = transitions.at(j).toElement();
385 if (transition.tagName() ==
"transition")
387 if ( transition.hasAttribute(
"source") &&
388 transition.hasAttribute(
"token" ) &&
389 transition.hasAttribute(
"destination") )
391 noerror = noerror &&
true;
392 sm->addTransition(transition.attribute(
"source"),
393 transition.attribute(
"token"),
394 transition.attribute(
"destination"));
398 noerror = noerror &&
false;
399 ARCSLog::logWarning(logSource(transition.lineNumber()),
"\"transition\" tag is missing either \"source\", \"token\", or \"destination\" attribute.");
406 if (element.tagName() ==
"first")
408 if (element.hasAttribute(
"name"))
411 ARCSLog::logWarning(logSource(element.lineNumber()),
"\"first\" tag is missing \"name\" attribute.");
414 if (element.tagName() ==
"last" )
416 if (element.hasAttribute(
"name"))
419 ARCSLog::logWarning(logSource(element.lineNumber()),
"\"last\" tag is missing \"name\" attribute.");
425 ARCSLog::logWarning(logSource(doc.documentElement().lineNumber()),
"statemachine without any transition.");
428 return ( noerror && hasTransitions ) ;
435 if (processNode.tagName() !=
"process")
437 ARCSLog::logError(logSource(processNode.lineNumber()),
"\"process\" tag expected.");
441 if (processNode.hasAttribute(
"controller"))
444 ARCSLog::logError(logSource(processNode.lineNumber()),
"undefined controller: "+ processNode.attribute(
"controller"));
448 QDomNodeList lst = processNode.elementsByTagName(
"sheet");
449 if (lst.count() <= 0)
451 ARCSLog::logError(logSource(processNode.lineNumber()),
"\"process\" tag does not contain any \"sheets\" tag.");
455 for (
int i=0; i< lst.count(); i++)
460 ARCSLog::logError(logSource(lst.at(i).lineNumber()),
"failed to parse sheet.");
471 bool ARCSXMLHandler::parseProfile(
ARCSContext* ctx)
473 QDomElement app = doc.documentElement();
475 if (app.tagName() !=
"profile")
477 ARCSLog::logError(logSource(doc.documentElement().lineNumber()),
"\"profile\" tag expected.");
489 QDomElement app = doc.documentElement();
491 if (app.tagName() !=
"application")
493 ARCSLog::logError(logSource(doc.documentElement().lineNumber()),
"\"application\" tag expected.");
499 QString mode = app.attribute(
"mode").toLower();
504 if (mode ==
"thread")
507 if (mode ==
"threadevent")
522 ARCSLog::logError(logSource(),
"could not parse context.");
526 QDomNodeList lst = doc.elementsByTagName(QString(
"process"));
527 if (lst.count() <= 0)
529 ARCSLog::logError(logSource(),
"undefined \"process\" tag for application.");
535 for (
int i=0; i < lst.count(); i++)
544 ARCSLog::logError(logSource(lst.at(i).lineNumber()),
"could not parse \"process\" tag.");
557 QDomElement cmp = doc.documentElement();
559 if (cmp.tagName() !=
"composite")
561 ARCSLog::logError(logSource(doc.documentElement().lineNumber()),
"\"composite\" tag expected.");
568 ARCSLog::logError(logSource(),
"could not parse context.");
572 QDomNodeList lst = doc.elementsByTagName(QString(
"sheet"));
574 if (lst.count() != 1)
576 ARCSLog::logError(logSource(lst.at(1).lineNumber()),
"wrong number of sheets in composite component.");
580 QDomElement sheetNode = lst.at(0).toElement();
586 QDomNodeList _lst2 = doc.elementsByTagName(QString(
"interface"));
587 if (_lst2.count() != 1)
589 ARCSLog::logWarning(logSource(_lst2.at(1).lineNumber()),
"wrong number of interfaces in composite component.");
593 QDomElement ifNode = _lst2.at(0).toElement();
597 ARCSLog::logError(logSource(ifNode.lineNumber()),
"could not parse \"interface\" tag.");
610 root = doc.documentElement();
612 if (node.isElement())
613 root = node.toElement();
615 if (root.tagName() !=
"interface")
617 ARCSLog::logError(logSource(root.lineNumber()),
"\"interface\" tag expected.");
621 QStringList signalAliases ;
622 QStringList slotAliases;
623 QStringList sourceComponents;
624 QStringList destinationComponents ;
625 QStringList signalMethods ;
626 QStringList slotMethods;
628 QDomNodeList dnl = root.childNodes();
629 for (i = 0; i < dnl.count(); i++)
631 QDomElement elt = dnl.at(i).toElement();
632 if (elt.tagName() ==
"signals")
633 parseMethodList(elt, signalAliases, sourceComponents, signalMethods);
635 if (elt.tagName() ==
"slots")
636 parseMethodList(elt, slotAliases, destinationComponents, slotMethods);
644 if (signalAliases.count() != sourceComponents.count() )
646 ARCSLog::logError(logSource(),
"signal count mismatch.");
650 if (slotAliases.count() != destinationComponents.count())
652 ARCSLog::logError(logSource(),
"slot count mismatch.");
656 for (j=0; j < signalAliases.count(); j++)
657 acc->
addProxySignal(signalAliases.at(j), sourceComponents.at(j), signalMethods.at(j));
659 for (j=0; j < slotAliases.count(); j++)
660 acc->
addProxySlot(slotAliases.at(j), destinationComponents.at(j), slotMethods.at(j));
671 void ARCSXMLHandler::parseMethodList(QDomElement elt, QStringList & aliases, QStringList & components, QStringList & methods)
673 QDomNodeList list = elt.childNodes();
679 for(
int i = 0; i< list.count(); i++)
681 if (list.at(i).isElement())
683 QDomElement element = list.at(i).toElement();
684 if (element.tagName() ==
"method")
686 if (element.hasAttribute(
"alias"))
688 aliases << element.attribute(
"alias");
689 if (element.hasAttribute(
"component") && element.hasAttribute(
"method"))
691 components << element.attribute(
"component");
692 methods << element.attribute(
"method");
695 ARCSLog::logWarning(logSource(element.lineNumber()),
"pure method detected.");
699 ARCSLog::logWarning(logSource(element.lineNumber()),
"\"method\" tag is missing \"alias\" attribute.");
706 void ARCSXMLHandler::parseContextElement(QDomElement elt,
ARCSContext* ctx, QString tagName, ARCSContext::AddPoolMethod method)
708 if (! elt.hasChildNodes())
711 ARCSLog::logWarning(logSource(elt.lineNumber()),
"empty \"constants\" part");
715 QDomNodeList list = elt.childNodes();
717 for (
int i=0; i < list.count(); i++)
719 if (list.at(i).isElement())
721 QDomElement e = list.at(i).toElement();
722 if (e.tagName() == tagName)
724 if (!e.hasAttribute(
"id") || !e.hasAttribute(
"type"))
726 ARCSLog::logWarning(logSource(e.lineNumber()),
"\"constant\" tag is missing either \"id\" or \"type\" attributes.");
731 QString
id = e.attribute(
"id");
732 QString type = e.attribute(
"type");
733 QString contents = nodeInternalsToText(e);
734 if (!(ctx->*method)(
id, type, contents))
735 ARCSLog::logWarning(logSource(e.lineNumber()),
"could not parse \"constant\" tag.");
741 bool ARCSXMLHandler::parseComponents(QDomElement elt,
ARCSContext* ctx)
743 if (! elt.hasChildNodes())
745 ARCSLog::logError(logSource(elt.lineNumber()),
"empty \"component\" list.");
749 QDomNodeList list = elt.childNodes();
751 for (
int i=0; i < list.count(); i++)
753 if (list.at(i).isElement())
755 QDomElement e = list.at(i).toElement();
756 if (e.tagName() ==
"component")
758 if (!e.hasAttribute(
"id") || !e.hasAttribute(
"type"))
761 ARCSLog::logWarning(logSource(e.lineNumber()),
762 "\"component\" tag is missing either \"id\" of \"type\" attributes.");
765 QString
id = e.attribute(
"id");
766 QString type = e.attribute(
"type");
767 QString filename = solveRelativePath(e.attribute(
"file"));
768 if (! filename.isEmpty())
773 ARCSLog::logError(logSource(e.lineNumber()),
774 "could not create component with id "+
id +
" and type "+type) ;
778 if (QFileInfo(filename).exists())
781 ARCSLog::logWarning(logSource(e.lineNumber()),
782 "failed to parse component.");
786 ARCSLog::logError(logSource(e.lineNumber()),
787 "component description "+ filename +
" not found.");
793 QString contents = nodeInternalsToText(e);
795 ARCSLog::logWarning(logSource(e.lineNumber()),
796 "could not parse component.");
804 void ARCSXMLHandler::computeRelativePaths(QString basePath)
806 QFileInfo fi1(basePath);
812 dir = fi1.absoluteDir();
815 for (
int i=0; i < fileAttributes.count(); i++)
817 fileAttributes[i].setValue(
818 dir.relativeFilePath(
819 QFileInfo(fileAttributes[i].value()).absoluteFilePath()
825 QString ARCSXMLHandler::solveRelativePath(QString path)
828 return QString::null;
830 if (fileName.isEmpty())
833 if (QFileInfo(path).isAbsolute())
836 QFileInfo fi1(fileName);
842 dir = fi1.absoluteDir();
844 return QDir::cleanPath(dir.absoluteFilePath(path));
852 bool bPres,bPosts, bCons, bCleanups;
853 bPres = bPosts = bCons = bCleanups =
false;
855 QDomElement sheetNode = doc.createElement(
"sheet");
856 QDomElement pres = doc.createElement(
"preconnections");
857 QDomElement posts = doc.createElement(
"postconnections");
858 QDomElement cons = doc.createElement(
"connections");
859 QDomElement cleanups = doc.createElement(
"cleanups");
862 sheetNode.setAttribute(
"id",
id);
866 QStringList destinations;
870 storeSheetProperties(sheet,sheetNode);
876 bCons = sources.count() > 0;
877 for (i=0; i < sources.count(); i++)
879 QDomElement link = doc.createElement(
"link");
880 link.setAttribute(
"source", sources[i]);
881 link.setAttribute(
"destination", destinations[i]);
882 link.setAttribute(
"signal", sgnls[i]);
883 link.setAttribute(
"slot", slts[i]);
885 sources[i],sgnls[i],destinations[i],slts[i]
887 QList<QPointF>& coords = connection.getCoordinates();
888 QStringList coordStrings;
889 if (coords.count() != 0)
891 for (j=0; j < coords.count(); j++)
892 coordStrings.append(QString::number(coords[j].x()) +
"," + QString::number(coords[j].y()));
893 link.setAttribute(
"coords",coordStrings.join(
" "));
895 cons.appendChild(link);
900 father.appendChild(sheetNode);
902 sheetNode.appendChild(pres);
904 sheetNode.appendChild(posts);
906 sheetNode.appendChild(cleanups);
908 sheetNode.appendChild(cons);
912 void ARCSXMLHandler::storeSheetProperties(
ARCSSheet *sheet, QDomElement root)
915 if (propertyKeys.count() <= 0)
918 QDomElement properties = doc.createElement(
"properties");
919 root.appendChild(properties);
920 for (
int i=0; i<propertyKeys.count(); i++)
922 QDomElement
property = doc.createElement(
"property");
923 property.setAttribute(
"id",propertyKeys[i]);
924 QDomText txt=doc.createTextNode(sheet->
getProperty(propertyKeys[i]));
925 properties.appendChild(property);
926 property.appendChild(txt);
931 bool ARCSXMLHandler::storeInvocations(
ARCSSheet* sheet,
932 ARCSSheet::GetInvocationsMethod method,
935 QStringList destinations;
941 (sheet->*method)(destinations, slts, types, values);
943 if (destinations.count() <= 0)
946 for (i=0; i < destinations.count(); i++)
948 QDomElement invoke = doc.createElement(
"invoke");
949 if (! values[i].isEmpty())
951 QDomText txt = doc.createTextNode(values[i]);
952 invoke.appendChild(txt);
954 invoke.setAttribute(
"destination", destinations[i]);
955 invoke.setAttribute(
"slot", slts[i]);
956 invoke.setAttribute(
"type", types[i]);
957 root.appendChild(invoke);
967 QDomElement smNode = doc.createElement(
"statemachine");
968 QDomElement trsNode = doc.createElement(
"transitions");
970 doc.appendChild(smNode);
971 smNode.appendChild(trsNode);
973 QDomElement fstNode = doc.createElement(
"first");
975 smNode.appendChild(fstNode);
980 QDomElement lstNode = doc.createElement(
"last");
982 smNode.appendChild(lstNode);
988 QStringList destinations;
989 sm->getTransitions(sources, tokens, destinations);
991 for (
int i=0; i < sources.count(); i++)
993 QDomElement trNode = doc.createElement(
"transition");
994 trNode.setAttribute(
"source",sources[i]);
995 trNode.setAttribute(
"token", tokens[i]);
996 trNode.setAttribute(
"destination", destinations[i]);
997 trsNode.appendChild(trNode);
1002 void ARCSXMLHandler::storeProfile(
ARCSContext* ctx)
1006 QDomElement app = doc.createElement(
"profile");
1007 doc.appendChild(app);
1011 for (
int i=0; i < lst.count(); i++)
1013 QDomElement cstNode = doc.createElement(
"constant");
1018 cstNode.setAttribute(
"id",lst[i]);
1019 cstNode.setAttribute(
"type",t);
1021 QDomText cstTxt = doc.createTextNode(r);
1022 cstNode.appendChild(cstTxt);
1023 app.appendChild(cstNode);
1029 void ARCSXMLHandler::storeContext(
ARCSContext* ctx)
1033 QDomElement ctxNode = doc.createElement(
"context");
1034 QDomElement libsNode = doc.createElement(
"libraries");
1035 QDomElement cmpsNode = doc.createElement(
"components");
1036 QDomElement cstsNode = doc.createElement(
"constants");
1041 for (i=0; i < lst.count(); i++)
1043 QDomElement cmpNode = doc.createElement(
"component");
1045 cmpNode.setAttribute(
"id",lst[i]);
1046 cmpNode.setAttribute(
"type",aac->
getType());
1048 QString filename = aac->
getProperty(
"filename").toString();
1049 if (filename.isEmpty() || QFileInfo(filename).isRelative())
1052 QDomDocument cmpTMP;
1053 if (cmpTMP.setContent(aac->
toString()))
1054 cmpNode.appendChild(cmpTMP);
1056 cmpNode.appendChild(doc.createTextNode(aac->
toString()));
1061 QDomAttr fAttr = doc.createAttribute(
"file");
1062 fAttr.setValue(filename);
1064 cmpNode.setAttributeNode(fAttr);
1065 fileAttributes.push_back(fAttr);
1068 cmpsNode.appendChild(cmpNode);
1073 for (i=0; i < lst.count(); i++)
1075 QDomElement cstNode = doc.createElement(
"constant");
1080 cstNode.setAttribute(
"id",lst[i]);
1081 cstNode.setAttribute(
"type",t);
1083 QDomText cstTxt = doc.createTextNode(r);
1084 cstNode.appendChild(cstTxt);
1085 cstsNode.appendChild(cstNode);
1091 for (i=0; i < lst.count(); i++)
1093 QDomElement libNode = doc.createElement(
"library");
1097 QDomAttr fAttr = doc.createAttribute(
"path");
1098 fAttr.setValue(lst[i]);
1100 libNode.setAttributeNode(fAttr);
1101 fileAttributes.push_back(fAttr);
1102 libsNode.appendChild(libNode);
1105 ctxNode.appendChild(libsNode);
1106 ctxNode.appendChild(cmpsNode);
1107 ctxNode.appendChild(cstsNode);
1108 doc.documentElement().appendChild(ctxNode);
1117 QDomElement app = doc.createElement(
"application");
1118 doc.appendChild(app);
1123 app.setAttribute(
"mode",
"base");
1126 app.setAttribute(
"mode",
"thread");
1129 app.setAttribute(
"mode",
"threadevent");
1132 app.setAttribute(
"mode",
"gui");
1135 app.setAttribute(
"mode",
"event");
1141 QDomElement prcs = doc.createElement(
"processes");
1142 app.appendChild(prcs);
1145 for (
int i = 0; i < nProc; i++)
1150 void ARCSXMLHandler::storeProcess(
ARCSProcess* proc,QDomElement father)
1152 QDomElement process = doc.createElement(
"process");
1158 for(
int i=0; i< sheetNames.count(); i++)
1163 father.appendChild(process);
1172 QDomElement composite = doc.createElement(
"composite");
1173 doc.appendChild(composite);
1189 QDomElement interfaceARCS = doc.createElement(
"interface");
1190 elt.appendChild(interfaceARCS);
1196 QStringList signalNames;
1197 QStringList slotNames;
1198 QStringList methodNames;
1199 QStringList componentNames;
1201 if (methodNames.count() == componentNames.count() &&
1202 methodNames.count() == signalNames.count())
1204 QDomElement signalRoot = doc.createElement(
"signals");
1205 interfaceARCS.appendChild(signalRoot);
1206 for (i=0; i< methodNames.count(); i++)
1208 QDomElement method = doc.createElement(
"method");
1209 method.setAttribute(
"alias",methodNames[i]);
1210 method.setAttribute(
"component", componentNames[i]);
1211 method.setAttribute(
"method",signalNames[i]);
1212 signalRoot.appendChild(method);
1217 if (methodNames.count() == componentNames.count() &&
1218 methodNames.count() == slotNames.count())
1220 QDomElement slotRoot = doc.createElement(
"slots");
1221 interfaceARCS.appendChild(slotRoot);
1222 for (i=0; i< methodNames.count(); i++)
1224 QDomElement method = doc.createElement(
"method");
1225 method.setAttribute(
"alias",methodNames[i]);
1226 method.setAttribute(
"component", componentNames[i]);
1227 method.setAttribute(
"method",signalNames[i]);
1228 slotRoot.appendChild(method);
1235 void ARCSXMLHandler::reset()
1237 libraryStrings.clear();
1243 QString ARCSXMLHandler::nodeInternalsToText(QDomNode node)
1247 QTextStream ts(&res);
1249 if (node.hasChildNodes())
1251 QDomNodeList children = node.childNodes();
1252 for (
int i = 0 ; i < children.count() ; i++)
1253 ts << children.at(i) ;
void getProxySignals(QStringList &proxies, QStringList &objects, QStringList &signalNames)
void storeInterface(ARCSAbstractComponent *aac, QDomElement father=QDomElement())
XML representation of a statemachine.
QStringList getSheetNames()
bool setContents(QString s)
Gives the content to parse.
void getProxySlots(QStringList &proxies, QStringList &objects, QStringList &slotNames)
ARCSInit & addCleanup(QString dst, QString slt, QString t, QString val)
Adds a cleanup invocation to the sheet structure.
Class defining a composite component i.e. a component made of components.
bool serializeConstant(QString name, QString &type, QString &representation)
Serializes constants.
XML representation of an application.
virtual QString toString()=0
Defines a basic seralization mechanism.
For applications running with Qt Widgets.
bool parseInterface(ARCSAbstractComponent *aac, QDomNode node=QDomNode())
bool parseContext(ARCSContext *)
Parses a context.
void setSheet(ARCSSheet ref)
Sets the sheet to use as an internal description of embedded components.
QString getProperty(QString name)
This class represents an application.
bool addProxySlot(QString proxy, QString id, QString slot)
Adds a wrapper to an internal component and its slot.
This class is representing a process under ARCS.
QString getFirstSheetName()
Returns the name of the first state activated in the statemachine.
void setCurrentMode(ARCS::ARCSAppFlag flag)
QStringList getComponentList()
bool modifyConstant(QString name, QString representation)
Modifies a constant of the list.
ARCSSheet * getSheet()
Returns the internal structure of this composite component described as a sheet.
bool openFile(QString s)
Opens a file given its path. The file should describe either an application or a composite component...
ARCSInit & addPreconnect(QString dst, QString slt, QString t, QString val)
Adds a pre-connection initialisation to the sheet structure.
bool addComponent(QString name, QString className, QString contents=QString::null)
Adds a component to the list.
QStringList getPropertyList()
void setContext(ARCSContext *ctx)
static ARCSFactory * getInstance()
Returns the instance of the singleton ARCSFactory.
XML representation of a composite component.
void setApplicationMode(ARCS::ARCSAppFlag flag)
None of the application mode has been selected so far.
void setProperty(QString name, QString value)
bool setController(QString s=QString::null)
void addProcess(ARCSProcess *ap)
ARCSContext getContext()
Returns the internal context of the composite component.
QVariant getProperty(QString name)
Gets a meta-property from this component.
ARCS::ARCSAppFlag getCurrentMode()
For applications nested in a thread.
void getCleanups(QStringList &destinations, QStringList &slts, QStringList &types, QStringList &values)
Allows to retrieve cleanup invocations.
Class handling the generic description of a component.
ARCSContext * getContext()
virtual bool loadFile(QString fn)
Defines a way to load a component description from a file.
XML representation of a profile.
void storeSheet(ARCSSheet *as, QDomElement father, QString id=QString::null)
Stores the xml description of a sheet.
QString getLastSheetName()
Returns the name of the last state activated in the statemachine.
void setFirstSheetName(QString s)
Sets the name of the first sheet i.e. the starting node of the statemachine.
ARCSAbstractComponent * getComponent(QString name)
Retrieves a component by its id.
void getConnections(QStringList &sources, QStringList &signls, QStringList &destinations, QStringList &slts)
Allows to retrieve connections.
bool parseProcess(ARCSProcess *ap, QDomElement processNode)
Parses the xml description of a process.
void getPostconnects(QStringList &destinations, QStringList &slts, QStringList &types, QStringList &values)
Allows to retrieve postconnection invocations.
bool saveFile(QString s)
Saves a file given its path. The file will describe either an application or a composite component...
QStringList computeLibraryList()
ARCSXMLHandler()
Constructor.
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.
QStringList getConstantList()
bool loadLibrary(QString path)
Loads a library given the path to it.
void reset()
Resets the component and constant lists.
bool parseSheet(ARCSSheet *as, QDomElement father)
Parses the xml descriptions of a sheet.
ARCSProcess * getProcess(int idx)
Class describing a state machine in order to control an application.
void setProperty(QString name, QVariant value)
Sets a meta-property on this component.
ARCSContext * getContext()
ARCSConnection & getConnection(QString source, QString sgn, QString dst, QString slt)
returns a reference to a connection in the sheet structure
ARCSInit & addPostconnect(QString dst, QString slt, QString t, QString val)
Adds a post-connection initialisation to the sheet structure.
ARCSSheet & getSheet(QString s)
For applications nested in a thread running with an event loop.
For applications requiring event loops.
Maintains connections between objects.
void getPreconnects(QStringList &destinations, QStringList &slts, QStringList &types, QStringList &values)
Allows to retrieve preconnection invocations.
bool addProxySignal(QString proxy, QString id, QString signal)
Adds a wrapper to an internal component and its signal.
void setLastSheetName(QString s)
Sets the name of the last sheet i.e. the node ending the statemachine.
QString getControllerId()
void addSheet(QString s, ARCSSheet sh)