Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Code refactoring on CPP
[simgrid.git] / src / cxx / Simulation.cxx
index cc13e94..b1fd89e 100644 (file)
@@ -1,11 +1,26 @@
+/*\r
+ * Simulation.cxx\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */\r
\r
+ /* Simulation member functions implementation.\r
+  */  \r
+  \r
 #include <Simulation.hpp>\r
 \r
-#include <Simulator.hpp>\r
-\r
 namespace SimGrid\r
 {\r
        namespace Msg\r
        {\r
+               \r
+               \r
                int Simulation::execute(int argc, char** argv)\r
                {\r
                        if(argc < 3) \r
@@ -18,44 +33,29 @@ namespace SimGrid
                init(argc, argv);\r
                        \r
                        // the environment to load\r
-                       Environment environment;\r
+                       Environment env;\r
                        \r
                        // the application to deploy\r
-                       Application application;\r
-                       \r
-                       // the simulation\r
-                       Simulation simulation;\r
+                       Application app;\r
+\r
                        \r
                        // try to load the environment described by the xml file (argv[1])\r
                        try\r
                        {\r
-                               environment.load(argv[1]);\r
-                       }\r
-                       catch(InvalidArgumentException e)\r
-                       {\r
-                               info(e.toString());\r
-                               finalize();\r
-                               return 1;\r
+                               env.load(argv[1]);\r
                        }\r
-                       catch(LogicException e)\r
+                       catch(FileNotFoundException e)\r
                        {\r
                                info(e.toString());\r
                                finalize();\r
                                return 1;\r
                        }\r
                                \r
-                       \r
                        // try to deploy the application described by the xml file deployment (argv[2])\r
                        try\r
                        {\r
-                               application.deploy(argv[2]);\r
-                       catch(InvalidArgumentException e)\r
-                       {\r
-                               info(e.toString());\r
-                               finalize();\r
-                               return 1;\r
-                       }\r
-                       catch(LogicException e)\r
+                               app.deploy(argv[2]);\r
+                       catch(FileNotFoundException e)\r
                        {\r
                                info(e.toString());\r
                                finalize();\r
@@ -65,7 +65,7 @@ namespace SimGrid
                        //try to run the simulation the given application on the given environment\r
                        try\r
                        {\r
-                               simulation.run(environment, application);\r
+                               this->run();\r
                        }\r
                        catch(MsgException e)\r
                        {\r
@@ -75,12 +75,11 @@ namespace SimGrid
                        }\r
                        \r
                        // finalize the MSG simulator\r
-                       \r
                        try\r
                        {\r
                                finalize();\r
                        }\r
-                       catch(MsgExceptio e)\r
+                       catch(MsgException e)\r
                        {\r
                                info(e.toString())\r
                                return 1;\r
@@ -89,7 +88,7 @@ namespace SimGrid
                        return 0;\r
                }\r
                \r
-               void run(const Environment& rEnvironment, const Application& rApplication)\r
+               void Simulation::run(void)\r
                throw (MsgException)\r
                {\r
                        if(MSG_OK != MSG_main())\r