1 /*******************************************************************************
\r
2 * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.
\r
3 * All rights reserved. This program and the accompanying materials
\r
4 * are made available under the terms of the Eclipse Public License v1.0
\r
5 * which accompanies this distribution, and is available at
\r
6 * http://www.eclipse.org/legal/epl-v10.html
\r
9 * VTT Technical Research Centre of Finland - initial API and implementation
\r
10 *******************************************************************************/
\r
11 package org.simantics.simulation.data;
\r
13 import java.util.Collection;
\r
14 import java.util.concurrent.Executor;
\r
15 import java.util.concurrent.locks.Lock;
\r
17 import org.simantics.databoard.binding.Binding;
\r
18 import org.simantics.databoard.binding.NumberBinding;
\r
19 import org.simantics.databoard.type.Datatype;
\r
20 import org.simantics.databoard.util.Bean;
\r
23 * Interface for adapting data provider to HistoryCollector.
\r
25 * @author Toni Kalajainen
\r
27 public interface Datasource {
\r
29 Collection<String> getVariables();
\r
30 Datatype getType(String key);
\r
32 void addListener(DatasourceListener listener);
\r
33 void removeListener(DatasourceListener listener);
\r
36 * Try to open a handle to a variable
\r
39 * the subscription item to open a handle for
\r
41 * requested handle address, should equal
\r
42 * SubscriptionItem#variableId
\r
43 * @param valueBinding
\r
44 * binding for handling the requested value
\r
45 * @return Variable Handle or <code>null</code> if handle cannot be resolved
\r
48 VariableHandle openHandle(Bean item, String key, Binding valueBinding);
\r
50 public interface DatasourceListener {
\r
53 * When listeners are processed, the data source does not proceed.
\r
54 * It is locked, but this is valid only for listeners with executor
\r
55 * as null. Values are typically read within a listener.
\r
59 void onStep(Datasource source);
\r
62 * Get executor where listener is handled.
\r
63 * If returned value is null, listener is handled synchronously in
\r
68 Executor getExecutor();
\r
72 // The following methods produce sensible values only when the source
\r
73 // is locked or within listener (when it is locked).
\r
76 Object getTime(NumberBinding binding);
\r