Book a Demo

Author Topic: class template parameters via automation interface  (Read 21139 times)

LurkingGrue

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
class template parameters via automation interface
« on: July 02, 2009, 02:44:55 pm »
On the Details tab of the Class Properties dialog, there is an area for adding parameters to a class. How can I access this information from the automation interface?

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: class template parameters via automation inter
« Reply #1 on: July 02, 2009, 10:05:58 pm »
The information is stored in one of the PDATA fields of the schema (in the t_object table). The EA API accesses these fields via the MiscData attributes of Element. Unfortunately these are read-only attributes in the API.

There is often some way to get around this restriction. Often EA exposes some other mechanism to set values in these fields. The means to do this vary with the type of element and information involved. There is usually no documentation and you take the risk that the mechanism may change in the future.

My suggestion - I have not tried this myself - is to see if you can access the information via the CustomProperties or Properties collections of the Element class.

If that does not work you may have to write your own routine to tweak these fields in the underlying database, through OLEDB or some other means outside of the EA API. Be very careful if you do this. You risk trashing other information in the fields, and are doing this at your own risk.
No, you can't have it!

LurkingGrue

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: class template parameters via automation inter
« Reply #2 on: July 11, 2009, 03:49:58 pm »
Thanks, Midnight!  The parametrized class info was available via the get_MiscData(2) method. Here is an example with two parameters, T and C:

Code: [Select]
<PRM1>=T;<TYP1>=string;<DEF1>=helloWorld;<PRM2>=C;<TYP2>=int;<DEF2>=13;
Unfortunately, it is read-only as you indicated, and it is not accessible via Properties or CustomProperties either.  I'm hesitant to try anything else, but at least I have read-only access for now.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: class template parameters via automation inter
« Reply #3 on: July 12, 2009, 12:11:14 am »
As you suspect there is no direct way to manipulate the MiscData fields from the API.

That does not necessarily mean you cannot move forward though. The two approaches I mentioned earlier could each work. I'd try them in the order I mentioned above.

First try tweaking other settings via the API, using the UI as a guideline (i.e. if setting 'something' by hand affects the class parameters, try finding other references to the same 'something' in the API. Sometimes these are a bit subtle so it can take some digging. Unfortunately there might not be any such indirect approach, and you simply cannot tell whether the workaround is obscure or nonexistent until you try pretty much everything.

Failing that you will have to write a second logic stream that handles this via OLEDB (or some other concurrent access). You should be very careful to tweak only that portion of the MiscData contents (it is a memo field) that apply to the parameters. Make sure you preserve all the surrounding text as well as the delimiters (the semicolons) Note that the trailing semicolon is significant (i.e. don't forget it when you assemble the string).
No, you can't have it!