-/*******************************************************************************\r
- * Copyright (c) 2010- Association for Decentralized Information Management in\r
- * Industry THTH ry.\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.databoard.accessor.wire;\r
-\r
-import java.util.LinkedList;\r
-\r
-import org.simantics.databoard.accessor.event.Event;\r
-import org.simantics.databoard.accessor.interestset.InterestSet;\r
-import org.simantics.databoard.accessor.reference.ChildReference;\r
-import org.simantics.databoard.annotations.Optional;\r
-import org.simantics.databoard.binding.mutable.MutableVariant;\r
-import org.simantics.databoard.type.Datatype;\r
-\r
-public interface IWireServer {\r
- \r
- /**\r
- * Open a handle to an accessor. \r
- * \r
- * @param ref accessor refence or <code>null<code> for root\r
- * @return accessor info\r
- * @throws WireException\r
- */\r
- AccessorInfo openAccessor(ChildReference ref) throws WireException;\r
- \r
- static class AccessorInfo {\r
- public int accessorId;\r
- public Datatype type;\r
- }\r
- \r
- /**\r
- * Close a group of accessor handles.\r
- * Open listener and lock handles are released.\r
- * \r
- * @param accIds accessor ids\r
- */\r
- int closeAccessors(Integer[] accIds) throws WireException;\r
- \r
- /**\r
- * Acquire mutual-exclusive write lock, and optionally read lock.\r
- * The lock covers the node and its sub-tree.\r
- * \r
- * Lock prevents access from other wire clients.\r
- * \r
- * @param accId\r
- * @param readLock\r
- * @param timeout in milliseconds, -1 = infinite\r
- * @return lockId, or -1 if failed \r
- */\r
-// int requestLock(int accId, boolean readLock, long timeout) throws WireException;\r
- \r
- /**\r
- * Release lock\r
- * \r
- * @param lockId\r
- */\r
-// void releaseLock(int lockId);\r
-\r
- /**\r
- * Read the value as whole.\r
- * \r
- * If accessor is locked, read operation delays until lock\r
- * is released.\r
- * \r
- * @param accId\r
- * @return value\r
- * @throws WireException \r
- */\r
- MutableVariant getValue(int accId) throws WireException;\r
- \r
- /**\r
- * Apply a list of changes to the node.\r
- * \r
- * If rollback is true, a rollback log is returned.\r
- * Rollback log is a list of events that revert modifications\r
- * if applied.<p> \r
- * \r
- * In case of error rollback log is filled with\r
- * events that counter modification that were already applied\r
- * before the error occured.<p> \r
- * \r
- * @param accId\r
- * @param changeSet\r
- * @param rollback\r
- * @return apply result\r
- */\r
- ApplyResult apply(int accId, Event[] changeSet, boolean rollback);\r
- \r
- public static class ApplyResult {\r
- public @Optional WireException error;\r
- public @Optional LinkedList<Event> rollbackLog;\r
- }\r
-\r
- /**\r
- * Create listener \r
- * \r
- * @param accId\r
- * @param interestSet\r
- * @param pathPrefix\r
- * @return lisId\r
- * @throws WireException\r
- */\r
- int addListener(int accId, InterestSet interestSet, ChildReference pathPrefix) throws WireException;\r
- \r
- /**\r
- * Remove listener \r
- * \r
- * @param lisId\r
- * @throws WireException\r
- */\r
- int removeListener(int lisId) throws WireException;\r
- \r
- // Array, Map, Record, Union\r
- /**\r
- * Get size of an array, map, record or union\r
- * \r
- * @param accId\r
- * @throws WireException\r
- */\r
- int size(int accId) throws WireException;\r
- \r
- /**\r
- * Remove all array or map elements\r
- * \r
- * @param accId\r
- * @throws WireException\r
- */\r
- int clear(int accId) throws WireException;\r
-\r
- boolean containsKey(int accId, MutableVariant key) throws WireException;\r
- boolean containsValue(int accId, MutableVariant value) throws WireException;\r
- MutableVariant getFirstKey(int accId) throws WireException;\r
- MutableVariant getLastKey(int accId) throws WireException;\r
- MutableVariant getLowerKey(int accId, MutableVariant key) throws WireException;\r
- MutableVariant getFloorKey(int accId, MutableVariant key) throws WireException;\r
- MutableVariant getCeilingKey(int accId, MutableVariant key) throws WireException;\r
- MutableVariant getHigherKey(int accId, MutableVariant key) throws WireException;\r
-\r
- /**\r
- * Get map entry value\r
- * \r
- * @param accId\r
- * @param key\r
- * @return value\r
- * @throws WireException\r
- */\r
- MutableVariant getMapValue(int accId, MutableVariant key) throws WireException;\r
- \r
- /**\r
- * Get map values as array\r
- * \r
- * @param accId\r
- * @return values in array inside a variant\r
- * @throws WireException\r
- */\r
- MutableVariant getMapValues(int accId) throws WireException;\r
- \r
- /**\r
- * Get map keys as array\r
- * \r
- * @param accId\r
- * @return keys in array inside a variant\r
- * @throws WireException\r
- */\r
- MutableVariant getMapKeys(int accId) throws WireException;\r
- \r
- // Optional\r
- /**\r
- * Get value status of an Optional node\r
- * \r
- * @param accId\r
- * @return <code>true</code> if there is value in the node \r
- * @throws WireException \r
- */\r
- boolean hasValue(int accId) throws WireException;\r
- \r
- // Union\r
- /**\r
- * Get tag index of a Union node\r
- * \r
- * @param accId\r
- * @return tag index\r
- * @throws WireException \r
- */\r
- int getTag(int accId) throws WireException;\r
- \r
- // Array\r
- \r
- /**\r
- * add objects to array\r
- * \r
- * @param accId\r
- * @param index insert pos, -1 = at the end\r
- * @param array\r
- * @return actual insert pos\r
- */\r
- int addAll(int accId, int index, MutableVariant array) throws WireException;\r
- \r
- /**\r
- * \r
- * @param accId\r
- * @param index insert pos, -1 = at the end\r
- * @param object\r
- * @return actual insert pos\r
- * @throws WireException\r
- */\r
- int add(int accId, int index, MutableVariant object) throws WireException;\r
- \r
- /**\r
- * Get array element value\r
- * \r
- * @param accId\r
- * @param index\r
- * @return value\r
- * @throws WireException\r
- */\r
- MutableVariant getArrayElement(int accId, int index) throws WireException; \r
- \r
-}\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2010- Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * 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:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.databoard.accessor.wire;
+
+import java.util.LinkedList;
+
+import org.simantics.databoard.accessor.event.Event;
+import org.simantics.databoard.accessor.interestset.InterestSet;
+import org.simantics.databoard.accessor.reference.ChildReference;
+import org.simantics.databoard.annotations.Optional;
+import org.simantics.databoard.binding.mutable.MutableVariant;
+import org.simantics.databoard.type.Datatype;
+
+public interface IWireServer {
+
+ /**
+ * Open a handle to an accessor.
+ *
+ * @param ref accessor refence or <code>null<code> for root
+ * @return accessor info
+ * @throws WireException
+ */
+ AccessorInfo openAccessor(ChildReference ref) throws WireException;
+
+ static class AccessorInfo {
+ public int accessorId;
+ public Datatype type;
+ }
+
+ /**
+ * Close a group of accessor handles.
+ * Open listener and lock handles are released.
+ *
+ * @param accIds accessor ids
+ */
+ int closeAccessors(Integer[] accIds) throws WireException;
+
+ /**
+ * Acquire mutual-exclusive write lock, and optionally read lock.
+ * The lock covers the node and its sub-tree.
+ *
+ * Lock prevents access from other wire clients.
+ *
+ * @param accId
+ * @param readLock
+ * @param timeout in milliseconds, -1 = infinite
+ * @return lockId, or -1 if failed
+ */
+// int requestLock(int accId, boolean readLock, long timeout) throws WireException;
+
+ /**
+ * Release lock
+ *
+ * @param lockId
+ */
+// void releaseLock(int lockId);
+
+ /**
+ * Read the value as whole.
+ *
+ * If accessor is locked, read operation delays until lock
+ * is released.
+ *
+ * @param accId
+ * @return value
+ * @throws WireException
+ */
+ MutableVariant getValue(int accId) throws WireException;
+
+ /**
+ * Apply a list of changes to the node.
+ *
+ * If rollback is true, a rollback log is returned.
+ * Rollback log is a list of events that revert modifications
+ * if applied.<p>
+ *
+ * In case of error rollback log is filled with
+ * events that counter modification that were already applied
+ * before the error occured.<p>
+ *
+ * @param accId
+ * @param changeSet
+ * @param rollback
+ * @return apply result
+ */
+ ApplyResult apply(int accId, Event[] changeSet, boolean rollback);
+
+ public static class ApplyResult {
+ public @Optional WireException error;
+ public @Optional LinkedList<Event> rollbackLog;
+ }
+
+ /**
+ * Create listener
+ *
+ * @param accId
+ * @param interestSet
+ * @param pathPrefix
+ * @return lisId
+ * @throws WireException
+ */
+ int addListener(int accId, InterestSet interestSet, ChildReference pathPrefix) throws WireException;
+
+ /**
+ * Remove listener
+ *
+ * @param lisId
+ * @throws WireException
+ */
+ int removeListener(int lisId) throws WireException;
+
+ // Array, Map, Record, Union
+ /**
+ * Get size of an array, map, record or union
+ *
+ * @param accId
+ * @throws WireException
+ */
+ int size(int accId) throws WireException;
+
+ /**
+ * Remove all array or map elements
+ *
+ * @param accId
+ * @throws WireException
+ */
+ int clear(int accId) throws WireException;
+
+ boolean containsKey(int accId, MutableVariant key) throws WireException;
+ boolean containsValue(int accId, MutableVariant value) throws WireException;
+ MutableVariant getFirstKey(int accId) throws WireException;
+ MutableVariant getLastKey(int accId) throws WireException;
+ MutableVariant getLowerKey(int accId, MutableVariant key) throws WireException;
+ MutableVariant getFloorKey(int accId, MutableVariant key) throws WireException;
+ MutableVariant getCeilingKey(int accId, MutableVariant key) throws WireException;
+ MutableVariant getHigherKey(int accId, MutableVariant key) throws WireException;
+
+ /**
+ * Get map entry value
+ *
+ * @param accId
+ * @param key
+ * @return value
+ * @throws WireException
+ */
+ MutableVariant getMapValue(int accId, MutableVariant key) throws WireException;
+
+ /**
+ * Get map values as array
+ *
+ * @param accId
+ * @return values in array inside a variant
+ * @throws WireException
+ */
+ MutableVariant getMapValues(int accId) throws WireException;
+
+ /**
+ * Get map keys as array
+ *
+ * @param accId
+ * @return keys in array inside a variant
+ * @throws WireException
+ */
+ MutableVariant getMapKeys(int accId) throws WireException;
+
+ // Optional
+ /**
+ * Get value status of an Optional node
+ *
+ * @param accId
+ * @return <code>true</code> if there is value in the node
+ * @throws WireException
+ */
+ boolean hasValue(int accId) throws WireException;
+
+ // Union
+ /**
+ * Get tag index of a Union node
+ *
+ * @param accId
+ * @return tag index
+ * @throws WireException
+ */
+ int getTag(int accId) throws WireException;
+
+ // Array
+
+ /**
+ * add objects to array
+ *
+ * @param accId
+ * @param index insert pos, -1 = at the end
+ * @param array
+ * @return actual insert pos
+ */
+ int addAll(int accId, int index, MutableVariant array) throws WireException;
+
+ /**
+ *
+ * @param accId
+ * @param index insert pos, -1 = at the end
+ * @param object
+ * @return actual insert pos
+ * @throws WireException
+ */
+ int add(int accId, int index, MutableVariant object) throws WireException;
+
+ /**
+ * Get array element value
+ *
+ * @param accId
+ * @param index
+ * @return value
+ * @throws WireException
+ */
+ MutableVariant getArrayElement(int accId, int index) throws WireException;
+
+}
+