Book a Demo

Author Topic: Deriving a class from a language provided class  (Read 3113 times)

seckley

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Deriving a class from a language provided class
« on: August 11, 2010, 10:20:27 pm »
Hi ;
I'm working on a class model and trying to figure out how to derive a class from a language provided class. i am working with Qt and quite a few classes are derived from the Qt provided classes: QObject, QWidget...
How can i specify, in the class i am creating what it is derived from, without having to add a class object for the Qt objects? we are building a Qt language template so we can generate Qt based classes and need to be able to specify certain items if a class is derived from QObject. ANy ideas?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Deriving a class from a language provided clas
« Reply #1 on: August 11, 2010, 11:36:09 pm »
I don't think you can without reverse engineering the QT library.

Geert

Bruce Knowles

  • EA Novice
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
Re: Deriving a class from a language provided clas
« Reply #2 on: August 15, 2010, 10:52:30 pm »
HI,

Actually, there is a quick and dirty method for implementing something like this. It does however come with short falls, and is not necessarily a general solution for all development languages, but will work just fine for C++ (and presumably C# and Java as well).

To investigate this I generated a new simple model and selected only to generate a Class Model region. After opening the System diagram I selected the Class3 class and then right clicked it. On the popup menu I selected Advanced->Parent (or use short cut CTL-I). This pops up a 'Set Parents and Interaces' Dialogue box.

In the class name - define the class name that you wish to Generalize. Make sure the Type drop down list is seleted to 'Generalizes', ensure the Accept classifier even if not in model check box is ticked and the click the Add button followed by the Close button....

Its as simple as that.

There is supplemental work that will be needed here though. You must ensure that in the Forward generation dialogue box (F11) the correct import libraries are included using the correct syntax.

You may also need to ensure that the name of the class you generalize is defined using the full namespace definition as well.

If not... you could have an easy time with modelling here, but building the solution will be a tad awkward.