Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2013-11-18 11:51:11 -0500
committerHenrik Rentz-Reichert2013-11-19 12:36:56 -0500
commitaf70a003bffc78a40b716f493069545a9d94ad5c (patch)
tree43f8136fec492fd07aed57122c0e5f07b7c1770a /runtime/org.eclipse.etrice.runtime.java/src/org/eclipse
parent6a31f677cdc6076eb2c16d0e5642acc237b3ac5e (diff)
downloadorg.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.tar.gz
org.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.tar.xz
org.eclipse.etrice-af70a003bffc78a40b716f493069545a9d94ad5c.zip
[runtime.java][generator.java] Bug 422044: add possibility to
store/restore an actor's extended state using POJOs https://bugs.eclipse.org/422044 Change-Id: Iba98c6dff98da807098a82d37e7d8dd8489df180
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.java/src/org/eclipse')
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java75
-rw-r--r--runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java23
2 files changed, 98 insertions, 0 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java
new file mode 100644
index 000000000..3fad7b002
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/ActorClassFinalActionBase.java
@@ -0,0 +1,75 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+import org.eclipse.etrice.runtime.java.messaging.IRTObject;
+
+/**
+ * A base class that is used by the generator if the {@code -storeDataObj} switch is used.
+ * After a state transition is completed {@link #finalAction()} is called which in turn
+ * executes the {@link FinalAction} which was stored using {@link #setFinalAction(FinalAction)}.
+ * If the final action is derived from {@link SingleFinalAction} then it is invoked only once.
+ * If it is derived from {@link RepeatedFinalAction} it is invoked after every state transition
+ * until {@link #setFinalAction(FinalAction)} is called with {@code null}.
+ *
+ * @author Henrik Rentz-Reichert
+ */
+public abstract class ActorClassFinalActionBase extends ActorClassBase {
+
+ /**
+ * The interface for final actions (called after a state transition is completed).
+ * This interface inherits from {@link Runnable}.
+ *
+ * @author Henrik Rentz-Reichert
+ */
+ public interface FinalAction extends Runnable {}
+
+ /**
+ * @author Henrik Rentz-Reichert
+ *
+ */
+ public interface SingleFinalAction extends FinalAction {}
+ public interface RepeatedFinalAction extends FinalAction {}
+
+ private FinalAction finalAction = null;
+
+ /**
+ * @param parent
+ * @param name
+ */
+ public ActorClassFinalActionBase(IRTObject parent, String name) {
+ super(parent, name);
+ }
+
+ /**
+ * @param finalAction the final action to be executed or {@code null} if no action should be executed.
+ */
+ public void setFinalAction(FinalAction finalAction) {
+ this.finalAction = finalAction;
+ }
+
+ /**
+ * This method is called right after a state transition occurred. It executes the {@link FinalAction} that
+ * was set with {@link #setFinalAction(FinalAction)}. If the final action is a {@link SingleFinalAction}
+ * it is executed only once.
+ */
+ protected void finalAction() {
+ if (finalAction==null)
+ return;
+
+ finalAction.run();
+
+ if (finalAction instanceof SingleFinalAction)
+ finalAction = null;
+ }
+}
diff --git a/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java
new file mode 100644
index 000000000..a52fea781
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.java/src/org/eclipse/etrice/runtime/java/modelbase/IActorClassDataObject.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2013 protos software gmbh (http://www.protos.de).
+ * 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:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+package org.eclipse.etrice.runtime.java.modelbase;
+
+/**
+ * All <actor class>_DataObjects implement this interface.
+ *
+ * @author Henrik Rentz-Reichert
+ *
+ */
+public interface IActorClassDataObject {
+
+}

Back to the top