transfoLightSimplePDL2PN.tex 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. \begin{tomcode3}[caption=Forme générale du code de la transformation \emph{SimplePDLToPetriNet},label=code:transfoLightSimplePDL2PN]
  2. ...
  3. public class SimplePDLToPetriNet {
  4. %include{ sl.tom }
  5. %include{ LinkClass.tom }
  6. %include{ emf/ecore.tom }
  7. %include{ mappings/DDMMPetriNetPackage.tom }
  8. %include{ mappings/DDMMSimplePDLPackage.tom }
  9. private static PetriNet pn = null;
  10. private static LinkClass tom__linkClass;
  11. %typeterm SimplePDLToPetriNet { implement { SimplePDLToPetriNet }}
  12. public SimplePDLToPetriNet() {
  13. this.tom__linkClass = new LinkClass();
  14. }
  15. ...
  16. %transformation SimplePDLToPetriNet(tom__linkClass:LinkClass,pn:PetriNet) :
  17. "metamodels/SimplePDL.ecore" -> "metamodels/PetriNet.ecore" {
  18. definition P2PN traversal `TopDown(P2PN(tom__linkClass,pn)) {
  19. /* code du listing #\colcode{black}{~\ref{code:p2pn}}# */
  20. }
  21. definition WD2PN traversal `TopDown(WD2PN(tom__linkClass,pn)) {
  22. /* code du listing #\colcode{black}{~\ref{code:wd2pn}}# */
  23. }
  24. definition WS2PN traversal `TopDown(WS2PN(tom__linkClass,pn)) {
  25. /* code du listing #\colcode{black}{~\ref{code:ws2pn}}# */
  26. }
  27. }
  28. public static void main(String[] args) {
  29. ...
  30. SimplePDLToPetriNet translator = new SimplePDLToPetriNet();
  31. Introspector introspector = new EcoreContainmentIntrospector();
  32. // processus #\colcode{black}{\texttt{à}}# transformer
  33. simplepdl.Process p_root = `Process("root", ...);
  34. Strategy transformer =
  35. `SimplePDLToPetriNet(translator.tom__linkClass,translator.pn);
  36. transformer.visit(p_root, introspector);
  37. //Appel de la strat#\colcode{black}{\texttt{é}}#gie de r#\colcode{black}{\texttt{é}}#solution g#\colcode{black}{\texttt{é}}#n#\colcode{black}{\texttt{é}}#r#\colcode{black}{\texttt{é}}#e
  38. `TopDown(tom__StratResolve_SimplePDLToPetriNet(translator.tom__linkClass,
  39. translator.pn)).visit(translator.pn, introspector);
  40. `TopDown(Sequence(PrintTransition()),PrintPlace()).visit(translator.pn,
  41. introspector);
  42. ...
  43. }
  44. ...
  45. }
  46. \end{tomcode3}