tags:

views:

287

answers:

4

I'm using Enterprise Architect code generation feature to export my models to Delphi code. Is there a way to specify interface GUIDs in EA so that interfaces are completely defined in the output code?

Example:

ILogger = interface
  procedure Log(AMessage: ILoggerMessage);
end;

should be

ILogger = interface
['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}']
  procedure Log(AMessage: ILoggerMessage);
end;
A: 

CTRL + SHIFT + G

Michael Steele
That would by when editing the file in Delphi but I want Enterprise Architect to include the GUID automatically while generating the code so that I don't need to edit them manually.
Tihauan
I did not read the question carefully enough. Enterprise Architect is something I've never worked with.
Michael Steele
+1  A: 

No. Delphi has no idea whether you'll need a GUID or not, as not all interfaces have to have one. (Interfaces that aren't intended for COM and don't implement IDispatch, for instance.) The IDE can't read your mind (yet - maybe there's hope for the future ), and can't know what type of interface you're planning on creating.

Ken White
A: 

Seems that EA does not support interfaces as in COM programming. But, you can try use the template editing feature to change the way code is generated...

Fabricio Araujo
+1  A: 

You should add to ILogger TaggedValue Attribute with value containing GUID in form that Delphi likes:

Attribute=['{16B77CF4-4219-412D-B1F3-20E29E2E9D9E}']

then you should modify Code Generation Template Class Body and add

%classTag:"Attribute"%

as the second line (should be after %if elemType == "Interface"%) Now EA should properly generate code with GUID's. EA imports it well but fails to generate properly.

This is a quick fix for interfaces only, it's been long time since I programmed in Delphi so I'm not sure if classes can have such attributes as well, therefore solution is limited to interfaces, for now :).