[great-users] return connected objects ordered by an attribute value

Belschner, Tim tim.belschner at ils.uni-stuttgart.de
Mon Mar 30 02:49:06 CDT 2015


If anyone should struggle with the same issue, here is an example:

 
struct cmp_SequenceID {

  bool operator() (const DataflowDSL::Operation& lhs, const DataflowDSL::Operation& rhs) const

  {return lhs.SequenceID()<rhs.SequenceID();}

};

 
cmp_SequenceID cmp_SeqID;

 
std::set<DataflowDSL::Operation, cmp_SequenceID> found_Operation = Data_IN.clDataOperationdst_sorted(cmp_SeqID);

for(std::set<DataflowDSL::Operation, cmp_SequenceID>::const_iterator it_found_Operation = found_Operation.begin(); it_found_Operation != found_Operation.end(); ++it_found_Operation)

{

       cout << it_found_Operation->name() << std::endl;

}

 
 
 
Von: great-users-bounces at list.isis.vanderbilt.edu [mailto:great-users-bounces at list.isis.vanderbilt.edu] Im Auftrag von Belschner, Tim
Gesendet: Mittwoch, 25. März 2015 15:54
An: 'A list for GReAT users to share bugs, fixes and ideas'
Betreff: [great-users] return connected objects ordered by an attribute value

 
Hello everybody,

 
during a transformation I stick some model objects “Operation” with a crosslink “clDataOperation” to the model object “Data_IN”. In my last rule, I pass in the “Data_IN” object and would like to get all connected “Operation” objects in a set, so that I can iterate through. The solution is pretty simple:

########## CODE BEGIN #############

set< DataflowDSL::Operation> Found_Operations= Data_IN.clDataOperationdst();

for(set< DataflowDSL::Operation>::const_iterator it1= Found_Operations.begin(); it1 != Found_Operations.end(); ++it1)

{

       cout << it1->name() << std::endl;

}

########## CODE END #############

 
Now, I would like to order the “Operation” objects by the value of their integer attribute “SequenceID”. For this I am using the “_sorted” version of the API call. Unfortunately, I am struggling with the proper call of the function “clDataOperationdst_sorted”, especially the correct declaration of “Pred”.

Here is what I got so far:

########## CODE BEGIN #############

Udm::CrossAssocAttr< DataflowDSL::Operation, Pred> > Found_Operations= Data_IN.clDataOperationdst_sorted( &DataflowDSL::Operation::SequenceID );

########## CODE END #############

 
Could someone please give me an example how the “_sorted” version has to be called in a correct way?

 
Thanks in advance and best regards

Tim

 

_______________________________________________



great-users mailing list



great-users at list.isis.vanderbilt.edu <mailto:great-users at list.isis.vanderbilt.edu> 



http://list.isis.vanderbilt.edu/mailman/listinfo/great-users <http://list.isis.vanderbilt.edu/mailman/listinfo/great-users> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://list.isis.vanderbilt.edu/pipermail/great-users/attachments/20150330/a6e3f6e4/attachment.html 


More information about the great-users mailing list