[gme-users] BON2 ExtenderInterpreter generated code and traversing connections

Thompson, Robert C robert.c.thompson3 at boeing.com
Sat Sep 3 18:23:06 CDT 2005


Hi,

It seems that when the BON2 ExtenderInterpreter generates code for
traversing connectors, it allows (and forces) a developer using the
generated API to specify std::set and std::multiset "2nd template
parameter", which is the comparator used by the template for comparing
elements.

For example, if your metamodel has two classes A,B and a connection
between them "Con", BON2 Extender Interpreter generates something like
the following member function of class A:

class A { 
...
template <class T> std::multiset<B, T> getConDsts (TDP) { ... }
...
}

Now, if I'm utilizing this method somewhere, and I have an instance "a1"
of the BON2-EI-generated class representing "A", the following seems to
work:

B b1 = *(a1->getConDsts<std::less<B> >.begin() );

But the thing is I have to specify the std::less<B> comparator class
template parameter for every invocation of "getConDsts()".

Of course I think I could hand-jam the BON2ExtenderInterpreter and
modify the method definition to specify a default for the parameter
value when I don't specify one:

template <class T=std::less<B> > std::multiset<B, T> getConDsts (TDP) {
... }

The problem is I have quite a few of these in my metamodel that I'd have
to manually update every time I re-gen with the Extender Interpreter.
Not a show-stopper but slightly akward in terms of the overall process.

My questions are: 

A) Is there something I could do differently to get around this, am I
missing something?
B) What's the rationale for exposing that "comparator" template
parameter for specification by the call-site?
C) What's the rationale for the generated code not specifying a
"default" such that the call-site doesn't _have_ to specify a template
parameter value?
D) Would something like "C" be considered beneficial by anyone else?

Thanks
-ace
Ace Thompson
Systems and Software Engineer
FCS LSI C4ISR Battle Command
robert.c.thompson3 at boeing.com
+1 480 891 2284
The Boeing Company




More information about the gme-users mailing list