Entirely wrote in pure Java, this code generator take UML models in XMI file format and generate C++ or Java source code. \n\nIts need at lease Java version 5 to compile successfully. Made in pure Java so its portable every where where Java run. The main strength of MLGen is its simplicity but will providing full featured code generator. This permit any one to easily modify it to fulfill its specific needs if the normal version don't do it. \n\nThe generator can be called from command line or script specifying the UML XMI file to use to generate source code. XMI is a common file format that can be exported from many UML editor. Where some of then are open source. Many of there UML editor have integrated generator but they don't have many code generation feature or are not easily modifiable.\n\nMLGen can generate C++ code that create and use template class. It also can generate and use Java generics.\n\nMLGen work by reading a XMI file and create an internal representation of the UML model with “emodel” objects. Then its generate source code from the “emodel”. Emodel is a language independent code representation. In the future other language generation may be added.\n\n
* use svn/tutoise patch to keep manual modification of generated source from star uml\n* support created template class/fct \n
/***\n|''Name:''|LegacyStrikeThroughPlugin|\n|''Description:''|Support for legacy (pre 2.1) strike through formatting|\n|''Version:''|1.0.1|\n|''Date:''|Jul 21, 2006|\n|''Source:''|http://www.tiddlywiki.com/#LegacyStrikeThroughPlugin|\n|''Author:''|MartinBudden (mjbudden (at) gmail (dot) com)|\n|''License:''|[[BSD open source license]]|\n|''CoreVersion:''|2.1.0|\n|''Browser:''|Firefox 1.0.4+; Firefox 1.5; InternetExplorer 6.0|\n\n***/\n\n//{{{\n\n// Ensure that the LegacyStrikeThrough Plugin is only installed once.\nif(!version.extensions.LegacyStrikeThroughPlugin)\n {\n version.extensions.LegacyStrikeThroughPlugin = true;\n\nconfig.formatters.push(\n{\n name: "legacyStrikeByChar",\n match: "==",\n termRegExp: /(==)/mg,\n element: "strike",\n handler: config.formatterHelpers.createElementAndWikify\n});\n\n} // end of "install only once"\n//}}}\n
[[Overview]]\n[[Description]]\n[[Usage]]\nToDo\nToDoDone\n[[Ideas]]\nXMIGeneration\n[[Support]]\n[[DownLoad|https://sourceforge.net/project/showfiles.php?group_id=202785]]\n[[Project@SourceForge|https://sourceforge.net/projects/mlgen/]]\n-----\nMainMenu\n\n\n\n\n\n\nHosted at [[SourceForge.net|http://sourceforge.net]]\n[img[picturename|http://sflogo.sourceforge.net/sflogo.php?group_id=202785&type=5]]\nSite Ver.: 3
Entirely wrote in pure Java, this code generator take UML models in XMI file format and generate C++ or Java source code.
From UML XMI to source code //(Press F5 or reload icon for last web site version)//
If you have a source forge account I suggest you to use the forum at https://sourceforge.net/forum/?group_id=202785. \nOtherwise you can send email directly to driobt "at" gmail "dot" com\n
~ToDo (in order):\n* generate Java 5 source (under development, main features done)\n* auto. add interface fct into subclass\n* handle interface extends\n* add License where needed to\n* support fct arg default value\n* derivate from template class\n* support const pointer not only const for object\n* line wrap at 80/100 char.\n* now advance cad stuff: auto GLog code include, assert, pre, post condition, invariant check, in/out design pattern, ...\n* in ctor init add base class ctor call\n
~ToDoDone:\n* generate .cpp file\n* recognize and generate ctor/dtor : add var member init in ctor [: [baseCls(TODO), ][var(TODO)[, var2(TODO)]]]\n* support use of template/generic class, by sub class typedef of template, done in 12.rar\n* (create common empty std class)? set list vector map, ect. Done in 13.rar\n* line end with /r/n not only 0x0A: Done in 14.rar\n* derivate from normal class 16.rar\n* generate #include directive Done as 17.rar\n* generate UML document as code comment (for class, function, class variable) Done as 18.rar\n* support static class var. Done as 19.rar\n* use Constraint (precondition) Done in 20.rar\n* command line interface Done in 21.rar\n* add version to program: in net.sourceforge.mlgen.application.MLGen class\n* in all generated file add UML model name used to generate the source code\n\n\n
Generate C++ source code:\n{{{\nStart -> run: cmd.exe\njava -jar mlgen.jar -c -s"Untitled.xml" -d"./generated-source"\n}}}\n\nGenerate Java source code:\n{{{\nStart -> run: cmd.exe\njava -jar mlgen.jar -j -s"Untitled.xml" -d"./generated-source"\n}}}\n
For now the only XMI file are those generated with free StarUML (http://staruml.sourceforge.net/en/download.php)\n\nDesc.\nStarUML is an open source project that are fast, flexible, extensible, feature full and freely-available. Its an UML/MDA platform running on Win32 platform. It is more easy to lean and use then many other like ArgoUML.\n\nhttp://staruml.sourceforge.net/en/\nhttps://sourceforge.net/projects/staruml/\n\n\nNotes:\n* Its important to follow instructions for StarUML so MLGen will work as expected\n\nTips:\n* Menu Bar -> Model -> Profiles -> Include UML Standard Profile\n* Menu Bar -> Model -> Profiles -> Include Java profile\nor\n* Menu Bar -> Model -> Profiles -> Include C++ profile\n\nSometimes MLGen can't parse the xmi file because of a illogical or errornous UML model. Check for type that is not correctly set to a model class. In this case StarUml create an custom XMI.DataType not recognized by MLGen. A look to the xmi file with some knowledge of the file format help to found the model problem. This problem can append if you enter the type name instead of browsing into it or by using the reverse engineer feature.\n\n\n------\nC++ Code Generation:\nWith StarUML Internal Generator:\n* Menu Bar -> Model -> Profiles -> Include C++ profile\n* Configure General / Default generation option in Menu Bar -> Tools -> Options... -> C++: There are important option for generating code with namespaces\n*To correctly support namespace generate code by left-click on UMLProject in Model Explorer View. Then choose C++ -> Generate Code...: Select desired UML Model (not package) click next -> Select desired package (not individual files) then continue...\nWith MLGen:\n* Export all project in xmi\n* Use MLGen\n\n----\nC++ Code Modeling\n*Make Constructor:\nCreate an operation with same name as its class, in stereotype in properties, enter create (destroy for destructor).\n*Make an operation(function) const, virtual, etc:\nIn model explorer left-click on a class's operator then select Tagged Values of pop-up menu. Select the appropriate tag definition set (combo) then set the value. To make it pure virtual, make it virtual in Tagged Values then check IsAbstract in properties.\n*Add argument (parameter) to function:\nIn model explorer left-click on a class's operator then select Add -> Parameter then type parameter name. Enter type in UML Parameter properties view. If its a const pointer or reference, in model explorer left-click on parameter then select Tagged Values of pop-up menu. Select the appropriate tag definition set (combo) then set the value. For pointer or reference select CppPointer Tag Definition Set then in the CppPointer value field enter a * for pointer or & for reference.\n* Add precondition\nTo add a function argument constraint (precondition), select argument in Model Explorer then in right-click menu select "Constraints...". In the dialog click "Add" button. Enter a name (the name its not processed) as body enter a simple boolean expression without the argument name. For exemple for the argument (const int index), a possible expression is >=0.\n*Specify return type of function:\nAdd a parameter to a operation and name is return. Select the return operation's parameter then in the properties view section detail change DirectionKind to RETURN.\n* Add class variable:\nSelect the class then add attribute. To make an attribute static (using the UML Standard Profile), select the attribute in Model Explorer and edit its ~TaggedValue. Select ~UMLStandard tab and set Persistence field to PERSISTENT. Use TaggedValue CppPointer with value set to * for pointer or & for reference. \n*Class function order:\nThe order of function in generated class file is same as operations order of the class in class diagram. To change an operation order click on a operation of a class in diagram then then click on the up or down arrow that appear on the right\n*Make Template class\nSelect the class to add template parameter. In Class properties, details section, click on TemplateParameters. In the opened dialog click on the dotted small rectangle on the left. In Model Explorer view click on the + of the class to see its contents then select one of dotted small rectangle (template parameter). In properties details edit name if needed and select Class in ParameterType.\n*Use Template class\nStarUML does't directly support template usage but with little work around it work. By following the tip, MLGen will correctly handle usage of class template to generate C++ and generic java code.\n(more to come)\nCreate an inner class say IntVector for the class that will use the created template. Set that inner class to use the tagged value TypeDef. Then use the tag value to define the template class usage like; std::vector<int>. The name should be carefully enter since this is raw text input. Then simply use the inner class for member variable and other to use the template class.\n\n\n