Skip to content

Commit 48c4756

Browse files
committed
Model.export methods for any format, including .umb, .pexp, with attached labels/rewards.
1 parent 5f3d28f commit 48c4756

2 files changed

Lines changed: 34 additions & 3 deletions

File tree

prism/src/explicit/Model.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
import common.IterableStateSet;
4141
import common.IteratorTools;
4242
import explicit.rewards.Rewards;
43-
import io.DotExporter;
44-
import io.ModelExportOptions;
45-
import io.PrismExplicitExporter;
43+
import io.*;
4644
import parser.State;
4745
import parser.Values;
4846
import parser.VarList;
@@ -426,6 +424,31 @@ default void prob1step(BitSet subset, BitSet u, BitSet v, BitSet result)
426424
*/
427425
void checkForDeadlocks(BitSet except) throws PrismException;
428426

427+
/**
428+
* Export to the specified model format.
429+
*/
430+
default void export(PrismLog out, ModelExportFormat exportFormat) throws PrismException
431+
{
432+
export(out, new ModelExportOptions(exportFormat));
433+
}
434+
435+
/**
436+
* Export using the specified export options.
437+
*/
438+
default void export(PrismLog out, ModelExportOptions exportOptions) throws PrismException
439+
{
440+
// Create a model checker with {@code out} as the log and export to that
441+
StateModelChecker mcExport = StateModelChecker.createModelChecker(getModelType());
442+
mcExport.setLog(out);
443+
// If {@code out} is backed by a real file (as opposed to stdout/the main log),
444+
// pass that file through too, since some (e.g. binary) export formats need it
445+
File file = null;
446+
if (out instanceof PrismFileLog && !((PrismFileLog) out).isStdout()) {
447+
file = new File(((PrismFileLog) out).getFileName());
448+
}
449+
mcExport.exportModel(this, ModelExportTask.fromOptions(file, exportOptions));
450+
}
451+
429452
// Export methods (explicit files)
430453

431454
/**

prism/src/prism/PrismFileLog.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,14 @@ public String getFileName()
127127
return stdout ? "stdout" : filename;
128128
}
129129

130+
/**
131+
* Is this log writing to standard output (rather than a file)?
132+
*/
133+
public boolean isStdout()
134+
{
135+
return stdout;
136+
}
137+
130138
/**
131139
* Is this log using native code to write to the file?
132140
*/

0 commit comments

Comments
 (0)