Book a Demo

Author Topic: Class model: Working with external libraries?  (Read 7570 times)

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Class model: Working with external libraries?
« on: April 21, 2011, 08:57:15 pm »
We are using a C++ library (Qt) as base of our development.

1) In my class diagram, how do I specify a Qt class (e.g. QGraphicsWidget) as base class of one of my own classes?

2) How will the custom types, enums and classes/template classes of the library affect my code generation, if I keep EA ignorant of the library?

3) How would I include the library into my project?

4) What else should I keep in mind when working with an external library?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Class model: Working with external libraries?
« Reply #1 on: April 21, 2011, 10:03:46 pm »
You'll have to import the libraries you use.
see Import Source Directory or Import Binary Module

Geert

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #2 on: April 22, 2011, 12:15:04 am »
Imported as source code, the library seems to be too big for EA. I've let it run for 2-3 hours, but by then the import was running at snail pace (where, in the beginning, I was barely able to follow the import output, by the end each line took several seconds to appear), and it had only imported maybe 20% of the library.

Importing as binary returned unspecified errors for each module.

What else can I try?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Class model: Working with external libraries?
« Reply #3 on: April 27, 2011, 09:17:57 am »
To my knowledge, Qt neither provides a .Net or Java binary (as it is native C++) so import binary will not work.

When doing the source directory import, did you turn off creating diagrams? It makes a big impact on speed and I would highly recommend it when importing any large project.

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #4 on: April 27, 2011, 05:41:00 pm »
Hi Simon,

thanks for your reply! Sounds like a good idea, and I'll make sure to try this the next time.
However, I first need to address the issue of macros in the library (see http://www.sparxsystems.com/cgi-bin/yabb/YaBB.cgi?num=1303815305)

The library does not really work without it's macros, and I cannot even guess what the code parser makes of the code when not understanding the macros.

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #5 on: April 27, 2011, 06:02:18 pm »
Hi
I am using the Qt framework as well.

EA has a list of MACROS that are ignored when importing source code and you can add to this list by selecting Settings->Pre Processor macros.

However, I did not find this very successful for the Qt libraries as there are some complex and non standard macros in there (I seem to remember that 'public slots:' gave me some grief) >:(

The approach that I have taken is to take a copy of the classes that I need (you surely don't need the whole of Qt in your model) and edit them so that they will import. You don't need to do much usually just comment out a few lines.

Not ideal I know but it works for me

Graham
Using V12

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #6 on: April 27, 2011, 06:14:08 pm »
Hi Graham,

thanks for your reply!
It implies to me that I cannot make the code parser actually understand the macros, only ignore them. Is that correct?

Of course I am not using all of Qt, but I expect to use quite a lot eventually. The question is whether it's worth to manually instrument the Qt classes when I cannot ever make them work fully (because the macros won't work).

The alternative is to use EA as a pure UML drawing tool, and write the code manually. It might actually be less work in total.

Have you tried EA 9? Are the any improvements regarding macros that might help?

SomersetGraham

  • EA User
  • **
  • Posts: 376
  • Karma: +1/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #7 on: April 27, 2011, 06:26:21 pm »
Hi
I have tried V9 but can see no improvement
You are correct when you say that you cannot make the parser understand the macros.
I am manually editing the Qt files as I progress my design, this means that I can use them to generate relationships in model and generate code for my classes (for example I can create a generalisation relationship to show that one of my classes inherits from a QtClass) and so far this approach has served my needs.
I am also developing a MDG for Qt so that I can declare a class to be of type QtObject so that when the code is generated it places the Q_OBJECT macro in the header and derives it from QObject.

Hope this helps
Using V12

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #8 on: April 27, 2011, 06:30:25 pm »
Sounds like a lot of work.
I wish you good luck!

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Class model: Working with external libraries?
« Reply #9 on: April 27, 2011, 06:39:43 pm »
If you can live with just a reference to the base classes (without having them in the model), then right click your sub class and select Parent... and enter the library base class in the dialog.

This class name will then appear in your base class in italics in the top right corner.

Cheers

Phil
Models are great!
Correct models are even greater!

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #10 on: April 27, 2011, 06:48:04 pm »
Phil,

I have been looking for that one for days! I didn't think to look for something I considered so basic in the advanced menu!

Thanks!

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Class model: Working with external libraries?
« Reply #11 on: April 28, 2011, 09:06:44 am »
Contact Sparx Systems support for an MDG technology that will allow import of QT code. It doesn't do anything with signals and slots, but it should at least get you going with an import.

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Class model: Working with external libraries?
« Reply #12 on: April 28, 2011, 05:28:20 pm »
Thanks. I hoped I had just missed a few things, but it looks like Qt integration is beyond the scope of the forums. We will talk this over in the company, and contact support then.

Signals and Slots do not trouble me much right now, because you can't really consider them structural elements anyway (i.e. I don't think they belong into a class diagram). And you can always add relationships that remind you certain classes "talk" to each other.