| // ***************************************************************************** |
| // Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // which accompanies this distribution, and is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| // |
| // Contributors: |
| // Pierre Allard - initial API and implementation |
| // Regent L'Archeveque |
| // |
| // SPDX-License-Identifier: EPL-1.0 |
| // ***************************************************************************** |
| |
| @GenModel(prefix="ApogyCommonProcessors", |
| childCreationExtenders="true", |
| extensibleProviderFactory="true", |
| multipleEditorPages="false", |
| copyrightText="******************************************************************************* |
| Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency |
| All rights reserved. This program and the accompanying materials |
| are made available under the terms of the Eclipse Public License v1.0 |
| which accompanies this distribution, and is available at |
| http://www.eclipse.org/legal/epl-v10.html |
| |
| Contributors: |
| Pierre Allard - initial API and implementation |
| Regent L'Archeveque |
| |
| SPDX-License-Identifier: EPL-1.0 |
| *******************************************************************************", |
| modelName="ApogyCommonProcessors", |
| suppressGenModelAnnotations="false") |
| @GenModel(dynamicTemplates="true", templateDirectory="platform:/plugin/org.eclipse.apogy.common.emf.codegen/templates") |
| @GenModel(modelDirectory="/org.eclipse.apogy.common.processors/src-gen") |
| @GenModel(editDirectory="/org.eclipse.apogy.common.processors.edit/src-gen") |
| |
| package org.eclipse.apogy.common.processors |
| |
| // Types |
| import org.eclipse.apogy.common.Apogy |
| |
| type IProgressMonitor wraps org.eclipse.core.runtime.IProgressMonitor |
| type Exception wraps Exception |
| |
| /** |
| * Represent a object for which operation progress can be reported. |
| */ |
| interface Monitorable |
| { |
| /** |
| * IProgressMonitor used to report progress. |
| */ |
| @GenModel(property="None") |
| transient IProgressMonitor progressMonitor |
| } |
| |
| /** |
| * Defines an object that can process an input to get an output. |
| */ |
| @Apogy(hasCustomClass="true") |
| abstract class Processor<I , O> extends Monitorable |
| { |
| /** |
| * The input. |
| */ |
| transient I input |
| |
| /** |
| * The output. Updates when the process(I input) method is called. |
| */ |
| transient O output |
| |
| /** |
| * Process the input and produces an output. |
| * @param input The input. |
| * @return The output. |
| * @throws An exception if the processing fails. |
| */ |
| op O process(I input) throws Exception |
| } |
| |
| /** |
| * Defines a processor that is implemented as a chain of processors. |
| */ |
| @Apogy(hasCustomClass="true") |
| class ProcessorsChain<I , O> extends Processor < I , O > |
| { |
| /** |
| * The intermediate result of the processor chain. |
| */ |
| Object intermediateResult |
| |
| /** |
| * The current processor being run. This changes as the processor are called one after the other when the process(I input) method is called. |
| */ |
| refers Processor < ? , ? >[1] runningProcessor |
| |
| /** |
| * The list of processors that make up the chain. Processor are chained in the order they are found in this list. |
| */ |
| refers Processor < ? , ? >[] processors |
| } |
| |
| /** |
| * A processor chain where the process(I input) method is run in a Job. |
| */ |
| @Apogy(hasCustomClass="true") |
| class JobProcessorsChain<I , O> extends ProcessorsChain < I , O > |
| { |
| } |