Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - grand.titus

Pages: [1]
1
General Board / Re: Generate C++ code for attribute default value
« on: October 15, 2006, 11:44:28 pm »
OK but what about initialisation of
-const static attribut ("=value" in the header)
-non-const static attribut ("type class::att=value;" in the class body)

2
General Board / Generate C++ code for attribute default value
« on: October 14, 2006, 04:07:23 pm »
Hello everyboby

I would like EA takes care of attribute initial values during C++ code generation.

For exemple, I want to set the 4 attributes of this class to 1:
Code: [Select]

class Class1 {
public:
  Class1();
  virtual ~Class1();
private:
  static const int stat_const_att;
  static int stat_att;
  const int dyn_const_att;
  int dyn_att;
};

So I would like EA to generate something like:
Code: [Select]

// Class1.h
class Class1 {
public:
  Class1();
  virtual ~Class1();
private:
  static const int stat_const_att=1;
  static int stat_att;
  const int dyn_const_att;
  int dyn_att;
};

//Class1.cpp
#include "Class1.h"

int Class1::stat_att =1;

Class1::Class1() : dyn_att(1),dyn_const_att(1){

}

I search a solution on this forum and I found this post:
Quote
I did it sir,

So u need create new template Attribute__Implement
$COMMENT = "Its script implement initialization for constructors"
%PI=" "%

%if attStatic==""%

$COMMENT = "Not static initialization"
$type=%attQualType%
$type=%REPLACE($type,".","::")%
$qualType=%packagePath% + "::" + %attType%
%PI=""%
%attContainment=="By Reference" ? "&" : ""%
%attName%( %attInitial% )

%else%

$COMMENT = "Static initialization"
 %attQualType% %className%::%attName% = %attInitial%;

%endIf%

Replace Class Body Implement template to following code
$templateArgs=%list="ClassParameter" @separator=", "%
%if $templateArgs != ""%
$templateArgs="<" + $templateArgs + ">"
$templ="template" + $templateArgs
%endIf%
$consPrefix=$templ + "\n" + %classQualName% + "::"

%if classStereotype != "struct"%

%PI=" "%
%if genOptGenConstructor == "T" and genOptGenConstructorInline != "T" and classHasConstructor != "T"%
$defaults = %list="Attribute__Implement" @separator=", " attInitial !=""%
$consPrefix%className%()
%if $defaults != ""%
: $defaults
%endIf%
\n{\n\n}
%endIf%

%PI="\n\n"%
 
%if genOptGenDestructor == "T" and genOptGenDestructorInline != "T" and classHasDestructor != "T"%
$destructor=$consPrefix+"~"+%className%+"()\n{\n\n}"
$destructor
%endIf%

%if genOptGenCopyConstructor == "T" and genOptGenCopyConstructorInline != "T" and classHasCopyConstructor != "T"%
$consPrefix%className%( const %className%& the%className% )\n{\n\n}
%endIf%

%endIf%

%list="OperationImpl" @separator="\n\n\n"%

%list="InnerClassImpl" @separator=""%

I checked - its works

Unfortunately, it doesn't work. It generates something like:
Code: [Select]

// Class1.h
class Class1 {
public:
  Class1();
  virtual ~Class1();
private:
  static const int stat_const_att;
  static int stat_att;
  const int dyn_const_att;
  int dyn_att;
};

//Class1.cpp
#include "Class1.h"

Class1::Class1() : int Class1::stat_att =1;int Class1::stat_const_att =1;dyn_att(1),dyn_const_att(1){

}

I am not confortable with code template editor. Is there is somebody for correcting the (nice) work of golyshkin?

Thanks for your help.

3
General Board / Re: C++ namespaces generation with packages
« on: October 13, 2006, 08:13:33 am »
Thanks for your answer.
Unfortunately manipulating template transformation code seem to be complex for me.

4
General Board / Re: C++ namespaces generation with packages
« on: October 10, 2006, 12:53:11 am »
Quote
Either add it to each class headers field, or add it to the Import Section template.

Finally, I have added:

  • "using namespace std;" into the Import Section template
  • "using namespace Package2;" into the headers and imports fields of the Generate Code dialog box of the class Class1.

These two instructions are added in the right place in *.h and *.cpp. But EA doesn't take care of "using namespace Package2;" and continues to add "Package2::" before "Class2". Is it possible to get round this problem?

5
General Board / Re: C++ namespaces generation with packages
« on: October 09, 2006, 12:40:06 am »
Thanks, I've not seen this option. Now it works.

I get the code:
Code: [Select]

#include "Class2.h"
namespace Package1
{
class Class1
{
public:
Class1();
virtual ~Class1();
Package2::Class2 get();
private:
Package2::Class2 c2;
};
}

I am glad with that, but is it possible to use the instruction "using namespace ...;"?
In particular, can I put "using namespace std;" at the head of ech file?



I also wonder if it is possible to generate sources into a directory "src" rather than "Class Model"? In order to get this hierarchy:
Code: [Select]

-src
.+--Package1
.|..+--Class1.h
.|..+--Class1.cpp
.+--Package2
....+--Class2.h
....+--Class2.cpp

rather than:
Code: [Select]

-Class Diagram
.+--Package1
.|..+--Class1.h
.|..+--Class1.cpp
.+--Package2
....+--Class2.h
....+--Class2.cpp

6
General Board / C++ namespaces generation with packages
« on: October 06, 2006, 07:42:56 am »
Hi

I have a very simple project:
---Class Model [set as Namespace Root]
------Package1 [NOT set as Namespace Root]
---------Class1 with an attribute c2:Class2
------Package2 [NOT set as Namespace Root]
---------Class2

When I generate the C++ code, I expect to get a file Class1.h with something like:
Code: [Select]

using namespace Package2;

namespace Package1
{
  class Class1
  {
     public:
        Class1();
        virtual ~Class1();
     private:
        Class2 c2;
  };
}

But what I really get is:
Code: [Select]

#include "Class2.h"

class Class1
{
  public:
     Class1();
     virtual ~Class1();
  private:
     Class2 c2;
};


In fact, EA packages are not transformed into C++ namespaces.

Thanks in advance

PS: EA version : 6.5.797

7
General Board / Generate association link automatically
« on: October 04, 2006, 06:18:16 am »
Hello everybody

Considering 3 classes belonging to the same package:
-Class1
-Class2 with an attribute "a1" of type Class1
-Class3 with an operation "op1" of type Class1

When these 3 classes are placed on the same class diagram, is it possible to generate automatically:
- an association link from Class2 to Class1 with the target role "a1"
- an association link from Class3 to Class1 with the target role "op1"?

Thanks for your answer

8
General Board / Using STL classes in a EA project
« on: October 02, 2006, 07:07:29 am »
Hello everybody

I am building a EA project in prevision of C++ code generation. I would like to use STL classes in this project. Does it exist some option/addin/template project/...  to make EA aware of STL classes?

Thanks for your answers.

9
Automation Interface, Add-Ins and Tools / Re: Unknow symbole over class box
« on: November 06, 2006, 06:24:57 am »
ok thank you.
I suppose that I pressed shift+space by mistake  :-/
A second shift+space and the bookmark disappeared :)

10
Automation Interface, Add-Ins and Tools / Unknow symbole over class box
« on: November 06, 2006, 05:04:11 am »
Hello everybody

During some manipulation of my project, a red triangle is appeared over one of my class box (in a class diagram)

"screenshot"  ;D

   _
   V   <- the red triangle
+-------+
| Class |
+-------+


Do you know what is this triangle and how remove it?

Thank you

11
Hi


When the option "Show package content" is checked, is it possible to specify which kind of elements to really show? For instance, is it possible to only show the classes of a package? Or to show everything except Use Cases?

Thanks

12
ok
Thanks

13
Hello everybody

I find the "Show hidden parent" option very useful. However I don't undestand why it doesn't work with realization links which are very similar to generalization links.

For exemple, let's take that only Class1 is put in a class diagram. So:
-if Class1 generalises Class2, then Class2 will be written at the top hand left corner of the Class1 box.
-if Class1 realises Interface3, then Interface3 will NOT be written at the top hand left corner of the Class1 box.

Is it wanted?

14
Thanks!!! :D

15
Hello everybody

In a class diagram, I would like to display the package name of classes. For instance "package_1::sub-package_1.2::MyClass".

In addition, is it possible to display the package name only for classes outside of the current package?

Thanks for your answers.

Pages: [1]