Having Fun and PRODUCTIVITY with Acceleo

In the context of an RCP application for internal customers I have to parse some binary files and store the result in a relation Database (this is done with http://www.sqlite.org/). The binary file content is described in text specification document. To be short, this file contains different “events” belonging to a given “category”. The category of the event is defined in the header of the event and this category allow to decode the event’s content. There is roughly 200 categories.

200 ??? This mean I’ll have to code 200 “parser classes”, one for each of these categories inserting the right things in the database. Wait ….. Few weeks ago, a colleague working in an other internal RCP application,  presented to me this application based on many Modeling technologies and mainly on Acceleo to generate some code from graphical models.

My context is a little bit different, because I don’t want to provide the code generation to my end users but I want to have fun and to be more productive in my daily work.  After few days of work and thanks to help of my colleagues already using this technology and thanks to the reactive support of Obeo on the Eclipse Modeling Forums I have a first version of my tool using generated classes.

To achieve this I first created an ecore Model (or meta model but name ar not important) file (.ecore). This EMF file describe what is a category: it’s mainly a list of parameters having a given type and a given length. Then, using the magic EMF Reflexive Editor, I created an instance of my model (or meta model), an xmi file describing all the available categories and their content. Finally I created an Acceleo 3 project, which job is to take my xmi file has input and generate the associated 200 Parser classes (through the use of a template file coded in OCL).

To conclude, reading this post you are thinking “it seems really easy to bring together these technologies” !!! I confirm, it is !!


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s