001    package com.hammurapi.reasoning.impl;
002    
003    import org.eclipse.emf.common.util.TreeIterator;
004    import org.eclipse.emf.ecore.EObject;
005    
006    import com.hammurapi.flow.Flow;
007    
008    /**
009     * Optimizes flow by setting inline flag to true for nodes and 
010     * transitions which form a chain and therefore there is no reason
011     * to spawn multiple task for execution of each of them.
012     * @author Pavel Vlasov
013     *
014     */
015    public class IniliningOptimizer implements RuleSetFlowOptimizer {
016    
017            /*
018             * Algorithm:
019             * 1. Iterate over nodes.
020             * 2. If the node has one outbound transition to another node, 
021             *    then mark the transition and the target node as inline..
022             */
023            
024            @Override
025            public void optimize(Flow ruleSetFlow) {                
026                    boolean optimized;
027                    Z: do {
028                            optimized = false;
029                            TreeIterator<EObject> rcit = ruleSetFlow.eAllContents();
030                            while (rcit.hasNext()) {
031                                    EObject next = rcit.next();
032                                    
033                                    throw new UnsupportedOperationException();
034                            }                                               
035                    } while (optimized);            
036            }
037            
038            /**
039             * This optimization shall be executed after transition sharing optimization.
040             */
041            @Override
042            public int getOrder() {
043                    return 20;
044            }
045    
046    }