--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007 VTT Technical Research Centre of Finland and others.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.simulation.data;\r
+\r
+import java.util.Collection;\r
+import java.util.concurrent.Executor;\r
+import java.util.concurrent.locks.Lock;\r
+\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.NumberBinding;\r
+import org.simantics.databoard.type.Datatype;\r
+import org.simantics.databoard.util.Bean;\r
+\r
+/**\r
+ * Interface for adapting data provider to HistoryCollector.\r
+ * \r
+ * @author Toni Kalajainen\r
+ */\r
+public interface Datasource {\r
+ \r
+ Collection<String> getVariables();\r
+ Datatype getType(String key);\r
+ Lock readLock();\r
+ void addListener(DatasourceListener listener);\r
+ void removeListener(DatasourceListener listener);\r
+\r
+ /**\r
+ * Try to open a handle to a variable\r
+ * \r
+ * @param item\r
+ * the subscription item to open a handle for\r
+ * @param key\r
+ * requested handle address, should equal\r
+ * SubscriptionItem#variableId\r
+ * @param valueBinding\r
+ * binding for handling the requested value\r
+ * @return Variable Handle or <code>null</code> if handle cannot be resolved\r
+ * for any reason\r
+ */\r
+ VariableHandle openHandle(Bean item, String key, Binding valueBinding);\r
+ \r
+ public interface DatasourceListener {\r
+ \r
+ /**\r
+ * When listeners are processed, the data source does not proceed.\r
+ * It is locked, but this is valid only for listeners with executor\r
+ * as null. Values are typically read within a listener.\r
+ * \r
+ * @param source\r
+ */\r
+ void onStep(Datasource source);\r
+ \r
+ /**\r
+ * Get executor where listener is handled.\r
+ * If returned value is null, listener is handled synchronously in \r
+ * current thread.\r
+ * \r
+ * @return\r
+ */\r
+ Executor getExecutor();\r
+ }\r
+\r
+ //\r
+ // The following methods produce sensible values only when the source\r
+ // is locked or within listener (when it is locked).\r
+ // \r
+ \r
+ Object getTime(NumberBinding binding);\r
+\r
+}\r
+\r