public override FilterStateResult traverse(FilterEnv in_env) { FilterStateResult result = new FilterStateResult(); current_env = in_env.advance(); if (in_features.Count > 0) { out_nodes = filter.process(in_features, current_env); } else if (in_fragments.Count > 0) { out_nodes = filter.process(in_fragments, current_env); } else if (in_nodes.Count > 0) { out_nodes = filter.process(in_nodes, current_env); } FilterState next = getNextState(); if (next != null) { if (out_nodes.Count > 0) { if (next is NodeFilterState) { NodeFilterState state = (NodeFilterState)next; state.push(out_nodes); } else if (next is CollectionFilterState) { CollectionFilterState state = (CollectionFilterState)next; state.push(out_nodes); } out_nodes.Clear(); result = next.traverse(current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } in_features.Clear(); in_fragments.Clear(); in_nodes.Clear(); return(result); }
/** * Instructs this state's Filter to process its input. * * @param env * Runtime processing environment */ public override FilterStateResult traverse(FilterEnv in_env) { FilterStateResult result = new FilterStateResult(); // clone a new environment: current_env = in_env.advance(); FeatureList output = filter.process(in_features, current_env); FilterState next = getNextState(); if (next != null) { if (output.Count > 0) { if (next is FeatureFilterState) { FeatureFilterState state = (FeatureFilterState)next; state.push(output); } else if (next is FragmentFilterState) { FragmentFilterState state = (FragmentFilterState)next; state.push(output); } else if (next is NodeFilterState) { NodeFilterState state = (NodeFilterState)next; state.push(output); } else if (next is CollectionFilterState) { CollectionFilterState state = (CollectionFilterState)next; state.push(output); } result = next.traverse(current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } // clean up in_features.Clear(); return(result); }
public override FilterStateResult signalCheckpoint() { #if TODO FilterStateResult result; FilterState next = getNextState(); if (next != null) { int metering = filter.getMetering(); if (next is FeatureFilterState) { if (features.Count > 0) { FeatureGroups feature_groups; foreach (Feature i in features) { feature_groups[filter.assign(i, current_env)].Add(i); } FeatureFilterState state = (FeatureFilterState)next; result = meterGroups(filter, feature_groups, state, metering, current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } else if (next is FragmentFilterState) { FragmentFilterState state = (FragmentFilterState)next; if (features.Count > 0) { FeatureGroups groups; foreach (Feature i in features) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else if (fragments.Count > 0) { FragmentGroups groups; foreach (Fragment i in fragments) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } else if (next is NodeFilterState) { NodeFilterState state = (NodeFilterState)next; if (features.Count > 0) { FeatureGroups feature_groups; foreach (Feature i in features) { feature_groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, feature_groups, state, metering, current_env); } else if (fragments.Count > 0) { FragmentGroups groups; foreach (Fragment i in fragments) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else if (nodes.Count > 0) { NodeGroups groups; foreach (AttributedNode i in nodes) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } else if (next is CollectionFilterState) { CollectionFilterState state = (CollectionFilterState)next; if (features.Count > 0) { FeatureGroups feature_groups; foreach (Feature i in features) { feature_groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, feature_groups, state, metering, current_env); } else if (fragments.Count > 0) { FragmentGroups groups; foreach (Fragment i in fragments) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else if (nodes.Count > 0) { NodeGroups groups; foreach (AttributedNode i in nodes) { groups[filter.assign(i, current_env)].Add(i); } result = meterGroups(filter, groups, state, metering, current_env); } else { result.set(FilterStateResult.Status.STATUS_NODATA, filter); } } if (result.isOK()) { result = next.signalCheckpoint(); } } // clean up the input: features.Clear(); fragments.Clear(); nodes.Clear(); current_env = null; return(result); #endif throw new NotImplementedException(); }