Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: DanG83616 on July 12, 2013, 08:13:58 am
-
Is there a way to generate non-member operations in a model transform?
for example, I want to put something into a C++ PSM that will result in the following after code gen:
std::ostream& operation<<(std::ostream& out, foo& foo);The transform engine complains to find "Operation" outside of a Class.
Thanks,
Dan
-
The last time that I wanted to model something like this I created a class with the stereotype of "namespace member". You could do the same from a transformation template.
I then created stereotype overrides in the code templates so that the class didn't generate anything for the declaration and only generated the members in the body (no braces).
-
Just about there... how did you suppress the using statement in the impl file?
-
I could not defeat EA's mission to place:
using <class>;into the impl file.
As a workaround, I made the stereotype override code template generate a forward decl into the header.
class %className%; // Just to make the compiler eat the "using" statement in the impl file w/o complaining
%list="Operation"%
I also modified the Operation Declaration Impl template like this:
%if classStereotype != "nonmembers"%
%classQualName%::
%endIf%
Thanks for the tip!
Dan