UML2c Plug-in

The UML2c Plug-in generates C source code and Google C++ Mocking Framework (Google Mock) from Astah's UML Class models.

   Versions


   How to Install

  1. Download the UML2C Plug-in from [Download] button and unzip the file.
  2. Copy "uml2c-x.x.x.jar" and the "uml2c" folder to userhome/.astah/professional(community)/plugins.
    Astah UML2C Plugin
  3. Launch Astah. If you find [UML2C plugin] menu under the [Tools], that means the installation has completed successfully!
    Astah UML2C Plugin

   Template Files

  1. All the .vm-extension files are the template files that are necessary to generate code and need to be placed as below.
  2. Windows%USERPROFILE%\.astah\professional(community)\plugins\uml2c\header.vm
    Mac and Linux$HOME/.astah/professional(community)/plugins/uml2c/header.vm
  3. Encoding of template files needs to be in UTF-8.

   How to Use

  1. Open a class diagram and select a class you want to generate code for. (Click here for sample output.)
  2. Go to [Tools] - [UML2C plugin] - [Generate C skeleton code] or [Generate GoogleMock code].
  3. Specify the output directory.
  4. If you get this dialog, the source code is generated successfully!

   Sample Code

This is a sample diagram in "uml2c-plugin-sample.asta" included in the .zip file.



Single Instance Module

Classes with <<SingleInstance >> stereotype will be exported as single instance module.


Foo.c

#include "Foo.h"

static EnumSample enumSample[ /* TODO */ ];
static Bar bar;
static Abstract *abstracts[ /* TODO */ ];
static Concrete concretes[ /* TODO */ ];


void Foo_Create(void)
{
	/* TODO */
}

void Foo_Destroy(void)
{
/* TODO */
}

uint32_t Foo_Operation(const char *arg)
{
/* TODO */
}

Foo.h

#ifndef _FOO_H_
#define _FOO_H_
#ifdef __cplusplus
extern "C" {	/* } */
#endif


void Foo_Create(void);
void Foo_Destroy(void);
uint32_t Foo_Operation(const char *arg);


#ifdef __cplusplus
}
#endif
#endif	/* _FOO_H_ */
		



Multi Instance Modules

Multi Instance Modules Standard classes will be exported as multi instance modules.


Bar.c

#include "Bar.h"


void Bar_Create(Bar self, uint64_t id, const char *name)
{
	/* TODO */
}

void Bar_Destroy(Bar self)
{
	/* TODO */
}

uint16_t Bar_Operation(Bar self)
{
	/* TODO */
}


Bar.h

#ifndef _BAR_H_
#define _BAR_H_
#ifdef __cplusplus
extern "C" {	/* } */
#endif


typedef struct BarStruct *Bar;


void Bar_Create(Bar self, uint64_t id, const char *name);
void Bar_Destroy(Bar self);
uint16_t Bar_Operation(Bar self);

#include "BarPrivate.h"

#ifdef __cplusplus
}
#endif
#endif	/* _BAR_H_ */


BarPrivate.h

#ifndef _BAR_PRIVATE_H_
#define _BAR_PRIVATE_H_
#ifdef __cplusplus
extern "C" {	/* } */
#endif


struct BarStruct {
uint64_t id;
char *name;
};


#ifdef __cplusplus
}
#endif
#endif	/* _BAR_PRIVATE_H_ */



Per-type dynamic interface (Super Class)

Abstract Classes will be exported as per-type dynamic interface.



Abstract.c

#include "Abstract.h"

void Abstract_Destroy(Abstract self)
{
	/* TODO */
}

uint8_t Abstract_Operation(Abstract self)
{
	/* TODO */
}

Abstract.h

#ifndef _ABSTRACT_H_
#define _ABSTRACT_H_
#ifdef __cplusplus
extern "C" {	/* } */
#endif

typedef struct AbstractStruct *Abstract;


void Abstract_Destroy(Abstract self);
uint8_t Abstract_Operation(Abstract self);

#include "AbstractPrivate.h"

#ifdef __cplusplus
}
#endif
#endif	/* _ABSTRACT_H_ */

AbstractPrivate.h

#ifndef _ABSTRACT_H_
#define _ABSTRACT_H_
#ifdef __cplusplus
extern "C" {	/* } */
#endif

typedef struct AbstractStruct *Abstract;


void Abstract_Destroy(Abstract self);
uint8_t Abstract_Operation(Abstract self);

#include "AbstractPrivate.h"

#ifdef __cplusplus
}
#endif
#endif	/* _ABSTRACT_H_ */