Book a Demo

Author Topic: typedef template binding code generation error  (Read 6029 times)

aaron1993

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
typedef template binding code generation error
« on: July 08, 2014, 07:42:16 am »
Hi all,

Alright, so, here's the gist of my issue. I'm attempting to rework my code templates in EA so that the format is as consistent with my work's coding standard as possible. Here's the problem I've run in to. I have a typedef that I want to be of type SmartPtr :: Ptr <type T >, so I add the appropriate template bindings to it. The namespace path of the SmartPtr is SmartPtr :: Ptr. Then, after I add the template bindings, when I click properties of the typedef and go to templates, the appropriate binding is there, but it says the target is merely "Ptr". And, consequentially, when I generate code, the typedef is merely of type "Ptr". However, when I click the binding in the template options mentioned previously and click "edit" a dialog pops up saying the target of the template binding is "SmartPtr :: Ptr".

So, why is it telling me the typedef has two different template binding targets? And how can I get the code generation to actually display the second, more complete one?

Any help?

Thanks,
Aaron
« Last Edit: July 08, 2014, 07:43:58 am by aaron1993 »

aaron1993

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: typedef template binding code generation error
« Reply #1 on: July 09, 2014, 08:44:49 am »
Ok, so, I've given up on doing it through the code generation templates, and I've decided to just write an addin to generate the proper namespace. The only problem is that, it seems, the EA addin API is very limited when it comes to accessing element properties. I've been trying all day to find out how to access the highlighted element on a connector from the EA addin API. I've iterated through the connector properties with no success. Any help locating the highlighted field. Have I missed some access command?


Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: typedef template binding code generation error
« Reply #2 on: July 09, 2014, 10:51:32 am »
You would need to construct this string based on the model structure.  I believe "Ptr" is the name of the class at the target end of the connector (see: Connector.SupplierID), the "SmartPtr::" part is the namespace that this target class belongs to.  The namespace is defined by the hierarchy of packages that own the class.  To get the namespace, you will need to traverse up the hierarchy to get the name of each package until you hit one that is flagged as a "Namespace Root" (Package.IsNamespace).

E.g.
  Class Model (Namespace Root)
    SmartPtr (Package)
      Ptr (Class)

The Namespace Root indicates that all packages below this point form the namespace.  The Namespace Root itself is not included in the namespace.

aaron1993

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: typedef template binding code generation error
« Reply #3 on: July 10, 2014, 01:34:09 am »
Thanks, Aaron, just what I was looking for.

Now, do you know if there's a way to access the template binding of a connector? I can't seem to find that either. I've checkout properties, conveyed items, custom properties, even tried to get the diagram Id to see if I could just strip the label off to get the name, but apparently it has no Diagram ID.

Cheers,
Aaron