Aufgrund von Umarbeiten des s3 Storage wird es in GitLab, in nächster Zeit, mögliche Performance-Einbußen geben. Näheres dazu unter: https://maintenance.itc.rwth-aachen.de/ticket/status/messages/43/show_ticket/6670

Commit d8192efc authored by Jean Meurice's avatar Jean Meurice

Destroyable/Inspectable/DataType toString()

parent 363fc25b
Pipeline #371727 passed with stage
in 48 seconds
......@@ -8,7 +8,7 @@
<groupId>montisim</groupId>
<artifactId>commons</artifactId>
<version>2.0.8</version>
<version>2.0.9</version>
<properties>
......
......@@ -3,6 +3,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.*;
import de.rwth.montisim.commons.utils.*;
import de.rwth.montisim.commons.utils.json.*;
......@@ -173,4 +174,30 @@ public class BasicType extends DataType {
return base_type.name();
}
@Override
public List<String> toString(Object o) {
switch (base_type) {
case BOOLEAN:
if ((Boolean)o) return new ArrayList<String>(Arrays.asList("true"));
else return new ArrayList<String>(Arrays.asList("false"));
case C:
return new ArrayList<String>(Arrays.asList("Unimplemented Type"));
case EMPTY:
return new ArrayList<String>(Arrays.asList("void"));
case N:
case N1:
case Z:
return new ArrayList<String>(Arrays.asList(Integer.toString((Integer) o)));
case Q:
return new ArrayList<String>(Arrays.asList(Double.toString((Double) o)));
case VEC2:
return new ArrayList<String>(Arrays.asList(((Vec2) o).toString()));
case VEC3:
return new ArrayList<String>(Arrays.asList(((Vec3) o).toString()));
default:
throw new IllegalArgumentException("Missing case");
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.List;
import de.rwth.montisim.commons.utils.json.*;
......@@ -30,6 +31,7 @@ public abstract class DataType {
public abstract void toBinary(DataOutputStream os, Object o) throws IOException;
public abstract Object fromBinary(DataInputStream is) throws IOException;
public abstract List<String> toString(Object o);
public abstract Class<?> getArrayType();
}
\ No newline at end of file
......@@ -4,6 +4,9 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.rwth.montisim.commons.utils.ParsingException;
import de.rwth.montisim.commons.utils.json.*;
......@@ -125,4 +128,9 @@ public class DynVectorType extends DataType {
throw new IllegalArgumentException("Unimplemented");
}
@Override
public List<String> toString(Object o) {
return new ArrayList<String>(Arrays.asList("Unimplemented toString()"));
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.*;
import de.rwth.montisim.commons.utils.json.Json;
import de.rwth.montisim.commons.utils.json.JsonTraverser;
......@@ -103,4 +103,9 @@ public class EnumType extends DataType {
public Object fromBinary(DataInputStream is) throws IOException {
throw new IllegalArgumentException("Unimplemented");
}
@Override
public List<String> toString(Object o) {
return new ArrayList<String>(Arrays.asList("Unimplemented toString()"));
}
}
......@@ -4,6 +4,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.*;
import de.rwth.montisim.commons.utils.ParsingException;
import de.rwth.montisim.commons.utils.json.*;
......@@ -163,4 +164,9 @@ public class MatrixType extends DataType {
throw new IllegalArgumentException("Unimplemented");
}
@Override
public List<String> toString(Object o) {
return new ArrayList<String>(Arrays.asList("Unimplemented toString()"));
}
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.*;
import de.rwth.montisim.commons.utils.json.*;
import de.rwth.montisim.commons.utils.json.JsonTraverser.ArrayIterable;
......@@ -196,4 +196,9 @@ public class StructType extends DataType implements CustomJson {
throw new IllegalArgumentException("Unimplemented");
}
@Override
public List<String> toString(Object o) {
return new ArrayList<String>(Arrays.asList("Unimplemented toString()"));
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ package de.rwth.montisim.commons.dynamicinterface;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.*;
import de.rwth.montisim.commons.utils.ParsingException;
import de.rwth.montisim.commons.utils.json.*;
......@@ -152,4 +153,20 @@ public class VectorType extends DataType {
} else throw new IllegalArgumentException("Unimplemented");
}
@Override
public List<String> toString(Object o) {
Class<?> array_c = base_type.getArrayType();
if (array_c == double[].class) {
double[] arr = (double[]) o;
String res = "[";
boolean first = true;
for (double d : arr) {
if (first) first = false;
else res += ", ";
res += Double.toString(d);
}
res += "]";
return new ArrayList<String>(Arrays.asList(res));
} else return new ArrayList<String>(Arrays.asList("Unimplemented toString()"));
}
}
\ No newline at end of file
/* (c) https://github.com/MontiCore/monticore */
package de.rwth.montisim.commons.simulation;
import java.util.ArrayList;
import java.util.List;
/**
* Stores references to different 'Destroyable' objects.
*
* applyDestroy() will destroy all registered objects.
*/
public class Destroyer {
protected transient List<Destroyable> destroyables = new ArrayList<>();
/** Register an Updatable. */
public void addDestroyable(Destroyable d){
destroyables.add(d);
}
/** Update all registered updatables. */
public void applyDestroy(){
for (Destroyable d : destroyables){
d.destroy();
}
}
}
\ No newline at end of file
package de.rwth.montisim.commons.simulation;
import java.util.List;
public interface Inspectable {
String getType(); // A general type for the inspectable object (ex: "autopilot")
String getName(); // The name of the inspected element
List<String> getEntries(); // Returns a list of debug values for the object.
}
package de.rwth.montisim.commons.utils;
import de.rwth.montisim.commons.utils.json.JsonEntry;
public enum Comparator {
LESS, LESS_EQUAL, GREATER, GREATER_EQUAL, EQUAL
@JsonEntry("<")
LESS,
@JsonEntry("<=")
LESS_EQUAL,
@JsonEntry(">")
GREATER,
@JsonEntry(">=")
GREATER_EQUAL,
@JsonEntry("==")
EQUAL
}
package de.rwth.montisim.commons.utils;
import de.rwth.montisim.commons.utils.json.JsonEntry;
public enum LTLOperator {
ALWAYS, NEVER, EVENTUALLY, UNTIL
@JsonEntry("always")
ALWAYS,
@JsonEntry("never")
NEVER,
@JsonEntry("eventually")
EVENTUALLY,
@JsonEntry("until")
UNTIL
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment