ä»æ¥ã¯ãå€æãäœæããå€æãèšè¿°ããŸãã å人çã«ãããã¯ã人ã ã倢ã®äžã§å€¢ãèŠãã¯ãªã¹ããã¡ãŒã»ããŒã©ã³ã®ãå§ãŸãããæãåºãããŸãã
ããã¯ãã¢ãã«æåéçºãµã€ã¯ã«ã®7çªç®ã®èšäºã§ãã 6ãæéãç§ã¯ã¢ãã«é§ååéçºã®æ·±å»ãªäŸã䜿ã£ãŠèšäºãæžã蟌ãããšããŠããŸããã ããããæ¯åãéåžžã«åçŽãªäŸãæŽçããããã«ãæåã«ãã¯ãããžãŒå šè¬ã«ã€ããŠè©±ãå¿ èŠãããããšãç解ããŠããŸãã ããã§ä»åã¯ããHello Worldãããèšäºãå§ããããšæã£ãã ãã§ããã®çµæããã®åçŽãªäŸã¯å€é¡ã®èšäºã«ãªããŸããã
ã¯ããã«
ååã®èšäºã§ã¯ãã¢ãã«ãã¡ã¿ã¢ãã«ãã¢ãã«ãšãã£ã¿ãŒãããã¹ãããã³ã°ã©ãã£ãã¯è¡šèšã«ã€ããŠèŠãŠããŸããã éçããåçã«ç§»è¡ããæã§ãã ä»æ¥ã¯ãããã€ãã®ã¢ãã«å€æããŒã«ã玹ä»ããŸãã
ã¯ãšãª/ãã¥ãŒ/å€æïŒQVTïŒ
QVTã¯ãã¢ãã«å€æãèšè¿°ãããã¡ã€ã³åºæã®èšèªã®ãã¡ããªã§ãã OMG QVTä»æ§ã§ã¯ã3ã€ã®èšèªã«ã€ããŠèª¬æããŠããŸãã
- QVT CoreïŒQVTcïŒã¯ã宣èšçãªã¢ãã«å€æèšèªã§ãã ããšãã°ãUMLããã³ERã¢ãã«ããããŸãã QVTã³ã¢ã䜿çšãããšãUMLã¢ãã«ã®ã¯ã©ã¹ãERã¢ãã«ã®ãšã³ãã£ãã£ã«å¯Ÿå¿ããŠããããšãUMLã¢ãã«ã®ã¯ã©ã¹ããããã£ãERã¢ãã«ã®å±æ§ã«å¯Ÿå¿ããŠããããšãªã©ããèšããããšãã§ããŸãã ãã®ãããªãããã³ã°ã«ã€ããŠèª¬æããã®ã§ãäžéšã®UMLã¢ãã«ãERã¢ãã«ã«ããŸãã¯éã«UMLã¢ãã«ã®ERã¢ãã«ã«å€æã§ããŸãïŒåæ¹åãããã³ã°ïŒã
- QVTãªã¬ãŒã·ã§ã³ïŒQVTrïŒã¯QVTã³ã¢ãšã»ãŒåãã§ãããæ§æç³è¡£ã®ã¿ã§ãå€æãããã³ã³ãã¯ãã«èšè¿°ã§ããŸãã
- QVTéçšïŒQVToïŒ-以åã®2ã€ã®èšèªãšã¯ç°ãªããããã¯ãã§ã«å¿ é ã§ãããäžæ¹åã®ã¢ãã«å€æã®ã¿ãèšè¿°ã§ããŸãã
QVToã¯å ã Borlandã«ãã£ãŠå®è£ ãããŠããŸããã ãããŠ2007-2008幎ãããEclipseã®äžéšãšããŠéçºãããŠããŸãã ã
QVTcããã³QVTrã«ã¯ã Eclipseã®å®è£ ããããŸã ã Eclipse Neonã®ãªãªãŒã¹ãŸã§ã«äœ¿çšã§ããããã«èšç»ãããŠããŸãã ããããããã¯ããŸãå¹æçã§ã¯ãããŸãããããããã£ãŠããã®èšäºã§ã¯ããã«ã€ããŠè©³ãã説æããŸããã
QVToå€æã¯ãEclipseã ãã§ãªããã¹ã¿ã³ãã¢ãã³Javaã¢ããªã±ãŒã·ã§ã³ã§ãå®è¡ã§ããããšã«æ³šæããããšãéåžžã«éèŠã§ãã ããšãã°ãå€æã¯WebãµãŒããŒåŽã§æ£åžžã«æ©èœããŸãã
QVTã¯OCLã®ã¢ããªã³ãšèŠãªãããšãã§ããŸãã ããã²ãŒã·ã§ã³ã«ã¯ãQVTã®æŒç®åãããããã³ã->ãã䜿çšã§ããŸãã æšæºã®OCLã©ã€ãã©ãªã䜿çšã§ããŸãã
ATLå€æèšèªïŒATLïŒ
ATLã¯ãQVTãšäžŠè¡ããŠç»å Žãããã€ããªããïŒå®£èšçã«å¿ é ïŒã¢ãã«å€æèšèªã§ãã QVTã«ãã䌌ãŠããŸãããããã€ãã®éãããããŸãã
çæïŒ
- OMG QVTä»æ§ããã QVTãšã¯ç°ãªããæšæºåãããŠããŸããã
- å°ãå€ãã£ãæ§æã§ãããããã¯äž»èŠ³çãªãã®ã§ãã
- OCLã®ç¬èªã®ç°¡ç¥åãããå®è£ ãOMGOCLä»æ§ã«é©åããã Eclipse OCLã»ã©è¯ããªãå ŽåããããŸãã
- ãšã©ãŒã¡ãã»ãŒãžãåžžã«æ¶å»ããããšã¯éããŸããã
- ããŸã䟿å©ã§ã¯ãªããšãã£ã¿ãŒãšãããã¬ãŒã
- å€æãéå§ããã«ã¯ãANTã¹ã¯ãªãããäœæããå¿ èŠããããŸãã
é·æïŒ
- Eclipse OCLãQVTã§äœ¿çšãããŸãããåªããŠããŸãããæ¯èŒçéããã®ã§ãã ATLã¯å šäœãšããŠQVToããã軜快ã«èŠããŸãã
- å€æã®æ¹è¯ã®ãµããŒãã æ°ããã¢ãã«ãäœæããã®ã§ã¯ãªããæ¢åã®ã¢ãã«ã«å°ããªå€æŽãå ããå¿ èŠãããå Žåã¯ãATLã®æ¹ã䟿å©ã§ãã çè«çã«ã¯ãQVTããã®ãããªå€æãèšè¿°ã§ããŸãããã»ãšãã©ãã¹ãŠãè€éã§ãã
- é«æ¬¡å€æã®ãµããŒãã ATLã䜿çšãããšãã¢ãã«ãšåæ§ã«ATLå€æã䜿çšã§ããŸãã ã€ãŸã ããã䜿çšãããšãATLå€æãäœãã«å€æããããéã«äœãããATLå€æãäœæãããã§ããŸãã çè«çã«ã¯ãQVTã§ãããè¡ãããšãã§ããŸãããå®éã«ã¯ããã¹ãŠãããã»ã©åçŽã§ã¯ãããŸããã
å€èº«
å€èº«ã¯ã¢ãã«å€æèšèªã§ããããŸãã ããããQVTãATLãšã¯ç°ãªããããã¹ãã§ã¯ãªãèŠèŠçã§ãã ã«ããŽãªãŒçè«ã«åºã¥ããŠããŸãã ã¢ãã«ã¯ãããã«ã³ãŒãã«ãŒãã¹ã¯ãšã¢ïŒããã«ããã·ã¥ã¢ãŠã-DPOïŒãŸãã¯ã·ã³ã°ã«ã³ãŒãã«ãŒãã¹ã¯ãšã¢ïŒã·ã³ã°ã«ããã·ã¥ã¢ãŠã-SPOïŒã®æ¹æ³ã䜿çšããŠå€æã§ããã°ã©ããšèŠãªãããŸãã
æ£çŽãªãšãããããã¯éåžžã«èå³æ·±ããããã¯ã§ããã次ã®èšäºã®ããããã§ããããã«ããŽãªçè«ã«æ»ããŸãã
Henshinã§ã¯ãApache Giraphã§å€æãå®è¡ã§ããŸããããã«ãããéåžžã«å€§ããªã¢ãã«ãå€æã§ããŸãã ãããè¡ã£ãããšã¯ãããŸããããäž»ã«QVToã䜿çšããŠããŸãã
ãã®ä»ã®ããŒã«
ã¢ãã«å€æã®ããã®ãã®ä»ã®ããŒã«ããããŸãïŒ Epsilon Transformation Language ã EMorF ã AGGïŒå±æ§ä»ãã°ã©ãææ³ã·ã¹ãã ïŒ ã VIATRAïŒä»®æ³èªåã¢ãã«å€æïŒãªã©ã ãããã¯ãã¹ãŠåæ§ã®åé¡ã解決ããåæ§ã®ååã«åºã¥ããŠããŸãã QVToãATLããŸãã¯Henshinãããªãã«åããªãå Žåãå€ãã®éžæè¢ããããŸãã
ãããšã¯å¥ã«ãXSLTã«æ³šç®ãã䟡å€ããããŸãã å€é©ã«é¢ããŠã¯ãå€ãã®äººããããæãåºããŸãã ç§èªèº«ã2000幎代ååãXSLTã®åºçŸã®å€æãã«ãXSLTãšãã®ãµã€ãã®PHPãšã³ãžã³ã«ã€ããŠæžããŸããã 圌ã¯æ¿ãããã¬ãŒãããããåœæã¯èããããªãã£ãéã®RAMãèŠæ±ããŸããã ããããããã¯ãã€ã³ãã§ã¯ãªããæè¡ã¯æªããããŸãããXSLTã«ããã€ãã®ç°¡åãªå€æãæžããŠããŸãã
XSLTã®æåã®åé¡ã¯ãXMLããã¥ã¡ã³ãã®å€æã«çŠç¹ãåãããŠããããšã§ãã ãã¡ãããã¢ãã«ãXMLããã¥ã¡ã³ããšããŠã·ãªã¢ã«åããXSLTã«ãã£ãŒãããããšãã§ããŸãã ããã«ã察å¿ããOMG XMIä»æ§ããããŸãïŒä»¥äžãXMIãã¡ã€ã«ã®äŸããããŸãïŒã ããããæåã«ãã¢ãã«ãXMLãã¡ã€ã«ã«å ¥ããããŸããŸãªæ¹æ³ããããŸãã ããšãã°ãå±æ§ã¯XMLå±æ§ãŸãã¯XMLèŠçŽ ãšããŠã·ãªã¢ã«åã§ããŸãã ãã®ãããªå€åã¯ãXSLTå€æãéåžžã«è€éã«ããŸãã 第äºã«ãã¢ãã«ã¯ããªãŒã§ã¯ãªãã°ã©ãã§ãããéåžžãã¢ãã«ã§ã¯ã¢ãã«éãå«ãæ°Žå¹³æ¥ç¶ã§ãã£ã±ãã§ãã ãã®ãããªãªã³ã¯ã䜿çšããŠç®çã®ãªããžã§ã¯ããæ€çŽ¢ããã®ã¯ãå°çã®ããã§ãã ãããŠãUMLã¢ãã«ã§ããå€ãã®ãããã¡ã€ã«ãšã¹ãã¬ãªã¿ã€ããæãåºãã°ãããã¯ãã§ã«å°çã®9çªç®ã®ãµãŒã¯ã«ã§ãã
XSLTã®2çªç®ã®åé¡ã¯XMLæ§æã§ãåã«äŸ¿å©ã§ã¯ãããŸããã
æåŸã«ãéåžžã®ã¢ãã«å€æããŒã«ã«ã¯ãXSLTäœæè ã倢ã«ãæããªãã£ãããšããããŸãã ããšãã°ãQVToã®å€æãã°ãšé 延ãªã³ã¯ã®è§£æ±ºãããã«ã€ããŠã¯ãåŸã§ïŒãããã°ã»ã¯ã·ã§ã³ã§ïŒçŽ¹ä»ããŸãã
ç§ã®è°è«ãååã«çŽåŸã§ããªãå Žåã¯ãããHello Worldãå€æãèšè¿°ããå€æãèšè¿°ããŠããŸããã»ã¯ã·ã§ã³ã«ãXMI圢åŒã®ã¢ãã«ã®äŸããããŸãã 以äžã¯ããã®ãããªã¢ãã«ãçæããATLå€æã§ãã åæ§ã®XSLTå€æãã©ã®ããã«èŠãããæ³åããŠãã ããã
ãšããã§ãEclipse Modeling Frameworkã䜿çšãããšãXMLã¹ããŒããšEcoreã¡ã¿ã¢ãã«ããªã³ã¯ã§ããŸãã ããã«ãããã»ãŒä»»æã®XMLãã¡ã€ã«ãEcoreã¢ãã«ã«ããŸãã¯ãã®éã«å€æã§ããŸãã ããã«ãããQVToãATLãããã³XMLããã¥ã¡ã³ããå€æããããã®ä»ã®ããŒã«ã䜿çšã§ããŸãã ããããã次ã®ããããã®èšäºã§ãã®ãããªäŸãæ€èšããŸãã
QVTéçš
Hello Worldãæžã
ãã€ãã®ããã«ã Eclipse Modeling Toolsã䜿çšããŸã ã
éçšQVTããã³ATLãã€ã³ã¹ããŒã«ããŸãïŒãã«ã->ã¢ããªã³ã°ã³ã³ããŒãã³ãã®ã€ã³ã¹ããŒã«ïŒã
http://download.eclipse.org/modeling/emft/henshin/updates/releaseããHenshinãã€ã³ã¹ããŒã«ããŸãïŒãã«ã->æ°ãããœãããŠã§ã¢ã®ã€ã³ã¹ããŒã«...ïŒã
å®æãããããžã§ã¯ããååŸããããæ°ãããããžã§ã¯ããäœæã§ããŸãïŒ[ãã¡ã€ã«]-> [æ°èŠ]-> [ãã®ä»...]-> [éçšQVTãããžã§ã¯ã]ïŒã
æ°ããå€æãäœæããŸãïŒãã¡ã€ã«->æ°èŠ->ãã®ä»...->æäœå¯èœãªQVTå€æïŒã
次ã®ããã«ã¡ã€ã³ã¹ããŒãã¡ã³ããå®äºããŸãã
transformation HelloWorld1(); main() { log('Hello world'); }
æ§æãäœæããŠå€æãéå§ãïŒå®è¡->æ§æã®å®è¡...ïŒãå®è¡ããŸãã
次ã®ãããªãã®ã衚瀺ãããã¯ãã§ãã
ã¢ãã«æåã®ãHello worldããäœæããŸã
çã®ã¢ãã«æåã®ãHello worldãã«ã¯ãã¹ãã¢ãã«ãå¿ èŠã§ããã以åã®èšäºã§ã¯ãã§ã«ååãªã¢ãã«ãäœæããŸããã ããã«æéã浪費ããã®ããããŠãQVã«èªåã§äœæãããïŒ
modeltype ECORE 'strict' uses 'http://www.eclipse.org/emf/2002/Ecore'; transformation HelloWorld2(out o : ECORE); main() { object EPackage { name := 'World'; eClassifiers += object EClass { name := 'Alice'; }; eClassifiers += object EClass { name := 'Bob'; }; }; }
æåã«ïŒmodeltypeæŒç®åã䜿çšããŠïŒãäœæããã¢ãã«ã®ã¡ã¿ã¢ãã«ãæå®ããå¿ èŠããããŸãã 次ã«ã3è¡ç®ã§ãå€æã«1ã€ã®åºåã¢ãã«ãããããšã瀺ããŸãã æåŸã«ãã¡ã€ã³ã¹ããŒãã¡ã³ãã«ã³ãŒããè¿œå ããŸãã
çŽèŠ³çã«ã¯ãå€æã¯2ã€ã®ã¯ã©ã¹ïŒAliceãšBobïŒãå«ãWorldããã±ãŒãžãäœæããŸãã
ã¯ã©ã¹ãŸãã¯ããããã£ã®ååãCtrlã§ã¯ãªãã¯ããå Žåãããããå®çŸ©ãããŠããã¡ã¿ã¢ãã«ãéããŸãã ãŸããæ°çŸãŸãã¯2ã€ã®ç°ãªãã¡ã¿ã¢ãã«ããããŸãã
ã泚æ
以äžã§ã¯ãèšèªã®æ§æã«ã€ããŠããŸã説æããŸããã ä»æ§æžãŸãã¯ãã®ãã¬ãŒã³ããŒã·ã§ã³ã§åœŒãç¥ãããšãã§ããŸãã 次ã®èšäºã§ã¯ãQVToã«ã€ããŠããã«è©³ããæ€èšããŸãã
æ§æã§ãå€æãéå§ããã«ã¯ãçæãããã¢ãã«ãä¿åãããã¡ã€ã«ãæå®ããå¿ èŠããããŸãã
èµ·ååŸã次ã®ã¢ãã«ãååŸãããŸãã
æ¬åœã«ã¢ãã«æåã®ãHello worldããæžã
次ã«ããã¹ãã¢ãã«ãæ°ããã¢ãã«ã«å€æããŸãã 3è¡ç®ã§ã¯ãå€æã«åºåã ãã§ãªãå ¥åEcoreã¢ãã«ãå«ãŸããŠããããšã瀺ããŸãã ãããŠãããã€ãã®ã³ãŒããè¿œå ããŸãã
modeltype ECORE 'strict' uses 'http://www.eclipse.org/emf/2002/Ecore'; transformation HelloWorld3(in i : ECORE, out o : ECORE); main() { i.rootObjects()[EPackage]->toEPackage(); } mapping EPackage::toEPackage() : EPackage { name := 'Hello' + self.name; eClassifiers := self.eClassifiers->toEDataType(); } mapping EClassifier::toEDataType() : EDataType { name := 'Hello' + self.name; instanceClassName := 'some.ns.' + self.name + 'Class'; serializable := false; }
å€æã®æ¬è³ªã¯æ¬¡ã®ãšããã§ãã å ¥åã¢ãã«ã§ãã¹ãŠã®ã«ãŒãããã±ãŒãžãæ¢ããããããããã±ãŒãžã«å€æããŸãããä»ã®ããã±ãŒãžãå€æããŸãã ååã«ãã¬ãã£ãã¯ã¹ãHelloããè¿œå ãããã¹ãŠã®åé¡åãããŒã¿åã«å€æããŸãã ããŒã¿ååãæ¥é èŸãHelloãã§å§ãŸããŸããããŒãã®åã«ãããã«ããã€ãã®ããããã£ãèšå®ããŸãã
ãã®å€æãéå§ããããã®æ§æãäœæããŸãã 以åã«äœæããã¢ãã«ãå ¥åãšããŠæå®ããããšãå¿ããªãã§ãã ãããåºåã¢ãã«ã«ã¯ãæ°ãããã¡ã€ã«åãæå®ããŠãã ããã
èµ·ååŸã次ã®ããã«ãªããŸãã
ãããã°
Eclipse QVToã«ã¯ãéåžžã®ãã®ã«å ããŠããã¹ãŠã®ãããã³ã°ã®å ¥åããã³åºåãªããžã§ã¯ãã衚瀺ããå€æãããã¬ãŒããããŸãã å®éãQVToãšã³ãžã³ã¯ã¢ãã«å€æã®è©³çŽ°ãªãã°ãä¿æããŠããŸãïŒå³äžã®å³ïŒã ãããŠãããã¯ãããã°ã ãã§ãªãå¿ èŠã§ãã ãŸããåããªããžã§ã¯ããåã³è¡šç€ºããããšãçµæã¯ãã®ãã°ïŒãã£ãã·ã¥ïŒããååŸãããŸãã ãšããã§ãããã«ãããã¢ãã«ãã€ã³ã¯ãªã¡ã³ã¿ã«ã«å€æã§ããŸãã 次ã«ãã³ãŒãã§ã¯ãresolveæäœã䜿çšããŠãã°ã«æ瀺çã«ã¢ã¯ã»ã¹ã§ããŸãã ãŸããé 延解決ã«ããããŸã ååšããªããžã£ãŒãã«ãšã³ããªãåç §ã§ããŸãã ãã®éèªã¯QVToã®éèŠãªæ©èœã®1ã€ã§ãã
ATLå€æèšèª
truã¢ãã«æåã®ãHello worldããæžãæããŸã
ããã§ãATLã®æåŸã®å€æãæžãæããŸãã æ°ãããããžã§ã¯ããäœæããŸãïŒãã¡ã€ã«->æ°èŠ->ãã®ä»...-> ATLãããžã§ã¯ãïŒã æ°ããå€æãäœæããŸãïŒãã¡ã€ã«->æ°èŠ->ãã®ä»...-> ATLãã¡ã€ã«ïŒã ATLã¯QVToã«éåžžã«äŒŒãŠããããšãããããŸãã
-- @nsURI Ecore = http://www.eclipse.org/emf/2002/Ecore module HelloWorld3; create OUT : Ecore from IN : Ecore; rule toEPackage { from package : Ecore!EPackage to newPackage : Ecore!EPackage ( name <- 'Hello' + package.name, eClassifiers <- package.eClassifiers ) } rule toEDataType { from classifier : Ecore!EClassifier to dataType : Ecore!EDataType ( name <- 'Hello' + classifier.name, instanceClassName <- 'some.ns.' + classifier.name + 'Class', serializable <- false ) }
泚éã®æåã®è¡ã§ã䜿çšããã¡ã¿ã¢ãã«ã瀺ããŸããã ãã ãããªãŒãã³ã³ããªãŒãããšãã£ã¿ãŒã§æ©èœããã«ã¯ãåæ€åºãå¿ èŠã«ãªãå ŽåããããŸãã
ã泚æ
INRIAã¯ATLã®äœæã«å ãããŸãããççŽã«èšã£ãŠãããã¯æ§æã§èŠãããšãã§ããŸã:)圌ãã®Camlãããç§ãç®ãäºéã«ããŸããã åªãããªãã£ã¹ã§ããã圌ãã®èšèªã¯ä»ã®èšèªãšã¯ç°ãªã£ãŠããããã©ã³ã¹èªã¯è±èªãšã¯ç°ãªããšæããŠããŸãã æåã¯äŒŒãŠããããã«èŠããŸãããäœããééã£ãŠããŸãã
å€æãä¿åãããšãasmãã¡ã€ã«ããããžã§ã¯ãã«è¡šç€ºãããŸãã ããã¯åãå€æã§ãããATLä»®æ³ãã·ã³ã§å®è¡ããããã«èšèšããã圢åŒã§ãã
ã泚æ
å€æã§äœããå€æŽããããšããããŸãããå€ãæ¹æ³ã§åäœããŸãã ãã®å Žåãasmãã¡ã€ã«ãåé€ããèªåçã«åäœæãããªãå Žåã¯ãå€æã«åé¡ããããŸãã ããšãã°ãå€æã§ã¯dropæŒç®åã䜿çšããŸããããããã¯ATLã³ã³ãã€ã©ã®æ°ããããŒãžã§ã³ã§ã®ã¿ãµããŒããããŠãããç¹å¥ãªãã£ã¬ã¯ãã£ãã䜿çšããŠæ瀺çã«æå¹ã«ããå¿ èŠããããŸãã åæã«ããšã©ãŒã¯çºçãããasmãã¡ã€ã«ã¯éãã«åçæãããŸããã§ããã
[å®è¡]-> [å®è¡æ§æ]ã䜿çšããŠãã®å€æãéå§ã§ããŸã...ãã ãããã®æ¹æ³ã«ã¯ããã€ãã®å¶éããããããããã«å®è¡ããANTã¹ã¯ãªãããèšè¿°ããŸãã
ãããžã§ã¯ãã«æ¬¡ã®å 容ã®build.xmlãã¡ã€ã«ãäœæããŸãã
<?xml version="1.0"?> <project name="HelloWorldATL"> <target name="HelloWorld3"> <!-- Loading metamodels --> <atl.loadModel name="Ecore" metamodel="MOF" nsURI="http://www.eclipse.org/emf/2002/Ecore" /> <!-- Loading models --> <atl.loadModel name="IN" metamodel="Ecore" path="output/MyModel2.xmi" /> <!-- Transformation --> <atl.launch path="HelloWorld3.atl"> <inmodel name="IN" model="IN" /> <outmodel name="OUT" model="OUT" metamodel="Ecore" /> </atl.launch> <!-- Saving models --> <atl.saveModel model="OUT" path="output/MyModel3.xmi" /> </target> </project>
ãã¹ãå ¥åã¢ãã«ã¯ãQVToãããžã§ã¯ãããååŸã§ããŸãã
å®è¡ããæ§æãäœæããŸãïŒå®è¡->å€éšããŒã«->å€éšããŒã«æ§æ...ïŒã
build.xmlãžã®ãã¹ãæå®ããŸãã
[ã¿ãŒã²ãã]ã¿ãã§ãHelloWorld3ããã§ãã¯ããŸãã
ãããŠãæãéèŠãªããšãšããŠãJREã¿ãã§ãã¯ãŒã¯ã¹ããŒã¹ãšåãJREã§å®è¡ããéžæããŸããããããªããšããååãå®çŸ©ãããŠããŸããããšãããšã©ãŒã衚瀺ãããŸãã
èµ·åãããšã次ã®ãããªãã®ã衚瀺ãããŸãã
çµã蟌ã¿å€æã®äœæ
æ°ããã¢ãã«ãäœæããã®ã§ã¯ãªããæ¢åã®ã¢ãã«ã«å°ããªå€æŽãå ããå¿ èŠãããå ŽåããããŸãã ã¢ãã«ããBobãåé€ããæ®ããæè¿ããå€æãèšè¿°ããŸãããã
-- @atlcompiler atl2010 -- @nsURI Ecore = http://www.eclipse.org/emf/2002/Ecore module HelloWorld4; create OUT : Ecore refining IN : Ecore; rule sayHello { from s : Ecore!ENamedElement (s.name <> 'Bob') to t : Ecore!ENamedElement ( name <- 'Hello' + s.name ) } rule killBob { from s : Ecore!ENamedElement (s.name = 'Bob') to drop }
å®è¡ããã¹ã¯ãªããã
<?xml version="1.0"?> <project name="HelloWorldATL"> <target name="HelloWorld4"> <!-- Loading metamodels --> <atl.loadModel name="Ecore" metamodel="MOF" nsURI="http://www.eclipse.org/emf/2002/Ecore" /> <!-- Loading models --> <atl.loadModel name="IN" metamodel="Ecore" path="output/MyModel2.xmi" /> <!-- Transformation --> <atl.launch path="HelloWorld4.atl" refining="true"> <inoutmodel name="IN" model="IN" /> </atl.launch> <!-- Saving models --> <atl.saveModel model="IN" path="output/MyModel4.xmi" /> </target> </project>
ã¢ãã«ã¯å¥ã®ãã¡ã€ã«ã«ä¿åãããŸãããæ§é ã§ã¯ãå€æã§èª¬æãããŠããå€æŽãé€ããå ã®ã¢ãã«ãç¹°ãè¿ããŸãã
ç§ãã¡ã¯ããHello Worldãå€æãäœæããå€æãäœæããŠããŸã
å°ãè³ãé€å»ããæãæ¥ããšæããŸãã ç§ãã¡ããã§ã«æžããã¢ãã«ãäœæãŸãã¯å€æŽããå€æã å€æãç§ãã¡ã®ããã«æžãå€æãæžãããšã¯æ®ã£ãŠããŸãã
å®éãå€æèªäœã¯ã¢ãã«ã§ãã ããã確èªããããã«ãã¢ãªã¹ãšããã«å人çã«æšæ¶ããå°ããªå€æãäœæããŸãã
-- @nsURI Ecore = http://www.eclipse.org/emf/2002/Ecore module HelloWorld5; create OUT : Ecore from IN : Ecore; rule SayHelloToAlice { from classifier : Ecore!EClassifier ( classifier.name = 'Alice' ) to datatype : Ecore!EDataType ( name <- 'Hello' + classifier.name ) } rule SayHelloToBob { from classifier : Ecore!EClassifier ( classifier.name = 'Bob' ) to datatype : Ecore!EDataType ( name <- 'Hello' + classifier.name ) }
ãã®ã¹ã¯ãªããã䜿çšããŠãå€æãXMI圢åŒã§ä¿åããŸãã
<?xml version="1.0"?> <project name="HelloWorldATL"> <target name="ATLCopy"> <!-- Loading metamodels --> <atl.loadModel name="ATL" metamodel="MOF" nsURI="platform:/plugin/org.eclipse.m2m.atl.common/org/eclipse/m2m/atl/common/resources/ATL.ecore" /> <!-- Loading models --> <atl.loadModel name="IN" metamodel="ATL" path="HelloWorld5.atl"> <injector name="ATL" /> </atl.loadModel> <!-- Saving models --> <atl.saveModel model="IN" path="output/HelloWorld5.atl.xmi" /> </target> </project>
ãã®çµæããã®ãããªã¢ãã«ãåŸãããŸãã
<?xml version="1.0" encoding="ISO-8859-1"?> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:atl="http://www.eclipse.org/gmt/2005/ATL" xmlns:ocl="http://www.eclipse.org/gmt/2005/OCL"> <atl:Module location="3:1-26:2" name="HelloWorld5"> <commentsBefore>-- @nsURI Ecore = http://www.eclipse.org/emf/2002/Ecore</commentsBefore> <inModels location="4:25-4:35" name="IN" metamodel="/2"/> <outModels location="4:8-4:19" name="OUT" metamodel="/1"/> <elements xsi:type="atl:MatchedRule" location="6:1-15:2" name="SayHelloToAlice"> <outPattern location="11:2-14:4"> <elements xsi:type="atl:SimpleOutPatternElement" location="12:3-14:4" varName="datatype"> <type xsi:type="ocl:OclModelElement" location="12:14-12:29" name="EDataType" model="/4"/> <bindings location="13:4-13:37" propertyName="name"> <value xsi:type="ocl:OperatorCallExp" location="13:12-13:37" operationName="+"> <source xsi:type="ocl:StringExp" location="13:12-13:19" stringSymbol="Hello"/> <arguments xsi:type="ocl:NavigationOrAttributeCallExp" location="13:22-13:37" name="name"> <source xsi:type="ocl:VariableExp" location="13:22-13:32" referredVariable="/0/@elements.0/@inPattern/@elements.0"/> </arguments> </value> </bindings> </elements> </outPattern> <inPattern location="7:2-10:4"> <elements xsi:type="atl:SimpleInPatternElement" location="8:3-8:33" varName="classifier" variableExp="/0/@elements.0/@inPattern/@filter/@source/@source /0/@elements.0/@outPattern/@elements.0/@bindings.0/@value/@arguments.0/@source"> <type xsi:type="ocl:OclModelElement" location="8:16-8:33" name="EClassifier" model="/3"/> </elements> <filter xsi:type="ocl:OperatorCallExp" location="9:4-9:29" operationName="="> <source xsi:type="ocl:NavigationOrAttributeCallExp" location="9:4-9:19" name="name"> <source xsi:type="ocl:VariableExp" location="9:4-9:14" referredVariable="/0/@elements.0/@inPattern/@elements.0"/> </source> <arguments xsi:type="ocl:StringExp" location="9:22-9:29" stringSymbol="Alice"/> </filter> </inPattern> </elements> <elements xsi:type="atl:MatchedRule" location="17:1-26:2" name="SayHelloToBob"> <outPattern location="22:2-25:4"> <elements xsi:type="atl:SimpleOutPatternElement" location="23:3-25:4" varName="datatype"> <type xsi:type="ocl:OclModelElement" location="23:14-23:29" name="EDataType" model="/6"/> <bindings location="24:4-24:37" propertyName="name"> <value xsi:type="ocl:OperatorCallExp" location="24:12-24:37" operationName="+"> <source xsi:type="ocl:StringExp" location="24:12-24:19" stringSymbol="Hello"/> <arguments xsi:type="ocl:NavigationOrAttributeCallExp" location="24:22-24:37" name="name"> <source xsi:type="ocl:VariableExp" location="24:22-24:32" referredVariable="/0/@elements.1/@inPattern/@elements.0"/> </arguments> </value> </bindings> </elements> </outPattern> <inPattern location="18:2-21:4"> <elements xsi:type="atl:SimpleInPatternElement" location="19:3-19:33" varName="classifier" variableExp="/0/@elements.1/@inPattern/@filter/@source/@source /0/@elements.1/@outPattern/@elements.0/@bindings.0/@value/@arguments.0/@source"> <type xsi:type="ocl:OclModelElement" location="19:16-19:33" name="EClassifier" model="/5"/> </elements> <filter xsi:type="ocl:OperatorCallExp" location="20:4-20:27" operationName="="> <source xsi:type="ocl:NavigationOrAttributeCallExp" location="20:4-20:19" name="name"> <source xsi:type="ocl:VariableExp" location="20:4-20:14" referredVariable="/0/@elements.1/@inPattern/@elements.0"/> </source> <arguments xsi:type="ocl:StringExp" location="20:22-20:27" stringSymbol="Bob"/> </filter> </inPattern> </elements> </atl:Module> <ocl:OclModel location="4:14-4:19" name="Ecore" model="/0/@outModels.0"/> <ocl:OclModel location="4:30-4:35" name="Ecore" model="/0/@inModels.0"/> <ocl:OclModel location="8:16-8:21" name="Ecore" elements="/0/@elements.0/@inPattern/@elements.0/@type"/> <ocl:OclModel location="12:14-12:19" name="Ecore" elements="/0/@elements.0/@outPattern/@elements.0/@type"/> <ocl:OclModel location="19:16-19:21" name="Ecore" elements="/0/@elements.1/@inPattern/@elements.0/@type"/> <ocl:OclModel location="23:14-23:19" name="Ecore" elements="/0/@elements.1/@outPattern/@elements.0/@type"/> </xmi:XMI>
ã泚æ
æ®å¿µãªãããANTã¹ã¯ãªããã®ATLã®ãã°ã®1ã€ã«ãããATL.ecoreãžã®çããããã¹ãèšè¿°ããå¿ èŠããããŸãã ãŸããåå空éwww.eclipse.org/gmt/2005/ATLããã³www.eclipse.org/gmt/2005/OCL㯠Eclipseã«ç»é²ãããŠããªããããçµæã®XMIãã¡ã€ã«ãéåžžã®ããªãŒã¢ãã«ãšãã£ã¿ãŒã§éãããšãã§ããŸããã ããã¯ä¿®æ£ã§ããŸãããæ°ãæ£ããããšã¯ãããŸãããèšäºã®ç®çäžãããã¯éèŠã§ã¯ãããŸããã äž»ãªããšã¯ãATLå€æãã¢ãã«ãšããŠè¡šçŸã§ããããšã§ãã
次ã«ãåæ§ã®ã¢ãã«ãçæããå€æãèšè¿°ããŸãïŒã€ãŸããç¹å®ã®ã¢ãã«ã®åã¯ã©ã¹ã«å人çã«æšæ¶ããå€æãçæããŸãïŒã
-- @nsURI Ecore = http://www.eclipse.org/emf/2002/Ecore -- @path ATL = platform:/plugin/org.eclipse.m2m.atl.common/org/eclipse/m2m/atl/common/resources/ATL.ecore module GenerateHelloWorld; create OUT : ATL from IN : Ecore; rule EPackageToModule { from package : Ecore!EPackage to _module : ATL!Module ( name <- 'HelloWorld5', inModels <- thisModule.createEcoreModel('IN'), outModels <- thisModule.createEcoreModel('OUT'), elements <- package.eClassifiers ) } rule EClassifierToRule { from classifier : Ecore!EClassifier to _rule : ATL!MatchedRule ( name <- 'SayHelloTo' + classifier.name, inPattern <- _in, outPattern <- _out ), -- InPattern _in : ATL!InPattern ( elements <- inElement, filter <- inFilter ), inElement : ATL!SimpleInPatternElement ( varName <- 'classifier', type <- thisModule.createEcoreModelElement('EClassifier') ), inFilter : ATL!"OCL::OperatorCallExp" ( operationName <- '=', source <- thisModule.createAttributeCallExp(inElement, 'name'), arguments <- thisModule.createStringExp(classifier.name) ), -- OutPattern _out : ATL!OutPattern ( elements <- outElement ), outElement : ATL!SimpleOutPatternElement ( varName <- 'datatype', type <- thisModule.createEcoreModelElement('EDataType'), bindings <- nameBinding ), nameBinding : ATL!Binding ( propertyName <- 'name', value <- helloPrefixOperatorExp ), helloPrefixOperatorExp : ATL!"OCL::OperatorCallExp" ( operationName <- '+', source <- thisModule.createStringExp('Hello'), arguments <- thisModule.createAttributeCallExp(inElement, 'name') ) } lazy rule createEcoreModel { from name : String to model : ATL!OclModel ( name <- name, metamodel <- ecoreMM ), ecoreMM : ATL!OclModel ( name <- 'Ecore' ) } lazy rule createEcoreModelElement { from name : String to element : ATL!"OCL::OclModelElement" ( model <- model, name <- name ), model : ATL!OclModel ( name <- 'Ecore' ) } lazy rule createAttributeCallExp { from var : ATL!SimpleInPatternElement, name : String to expr : ATL!"OCL::NavigationOrAttributeCallExp" ( name <- name, source <- variableExp ), variableExp : ATL!"OCL::VariableExp" ( referredVariable <- var ) } lazy rule createStringExp { from str : String to expr : ATL!"OCL::StringExp" ( stringSymbol <- str ) }
åæ§ã®XSLTå€æãã©ã®ããã«èŠãããæ³åããŠãã ããã
å®è¡ããã¹ã¯ãªããã
<?xml version="1.0"?> <project name="HelloWorldATL"> <target name="GenerateHelloWorld"> <!-- Loading metamodels --> <atl.loadModel name="Ecore" metamodel="MOF" nsURI="http://www.eclipse.org/emf/2002/Ecore" /> <atl.loadModel name="ATL" metamodel="MOF" nsURI="platform:/plugin/org.eclipse.m2m.atl.common/org/eclipse/m2m/atl/common/resources/ATL.ecore" /> <!-- Loading models --> <atl.loadModel name="IN" metamodel="Ecore" path="output/MyModel2.xmi" /> <!-- Transformation --> <atl.launch path="GenerateHelloWorld.atl"> <inmodel name="IN" model="IN" /> <outmodel name="OUT" model="OUT" metamodel="ATL" /> </atl.launch> <!-- Saving models --> <atl.saveModel model="OUT" path="output/HelloWorld5.atl"> <extractor name="ATL" /> </atl.saveModel> </target> </project>
å€æãéå§ãããšããã®ãµãã»ã¯ã·ã§ã³ãéå§ããå€æãååŸããŸãïŒSayHelloToAliceããã³SayHelloToBobã«ãŒã«ã䜿çšïŒã
å€æãèšè¿°ããå€æãèšè¿°ããå€æãèšè¿°ããŸã...
åè«ã ããããªãå¿ èŠãªã®ãæ³åããã®ã¯é£ããã§ãã
å€èº«
äžæ°å³ãªATLæ§æããå°ãå埩ããããã«ãããŠã¹ã§å€æãæç»ããŸãã
æ°èŠãããžã§ã¯ããäœæããŸãïŒéåžžãŸãã¯JavaïŒãã¡ã€ã«->æ°èŠ->ãã®ä»...-> Javaãããžã§ã¯ãïŒã
å€èº«å³ãäœæãããšãäœæãŠã£ã¶ãŒãã§ã¢ãã«ãäœæããããšãã§ããŸãã ãšããã§ã ã·ãªãŠã¹ã«é¢ããèšäºã§ããã®ãããªãã€ã¢ã°ã©ã ãšãã£ã¿ã®äœææ¹æ³ãåŠã³ãŸããã
次ã®ãããªå€æãäœæããŸãã
æå³ã¯çŽæçã§ãªããã°ãªããŸããã æåã«ããã殺ããã«ã«ãã¹ã玹ä»ããŸãã ãã®åŸãçåè ãæè¿ããŸãã
ã泚æ
æ£çŽãªãšããããã£ãŒããšãã£ã¿ã«æ £ããå¿ èŠããããŸãã ããšãã°ãSequential Unitã§ã«ãŒã«ã®é åºãå€æŽã§ããªãå Žåãã¢ãã«ã®ããªãŒãšãã£ã¿ãŒã§å€æŽã§ããŸãã
ãããžã§ã¯ãããªãŒã®å·ŠåŽã§ãhenshinãã¡ã€ã«ã®ã³ã³ããã¹ãã¡ãã¥ãŒãåŒã³åºããŸãã ãããŠãå€èº«->å€æã®é©çšãéžæããŸãã åã ã®ã«ãŒã«ãšã¢ãžã¥ãŒã«ã®äž¡æ¹ãå®è¡ã§ããŸãã
ã¢ãã«ãšããŠãQVToå€æã«ãã£ãŠä»¥åã«èŠªåã«çæããããã¹ãã¢ãã«ãæå®ã§ããŸãã ãŠã£ã¶ãŒãã¯ãå€æåŸã«ã¢ãã«ãæ¯èŒããããã«æäŸããããšã«æ³šæããŠãã ããã
ãã¹ãŠãæ£åžžã§ããã°ãèµ·ååŸã«æ¬¡ã®ãããªãã®ã衚瀺ãããŸãã
ã芧ã®ãšãããã¢ãªã¹ã®ååã®å€æŽãããã®æ®ºå®³ãã«ã«ãã¹ã®ã¢ãã«ãžã®å°å ¥ã¯èŠéããããŸããã§ããã
ããããã»ãšãã©ã®å Žåã次ã®ãããªãã®ã衚瀺ãããŸãã
ãããçºçããå Žåããšã©ãŒã®åå ãç¹å®ããã«ã¯ãåæ§ã®ã¯ã©ã¹ã䜿çšããŠæåã§å€æãéå§ããå¿ èŠããããŸãã
HelloWorldHenshin.Main
package HelloWorldHenshin; import org.eclipse.emf.henshin.interpreter.EGraph; import org.eclipse.emf.henshin.interpreter.Engine; import org.eclipse.emf.henshin.interpreter.UnitApplication; import org.eclipse.emf.henshin.interpreter.impl.EGraphImpl; import org.eclipse.emf.henshin.interpreter.impl.EngineImpl; import org.eclipse.emf.henshin.interpreter.impl.UnitApplicationImpl; import org.eclipse.emf.henshin.model.Module; import org.eclipse.emf.henshin.model.resource.HenshinResourceSet; public class Main { public static void main(String[] args) { HenshinResourceSet resourceSet = new HenshinResourceSet("model"); Module module = resourceSet.getModule("HelloWorld.henshin", false); EGraph graph = new EGraphImpl(resourceSet.getResource("MyModel2.xmi")); Engine engine = new EngineImpl(); UnitApplication app = new UnitApplicationImpl(engine); app.setEGraph(graph); app.setUnit(module.getUnit("main")); if (!app.execute(null)) { throw new RuntimeException("Execution error"); } resourceSet.saveEObject(graph.getRoots().get(0), "MyModel3.xmi"); } }
ãã®å Žåãããæå³ã®ãããšã©ãŒã¡ãã»ãŒãžã衚瀺ãããå¯èœæ§ããããŸãã
å€èº«å€æã®äŸãèŠãããšããå§ãããŸãã ç¹ã«ã·ã§ã«ãã³ã¹ããŒã®äžè§åœ¢ãšé£äºå²åŠè ã«ã€ããŠã
EMorF ã AGG ã VIATRAãªã©ãåæ§ã®ããŒã«ãããã€ããããŸãã
ãããã«
ãã®èšäºã§ã¯ãããã€ãã®ã¢ãã«å€æããŒã«ã«æ³šç®ããŸããã
å€æèªäœãã¢ãã«ã§ãããšç¢ºä¿¡ããŠããŸãã
ã«ããŽãªãŒçè«ïŒSPOãDPOïŒã®èå³æ·±ãå®çšçãªå¿çšãèŠãŸãããããã¯åŸã§æ»ã£ãŠãããããããŸããã
ããäžåºŠããªããžã§ã¯ã管çã°ã«ãŒãã®ä»æ§ïŒ XMI ã OCL ã QVT ã UML ïŒã«ã€ããŠèããŸããã
äœæ°ãªãEMF Compareã¢ãã«æ¯èŒããŒã«ã«æ £ããŸããã
ãœãŒã¹ã³ãŒãã¯ãã¡ãããå ¥æã§ããŸã ã
次ã®èšäºã§ã¯ãå®éã®è€éãªQVToå€æã«ã€ããŠèª¬æããŸãã