Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java')
-rw-r--r--plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java49
1 files changed, 29 insertions, 20 deletions
diff --git a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
index c2f2bc3a3..4eb476223 100644
--- a/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
+++ b/plugins/org.eclipse.etrice.core.config/src/org/eclipse/etrice/core/config/util/ConfigUtil.java
@@ -16,10 +16,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.etrice.core.config.IntLiteral;
-import org.eclipse.etrice.core.config.NumberLiteral;
import org.eclipse.etrice.core.config.PortInstanceConfig;
-import org.eclipse.etrice.core.config.RealLiteral;
import org.eclipse.etrice.core.config.RefPath;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorContainerClass;
@@ -35,7 +32,6 @@ import org.eclipse.etrice.core.room.PortClass;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.SAPRef;
-import org.eclipse.etrice.core.room.SPPRef;
import org.eclipse.etrice.core.room.SubSystemClass;
import org.eclipse.etrice.core.room.util.RoomHelpers;
@@ -55,11 +51,35 @@ public class ConfigUtil {
return null;
}
- public static ActorContainerClass resolve(ActorContainerClass root,
+ public static ActorClass resolve(ActorContainerClass root,
RefPath path) {
- if (path == null)
- return root;
+ if(path.getRefs().isEmpty())
+ return null;
+
+ ActorContainerClass result = root;
+ for (String ref : path.getRefs()) {
+ ActorRef match = null;
+ for (ActorContainerRef actor : RoomHelpers.getRefs(result, true)) {
+ if (actor instanceof ActorRef && actor.getName().equals(ref)) {
+ match = (ActorRef) actor;
+ break;
+ }
+ }
+ if (match == null)
+ return null;
+ result = match.getType();
+ }
+
+ return (ActorClass) result;
+ }
+
+ public static ActorRef getLastActorRef(ActorContainerClass root,
+ RefPath path) {
+ if(path.getRefs().isEmpty())
+ return null;
+
+ ActorRef lastMatch = null;
ActorContainerClass result = root;
for (String ref : path.getRefs()) {
ActorRef match = null;
@@ -73,9 +93,10 @@ public class ConfigUtil {
if (match == null)
return null;
result = match.getType();
+ lastMatch = match;
}
- return result;
+ return lastMatch;
}
/**
@@ -125,18 +146,6 @@ public class ConfigUtil {
return null;
}
- public static double literalToDouble(NumberLiteral number) {
- double dValue = 0;
- if (number instanceof IntLiteral)
- dValue = ((IntLiteral) number).getValue();
- else if (number instanceof RealLiteral)
- dValue = ((RealLiteral) number).getValue();
- else
- assert (false) : "unexpected type";
-
- return dValue;
- }
-
public static PortClass getPortClass(PortInstanceConfig config) {
InterfaceItem item = config.getItem();
PortClass portClass = null;

Back to the top