[gme-users] Use of BON Extender

Kevin Smyth ksmyth at isis.vanderbilt.edu
Thu Aug 6 16:13:14 CDT 2009


>
> 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? 
Downcasting would be unnecessary. 'accept' is 'virtual,' so 
(*it)->accept(pVisitor) should invoke the 'accept' method of the FCO's 
actual class.

> 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);
>   
I suspect you want object->accept(xman_visitor);

Kevin




Ioannis Ntalamagkas wrote:
> 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
>
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
>   

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3273 bytes
Desc: S/MIME Cryptographic Signature
Url : http://list.isis.vanderbilt.edu/pipermail/gme-users/attachments/20090806/8ca87b92/attachment.bin 


More information about the gme-users mailing list