summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-03 11:10:55 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2017-08-03 11:10:55 +0200
commitc5a23ef9d6ab1e89b85016831fc8b2431f68f87f (patch)
treefc83310559ffe00ea78f09b277fc7b2e93237947 /sol_pretty_printer/src/Main.java
parent69d904f3b2de5b914bc329af1729584f10644bf2 (diff)
Finishes the sol_pretty_printer, 'xcept Makefile.
Diffstat (limited to 'sol_pretty_printer/src/Main.java')
-rw-r--r--sol_pretty_printer/src/Main.java130
1 files changed, 130 insertions, 0 deletions
diff --git a/sol_pretty_printer/src/Main.java b/sol_pretty_printer/src/Main.java
index 21aebcb..7a7bfcd 100644
--- a/sol_pretty_printer/src/Main.java
+++ b/sol_pretty_printer/src/Main.java
@@ -1,7 +1,125 @@
+import java.util.List;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
public class Main
{
private static Parameters PARAMETERS;
+ private static boolean load_model_files ()
+ {
+ for (final String model_file: PARAMETERS.get_model_files())
+ {
+ try
+ {
+ if (!Models.load_file(model_file))
+ {
+ System.err.println
+ (
+ "[F] Something went wrong while loading the model file \""
+ + model_file
+ + "\""
+ );
+
+ return false;
+ }
+ }
+ catch (final FileNotFoundException fnfe)
+ {
+ System.err.println
+ (
+ "[F] Could not find model file \""
+ + model_file
+ + "\""
+ );
+
+ return false;
+ }
+ }
+
+ return Models.propagate_filenames();
+ }
+
+ private static boolean load_map_files ()
+ {
+ for (final String map_file: PARAMETERS.get_map_files())
+ {
+ try
+ {
+ if (!Strings.load_file(map_file))
+ {
+ System.err.println
+ (
+ "[F] Something went wrong while loading the map file \""
+ + map_file
+ + "\""
+ );
+
+ return false;
+ }
+ }
+ catch (final FileNotFoundException fnfe)
+ {
+ System.err.println
+ (
+ "[F] Could not find map file \""
+ + map_file
+ + "\""
+ );
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static void print_solutions ()
+ {
+ final List<String> sol_files, pp_files;
+ final int solutions_count;
+
+ sol_files = PARAMETERS.get_solution_files();
+ pp_files = PARAMETERS.get_pretty_print_files();
+
+ solutions_count = sol_files.size();
+
+ if (solutions_count != pp_files.size())
+ {
+ System.err.println
+ (
+ "[F] Not as many solution files as pretty-print files."
+ );
+
+ return;
+ }
+
+ for (int i = 0; i < solutions_count; ++i)
+ {
+ try
+ {
+ Solutions.print(sol_files.get(i), pp_files.get(i));
+ }
+ catch (final IOException ioe)
+ {
+ System.err.println
+ (
+ "[F] Something went wrong while printing the solution linked to"
+ + " \""
+ + sol_files.get(i)
+ + "\" and \""
+ + sol_files.get(i)
+ + "\":"
+ );
+
+ ioe.printStackTrace();
+
+ return;
+ }
+ }
+ }
+
public static void main (final String... args)
{
PARAMETERS = new Parameters(args);
@@ -10,5 +128,17 @@ public class Main
{
return;
}
+
+ if (!load_map_files())
+ {
+ return;
+ }
+
+ if (!load_model_files())
+ {
+ return;
+ }
+
+ print_solutions();
}
}