[gme-users] Use of BON Extender

Ioannis Ntalamagkas i.ntalamagkas at cs.manchester.ac.uk
Tue Aug 4 06:35:31 CDT 2009


Hello,


I am having a problem into using the BON extender correctly for our 
meta-model. The story is as follows::

We are trying to define an interpreter for our meta-model which we call 
XMAN_META. We use the BON Extender that correctly generates all 
meta-classes (XMAN_META_CLASSES). We also generate XMANVisitor and 
populate its methods accordingly. We then build the interpreter 
component using BON II. Inside the InvokeEx method we are doing:

> XMANVisitor * xman_visitor = new XMANVisitor();
>
> std::set<FCO>::const_iterator it = setSelectedFCOs.begin();
> (*it)->accept(xman_visitor);
This does not work because the type of the selected FCO is a META_GME 
type (FCOBase or something) and not of type XMAN_META_CLASSES. To force 
the latter, we changed our code to:

> 1: XMANVisitor * xman_visitor = new XMANVisitor();
>
> 2: std::set<FCO>::const_iterator it = setSelectedFCOs.begin();
> 3: XMAN_BON::SomeType object = XMAN_BON::SomeType(*it);
> 4: (*it)->accept(xman_visitor);
In the third line we construct an object of XMAN_META_CLASSES type. Now 
the visitor correctly visits the object, but it does not visit its 
children(!!).

We suspect that the reason is the auto-generated code of SomeTypeImpl's 
accept method. For convenience I quote it below:
>  
>     void XMAN_BON::SomeTypeImpl::accept( XMAN_BON::XMANVisitor *pVisitor){
>
>     // visit the XMAN_BON::SomeType - THIS WORKS FINE
>     pVisitor->visitSomeType( XMAN_BON::SomeType( this));
>  
>     // NOW THIS DOES NOT WORK
>     std::set<BON::FCO> children = ModelImpl::getChildFCOs();
>     for( std::set<BON::FCO>::const_iterator it = children.begin(); it 
> != children.end(); ++it)
>     {
>         (*it)->accept( pVisitor);
>     }
> }
In the second part of the accept method, should it not automatically 
down-cast the FCOs children of "SomeType" to the correct 
XMAN_META_CLASSES type? Actually this for-loop should be more 
complicated so that it automatically down-casts the FCOs children of 
"SomeType" to the correct sub-type? Is there something wrong in my 
understanding? Am I not using BON_Extender in the correct way? Any 
advice is appreciated.


Thank you,
Yannis



More information about the gme-users mailing list