Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Code refactoring on CPP
[simgrid.git] / src / cxx / Application.cxx
index 6e6ea8b..e11cab9 100644 (file)
@@ -1,3 +1,18 @@
+/*\r
+ * Application.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
+ /* Application member functions implementation.\r
+  */  \r
+  \r
 #include <Application.hpp>\r
 #include <ApplicationHandler.hpp>\r
 \r
@@ -27,17 +42,17 @@ namespace SimGrid
                }\r
        \r
                Application::Application(const char* file)\r
-               throw(InvalidParameterException)\r
+               throw(NullPointerException, FileNotFoundException)\r
                {\r
                        // check parameters\r
                        \r
                        if(!file)\r
-                               throw InvalidParameterException("file (must not be NULL");\r
+                               throw NullPointerException("file");\r
                        \r
                        struct stat statBuf = {0};\r
                                \r
                        if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
-                               throw InvalidParameterException("file (file not found)");\r
+                               throw FileNotFoundException(file);\r
                                \r
                        this->file = file;\r
                        this->deployed = false;\r
@@ -49,7 +64,7 @@ namespace SimGrid
                }\r
                        \r
                Application::deploy(const char* file)\r
-               throw(InvalidParameterException, LogicException, MsgException)\r
+               throw(NullPointerException, FileNotFoundException, LogicException, MsgException)\r
                {\r
                        // check logic\r
                        \r
@@ -59,25 +74,39 @@ namespace SimGrid
                        // check the parameters\r
                                \r
                        if(!file)\r
-                               throw InvalidParameterException("file (must not be NULL");\r
+                               throw NullPointerException("file");\r
                        \r
                        struct stat statBuf = {0};\r
                                \r
                        if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
-                               throw InvalidParameterException("file (file not found)");\r
+                               throw FileNotFoundException(file);\r
                                        \r
                        surf_parse_reset_parser();\r
+                       \r
+                       // set the begin of the xml process element handler\r
                        surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
+                               \r
+                       // set the process arg handler\r
                        surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onArg);\r
+                               \r
+                       // set the properties handler\r
                        surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
+                               \r
+                       // set the end of the xml process element handler\r
                        surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::OnEndProcess);\r
 \r
                        surf_parse_open(file);\r
                        \r
+                       // initialize the process factory used by the process handler to build the processes.\r
+                       ApplicationHandler::onStartDocument();\r
+                               \r
                        if(surf_parse())\r
                                throw MsgException("surf_parse() failed");\r
                        \r
-                       surf_parse_close();     \r
+                       surf_parse_close();\r
+                       \r
+                       // release the process factory\r
+                       ApplicationHandler::onEndDocument();    \r
                        \r
                        this->file = file;\r
                        this->deployed = true;\r
@@ -117,7 +146,7 @@ namespace SimGrid
                }\r
                \r
                void Application::setFile(const char* file)\r
-               throw (InvalidParameterException, LogicException)\r
+               throw (NullPointerException, FileNotFoundException, LogicException)\r
                {\r
                        // check logic\r
                        \r
@@ -127,12 +156,12 @@ namespace SimGrid
                        // check parameters\r
                        \r
                        if(!file)\r
-                               throw InvalidParameterException("file (must not be NULL");\r
+                               throw NullPointerException("file");\r
                        \r
                        struct stat statBuf = {0};\r
                                \r
                        if(stat(statBuff, &info) < 0 || !S_ISREG(statBuff.st_mode))\r
-                               throw InvalidParameterException("file (file not found)");\r
+                               throw FileNotFoundException("file (file not found)");\r
                                \r
                        this->file = file;\r
                        \r