Skip to content

Commit

Permalink
Attempt to fix issue #3111 by introducing a new Converter for BDIPlan
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitgaudou committed Dec 10, 2021
1 parent 6d60da6 commit 9b4f2d0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
3 changes: 2 additions & 1 deletion ummisco.gama.serialize/META-INF/MANIFEST.MF
Expand Up @@ -4,7 +4,8 @@ Bundle-Name: Serialize
Bundle-SymbolicName: ummisco.gama.serialize;singleton:=true
Bundle-Version: 1.8.2.qualifier
Require-Bundle: msi.gama.core,
msi.gama.ext
msi.gama.ext,
msi.gaml.architecture.simplebdi;bundle-version="1.8.2"
Bundle-ClassPath: .,
ext/xstream-1.4.8.jar,
ext/kxml2-2.3.0.jar,
Expand Down
Expand Up @@ -17,6 +17,7 @@
import ummisco.gama.serializer.gamaType.converters.ConverterScope;
import ummisco.gama.serializer.gamaType.converters.GamaAgentConverter;
import ummisco.gama.serializer.gamaType.converters.GamaAgentConverterNetwork;
import ummisco.gama.serializer.gamaType.converters.GamaBDIPlanConverter;
import ummisco.gama.serializer.gamaType.converters.GamaBasicTypeConverter;
import ummisco.gama.serializer.gamaType.converters.GamaFileConverter;
import ummisco.gama.serializer.gamaType.converters.GamaGraphConverter;
Expand All @@ -36,7 +37,7 @@ public abstract class Converters {

private static Converter[] loadConverter(ConverterScope cs)
{
Converter[] converters= new Converter[14];
Converter[] converters= new Converter[15];
converters[0]= new GamaBasicTypeConverter(cs);
converters[1]=new GamaAgentConverter(cs);
converters[2]=new GamaListConverter(cs);
Expand All @@ -52,7 +53,9 @@ private static Converter[] loadConverter(ConverterScope cs)
converters[10]= new GamaPopulationConverter(cs);
converters[11]= new GamaSpeciesConverter(cs);
converters[12]= new ReferenceAgentConverter(cs);
converters[13]= new GamaPathConverter(cs);
converters[13]= new GamaPathConverter(cs);

converters[14]= new GamaBDIPlanConverter(cs);

//converters[12]= new ComplexMessageConverter(cs);

Expand All @@ -70,7 +73,7 @@ public static Converter[] converterFactory(ConverterScope cs)
// TODO Remove when possible
private static Converter[] loadConverterNetwork(ConverterScope cs)
{
Converter[] converters= new Converter[12];
Converter[] converters= new Converter[14];
converters[0]= new GamaBasicTypeConverter(cs);
converters[1]=new GamaAgentConverterNetwork(cs);
converters[2]=new GamaListConverterNetwork(cs);
Expand All @@ -84,7 +87,12 @@ private static Converter[] loadConverterNetwork(ConverterScope cs)
converters[9]=new SavedAgentConverter(cs);

converters[10]= new GamaPopulationConverter(cs);
converters[11]= new GamaSpeciesConverter(cs);
converters[11]= new GamaSpeciesConverter(cs);
converters[12]= new GamaPathConverter(cs);

converters[13]= new GamaBDIPlanConverter(cs);


//converters[12]= new ComplexMessageConverter(cs);

return converters;
Expand Down
@@ -0,0 +1,36 @@
package ummisco.gama.serializer.gamaType.converters;

import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;

import msi.gaml.architecture.simplebdi.BDIPlan;
import ummisco.gama.dev.utils.DEBUG;

public class GamaBDIPlanConverter implements Converter {
ConverterScope convertScope;

public GamaBDIPlanConverter(final ConverterScope s) {
convertScope = s;
}

@Override
public boolean canConvert(final Class arg0) {
return BDIPlan.class.isAssignableFrom(arg0);
}

@Override
public void marshal(Object arg0, HierarchicalStreamWriter arg1, MarshallingContext arg2) {
final BDIPlan plan = (BDIPlan) arg0;

DEBUG.OUT("ConvertAnother : BDIPlan " + plan.getClass() + " " + plan.getGamlType().getContentType());
DEBUG.OUT("END --- ConvertAnother : BDIPlan ");
}

@Override
public Object unmarshal(HierarchicalStreamReader arg0, UnmarshallingContext arg1) {
return null;
}
}

0 comments on commit 9b4f2d0

Please sign in to comment.