Book a Demo

Author Topic: Template Specialization  (Read 5316 times)

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Template Specialization
« on: September 04, 2003, 08:19:21 am »
Ok, I'm at wits end here and I just can't figure this out. I'm trying to inherit from a base class that is a template and can't figure out how...

It looks like you can do it from the class "Detail" property page by selecting "instantiated" from the drop down, then fill in the arguments edit. Not only does this not generate any extra C++ code (it simply inherits the base class as if it were not a template) but what if I am inheriting from more than one templated base class? Where do the arguments go for the second, third, etc. base classes?

I've also tried setting various properties of the inherit link to the base class, but this also results in the incorrect (same as above) code being generated.

Oh, I am currently evaluating EA v3.60.637.

Any help would be appreciated...

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Template Specialization
« Reply #1 on: September 04, 2003, 08:09:20 pm »
Hi mitch,

Thanks for the feedback.

I'm assuming you want to generate something like:

class Foo : public Vector<Bar>

(for the single inheritance case)

Currently the default code generation templates don't access the instantiated/arguments fields from the Class Details tab- hence the absence of the arguments in the code.

Hopefully this should be updated within the next couple of builds.

As regards inheriting from multiple template classes, would a possible work around be to instantiate the base template classes and then inherit from the multiple instantiated base classes?  For the longer term, we'll look at supporting a way of modelling such inheritances.

Regards,
Ben

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Template Specialization
« Reply #2 on: September 05, 2003, 04:21:05 am »
Thanks for the reply. I was more thinking I was doing something wrong, but I had tried everything. If the functionality simply isn't in there yet, hey, no prob.

I was pondering doing something (in the code generation) with the names of the inherit links to maybe generate the proper code. I have to wait until the weekend to try this experiment, though...

As for multiple templated base classes, I think that the current UI simply isn't going to do the trick. It is a single edit box where a list is needed. That or move the template instantiation params to the link. Just a few thoughts.

I like this product, though. I can't believe the amount of functionality present at that price. Very impressive.

Thanks again.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Template Specialization
« Reply #3 on: September 10, 2003, 07:41:26 pm »
Hi mitch,

The default c++ code templates have been updated to handle simple cases like:

class Foo : public Vector<Bar>

(The relevant code template now uses the "Arguments" field from the class detail dialogue)

As for inheriting from multiple templated bases- you're right, this will require some UI rework, or we may provide access to tagged values in the inheritance links...

Regards,
Ben

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: Template Specialization
« Reply #4 on: September 11, 2003, 05:35:32 am »
Thank you. That currently helps for most of my cases anyhow, so that saves me from doing it. :)

Later,
SDM