Book a Demo

Author Topic: C++ "friend" keyword  (Read 3353 times)

SebastienRoy

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
C++ "friend" keyword
« on: March 24, 2006, 12:38:25 am »
Hello,
When I make the reverse engineering of a C++ class which declares functions as "friends", these functions are generated in EA model as methods of the class.
This is a real problem for the round trip.
Does anyone has a workaround for that?

Seb

SebastienRoy

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: C++ "friend" keyword
« Reply #1 on: March 24, 2006, 02:35:17 am »
I have another pb : The member initialization part of the constructors is removed by EA.
Example :
Code: [Select]

MyClass::MyClass()
: myAttribute(InitialValue)
{
// code...
}

is replaced with :
Code: [Select]

MyClass::MyClass()
{
// code...
}

when I regenerate my class.
This is really a blocking problem for using the code generator.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ "friend" keyword
« Reply #2 on: March 26, 2006, 02:34:08 pm »
The friend appears to be an issue with reverse engineering being inconsistent with code generation.  Adding the following line into your operation declaration template should fix it.

Code: [Select]
%opTag:"friend"=="true" ? "friend" : ""%

Member initialization is round tripped in the tagged value "initializer", so in your example the value of that tag should be "myAttribute(InitialValue)".  Reverse engineering the class should also add the appropriate tag.

SebastienRoy

  • EA User
  • **
  • Posts: 25
  • Karma: +0/-0
    • View Profile
Re: C++ "friend" keyword
« Reply #3 on: March 29, 2006, 02:53:43 am »
Thank you for your help.
Finally, I will avoid using the "friend" C++ facility in my code. It is not really UML complient and breaks the class encapsulation (it is however usefull because there is no "package" specific visibility in C++).

For the "initializer" tagged value, it works fine. Was it written somewhere in the documentation? I didn't find it.

Sebastien

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ "friend" keyword
« Reply #4 on: March 29, 2006, 02:18:25 pm »
Yes, it was.  Sorry, I forgot to include the link before.

http://www.sparxsystems.com/EAUserGuide/index.html?cpp_conventions.htm