[gme-users] Ordering of sets in Bon

Zoltan Molnar zoltan.molnar at vanderbilt.edu
Fri Apr 30 13:03:11 CDT 2004


Hi,

Yes I tried it out (even with the latest service pack 6).
The compiler fails when you have a template method inside a class and would
like to invoke it specialized.
Global template methods can be invoked specialized without problem.

Thanks for the suggestion
Br, Zoli

> -----Original Message-----
> From: gme-users-bounces at list.isis.vanderbilt.edu 
> [mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
> Of Jacques Kerner
> Sent: Friday, April 30, 2004 10:42 AM
> To: A list for GME users to share thoughts and discuss bugs and fixes.
> Subject: Re: [gme-users] Ordering of sets in Bon
> 
> 
> Hi Zoltan,
> 
> You tried the code on Visual 6 and it did not compile ? Too bad...
> 
> Otherwise, my other guess would rather be to have something 
> like (almost 
> the same as you suggested) :
> 
> std::set<B, BComparison>   bSet = b->getB( BComparison() )
> 
> I think it would be more logical to pass the comparison class as an 
> argument rather that the set. Would that work with visual 6 ? 
> This would 
> give you this declaration code :
> 
> template <class T>
> std::set<B, T> AImpl::getB(const T & aComparison)
> {
>     std::set<B, T> res;
>     std::set<BON::FCO> roles = getChildFCOsAs("B");
>     for( std::set<BON::FCO>::iterator i = roles.begin(); i != 
> roles.end(); ++i)
>     {
>         TypeReference elem(*i);
>         ASSERT(elem);
>         res.insert(elem);
>     }
>     return res;
> }
> 
> I tested it on Visual 7.1 and it works fine, but of course 
> you need to test it on Visual 6 (I don't have it on my machine).
> 
> Also, I will try to find if there are no workaround for 
> template specialization on Visual 6, and tell you if I find 
> such things...
> 
> Jacques Kerner.
> 
> 
> 
> Zoltan Molnar a écrit :
> 
> >Hi,
> >
> >Unfortunately VC6.0 doesn't support the specialization 
> >"getB<Bcomparison>" in
> >std::set<B, BComparison>    bSet    =    b->getB<BComparison>();
> >
> >But a version like this is accepted by vc6, (it doesn't require the
> >specialization)
> >std::set<B, BComparison>    bSet    =    b->getB( bSet);
> >
> >Would it be OK?
> >
> >Zoli
> >
> >  
> >
> >>-----Original Message-----
> >>From: gme-users-bounces at list.isis.vanderbilt.edu
> >>[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf 
> >>Of Jacques Kerner
> >>Sent: Tuesday, April 20, 2004 8:26 AM
> >>To: A list for GME users to share thoughts and discuss bugs 
> and fixes.
> >>Subject: Re: [gme-users] Ordering of sets in Bon
> >>
> >>
> >>Hi, it's me again, on ordering (sorry).
> >>
> >>I would still like to suggest an additional generated
> >>function to allow 
> >>the user to specify how a returned set should be ordered. 
> >>Note that my 
> >>suggestion does not break the current API.
> >>
> >>For instance, let's suppose we have Model "A" that can
> >>aggregate Atoms 
> >>"B". What the BONExtender generates is :
> >>
> >>class AImpl :
> >>  virtual public BON::ModelImpl
> >>{
> >>public:
> >>    std::set<B> getB();
> >>};
> >>
> >>and
> >>
> >>std::set<B> AImpl::getB()
> >>{
> >>    std::set<B> res;
> >>    std::set<BON::FCO> roles = getChildFCOsAs("B");
> >>    for( std::set<BON::FCO>::iterator i = roles.begin(); i !=
> >>roles.end(); ++i)
> >>    {
> >>        TypeReference elem(*i);
> >>        ASSERT(elem);
> >>        res.insert(elem);
> >>    }
> >>    return res;
> >>}
> >>
> >>ordering is done in the insert function, and uses the operator< that
> >>relies on the reference counter to compare two fcos. I suggest the 
> >>addition of the following template function to the AImpl 
> >>class declaration:
> >>
> >>template <class T>
> >>std::set<B, T> AImpl::getB()
> >>{
> >>    std::set<B, T> res;
> >>    std::set<BON::FCO> roles = getChildFCOsAs("B");
> >>    for( std::set<BON::FCO>::iterator i = roles.begin(); i !=
> >>roles.end(); ++i)
> >>    {
> >>        TypeReference elem(*i);
> >>        ASSERT(elem);
> >>        res.insert(elem);
> >>    }
> >>    return res;
> >>}
> >>
> >>Adding this function allows the user to use his own 
> comparison Trait :
> >>
> >>std::set<B, BComparison>    bSet    =    b->getB<BComparison>();
> >>
> >>with, for instance, a Comparison class based on the x coordinate in
> >>"MyAspect" aspect.
> >>
> >>    class BComparison
> >>    {
> >>    public:
> >>        //! This method orders two Bs with respect to their x
> >>coordinate 
> >>in the diagram
> >>        /** (thanks to Peter Volgyesi for the trick... :)
> >>        */
> >>        bool operator()(
> >>            const B& _Left,
> >>            const B& _Right
> >>        ) const
> >>        {
> >>            return 
> >>(_Left->getRegistry()->getLocation("MyAspect").first 
> >>< _Right->getRegistry()->getLocation("MyAspect").first);
> >>        }
> >>    };
> >>
> >>or whatever Trait the user defines for his own needs.
> >>
> >>Again, please note that my suggestion does not break the 
> current API,
> >>since the user can still call the regular untemplated 
> getB() method. 
> >>Furthermore, this does not imply any additional performance 
> >>cost other 
> >>than implied by the user comparison function. Using this 
> >>avoids the need 
> >>to reorder the sets after they have been recovered. If the 
> >>user wants to 
> >>get the set as fast as possible, she uses the untemplated 
> >>getB() method, 
> >>but if she wants to order it in her own way, this is still 
> >>faster that 
> >>getting the set and THEN reordering it.
> >>
> >>I have succesfully tested this method with GME 4.3.17, with
> >>Visual 7.1. 
> >>Hoping there are no issues with this that I am anaware of ...
> >>
> >>Best Regards,
> >>
> >>Jacques Kerner.
> >>
> >>Peter Volgyesi a écrit :
> >>
> >>    
> >>
> >>>Hi,
> >>>
> >>>Collections coming from the model database are never
> >>>      
> >>>
> >>ordered. (This is
> >>    
> >>
> >>>a property of our modeling engine and not BON specific, and it is
> >>>because of internal caching mechanisms.) One can argue, 
> why don't we 
> >>>order these lists, however it seems a better (general) 
> >>>      
> >>>
> >>approach to me
> >>    
> >>
> >>>to provide data as fast as possible that can be sorted by the upper
> >>>layers on demand.
> >>>
> >>>Anyway, the MONTraverser interpreter (Paradigms/MetaGME 
> folder) does
> >>>implement some kind of sorting (MONDialog.cpp). Feel free to 
> >>>      
> >>>
> >>use that
> >>    
> >>
> >>>code.
> >>>
> >>>For retrieving graphical position of an object in a given
> >>>      
> >>>
> >>aspect, use
> >>    
> >>
> >>>this:
> >>>fco->getRegistry()->getLocation("AspectName");
> >>>
> >>>fco must be a BON FCO object (eg.: BON::Atom)
> >>>
> >>>Regards,
> >>>
> >>>--
> >>>peter
> >>>
> >>>
> >>> 
> >>>
> >>>      
> >>>
> >>>>-----Original Message-----
> >>>>From: gme-users-bounces at list.isis.vanderbilt.edu
> >>>>[mailto:gme-users-bounces at list.isis.vanderbilt.edu] On Behalf
> >>>>Of Jacques Kerner
> >>>>Sent: Tuesday, April 06, 2004 9:45 AM
> >>>>To: A list for GME users to share thoughts and discuss bugs 
> >>>>        
> >>>>
> >>and fixes.
> >>    
> >>
> >>>>Subject: [gme-users] Ordering of sets in Bon
> >>>>
> >>>>Hi,
> >>>>
> >>>>I would like to know how the std::set<...> returned by 
> BONExtender 
> >>>>generated functions are ordered. For instance, I have a 
> model named 
> >>>>"Container" that aggregates "Contained" Atoms "contained1", 
> >>>>"contained2" and "contained3" and I was uable to figure 
> out how the
> >>>>ordering was made. Sometimes the order is by creation of the 
> >>>>contained elements, sometimes not, ...
> >>>>
> >>>>Is there a way to impose the ordering on the returned sets ? Do I 
> >>>>have to define a specific operator < for this ? Could BonExtender 
> >>>>generate one from a rule in the meta model ?
> >>>>
> >>>>I also wondered if one can retrieve the position of elements in 
> >>>>diagrams in BON .
> >>>>
> >>>>Thank you in advance.
> >>>>
> >>>>Jacques Kerner. _______________________________________________
> >>>>gme-users mailing list
> >>>>gme-users at list.isis.vanderbilt.edu
> >>>>http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> >>>>   
> >>>>
> >>>>        
> >>>>
> >>>_______________________________________________
> >>>gme-users mailing list
> >>>gme-users at list.isis.vanderbilt.edu
> >>>http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> >>>
> >>> 
> >>>
> >>>      
> >>>
> >>_______________________________________________
> >>gme-users mailing list
> >>gme-users at list.isis.vanderbilt.edu
> >>http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> >>
> >>    
> >>
> >
> >_______________________________________________
> >gme-users mailing list
> >gme-users at list.isis.vanderbilt.edu
> >http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> >
> >  
> >
> _______________________________________________
> gme-users mailing list
> gme-users at list.isis.vanderbilt.edu
> http://list.isis.vanderbilt.edu/mailman/listinfo/gme-users
> 



More information about the gme-users mailing list