Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleans a bit the Serialisation code by removing duplicates #200

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*******************************************************************************************************
*
* CompositeGamaMessage.java, in gama.network, is part of the source code of the GAMA modeling and simulation
* platform .
* CompositeGamaMessage.java, in gama.extension.network, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.extension.network.common;

import gama.core.common.interfaces.ISerialisationConstants;
import gama.core.messaging.GamaMessage;
import gama.core.runtime.IScope;
import gama.extension.serialize.implementations.BinarySerialisation;
import gama.extension.serialize.binary.BinarySerialisation;

/**
* The Class CompositeGamaMessage.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* Connector.java, in gama.network, is part of the source code of the GAMA modeling and simulation platform
* .
* Connector.java, in gama.extension.network, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.extension.network.common;

Expand All @@ -22,7 +22,7 @@
import gama.core.metamodel.agent.IAgent;
import gama.core.runtime.IScope;
import gama.extension.network.skills.INetworkSkill;
import gama.extension.serialize.implementations.BinarySerialisation;
import gama.extension.serialize.binary.BinarySerialisation;

/**
* The Class Connector.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/*******************************************************************************************************
*
* NetworkMessage.java, in gama.network, is part of the source code of the GAMA modeling and simulation platform
* .
* NetworkMessage.java, in gama.extension.network, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.extension.network.common;

import gama.core.messaging.GamaMessage;
import gama.core.runtime.IScope;
import gama.extension.serialize.implementations.BinarySerialisation;
import gama.extension.serialize.binary.BinarySerialisation;

/**
* The Class NetworkMessage.
Expand Down
3 changes: 1 addition & 2 deletions gama.extension.serialize/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ Require-Bundle: gama.core,
Bundle-ClassPath: .
Export-Package: gama.extension.serialize,
gama.extension.serialize.binary,
gama.extension.serialize.gaml,
gama.extension.serialize.implementations
gama.extension.serialize.gaml
Import-Package: org.osgi.framework;version="1.10.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ experiment SaveSimulation type: gui {

reflex save_simulation when: cycle mod 2 = 0 {
write "================ START SAVE + self " + " - " + cycle ;
save simulation to: '../result/file.simulation' format: "json" ;
save simulation to: '../result/file.simulation' ;
write "================ END SAVE + self " + " - " + cycle ;
}

reflex serialize_agent when: cycle mod 2 = 1 {
write "================ Serialize simulation " + self + " - " + cycle;
write serialize(self.simulation, 'json', false);
write serialize(self.simulation);
write "================ END Serialize simulation " + self + " - " + cycle;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*******************************************************************************************************
*
* BinarySerialisation.java, in gama.extension.serialize, is part of the source code of the GAMA modeling and simulation
* platform.
* BinarySerialisation.java, in gama.extension.serialize, is part of the source code of the
* GAMA modeling and simulation platform (v.2024-06).
*
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
* (c) 2007-2024 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, ESPACE-DEV, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
*
********************************************************************************************************/
package gama.extension.serialize.binary;

Expand Down Expand Up @@ -199,7 +199,8 @@ public static void restoreFromBytes(final IAgent sim, final byte[] bytes) throws
*/
public static final void saveToFile(final IScope scope, final Object o, final String path, final String format,
final boolean zip, final boolean includingHistory) {
try (OutputStream os = Files.newOutputStream(new File(path).toPath(), StandardOpenOption.APPEND)) {
try (OutputStream os = Files.newOutputStream(new File(path).toPath(), StandardOpenOption.APPEND,
StandardOpenOption.CREATE, StandardOpenOption.WRITE)) {
if (o instanceof SimulationAgent sim) {
sim.setAttribute(SerialisedAgent.SERIALISE_HISTORY, includingHistory);
}
Expand Down
Loading