Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Code refactoring on CPP
[simgrid.git] / src / cxx / ApplicationHandler.cxx
index 5d6d3f2..f1a8077 100644 (file)
@@ -1,3 +1,18 @@
+/*\r
+ * ApplicationHandler.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
+ /* ApplicationHandler member functions implementation.\r
+  */  \r
+  \r
 #include <ApplicationHandler.hpp>\r
 \r
 namespace SimGrid\r
@@ -33,7 +48,7 @@ namespace SimGrid
                {\r
                        return *this;\r
                }\r
-                       \r
+               \r
                void ApplicationHandler::onStartDocument(void)\r
                {\r
                        // instanciate the factory at the begining of the parsing\r
@@ -84,31 +99,19 @@ namespace SimGrid
                \r
                // create the cxx process wrapper.\r
                void ApplicationHandler::ProcessFactory::createProcess() \r
+               throw (ClassNotFoundException, HostNotFoundException)\r
                {\r
                        Host host;\r
                        Process* process;\r
                        \r
-                       // dynamic creation of a instance fo the process from its name (which is specified by the element function\r
+                       // try to dynamicaly create an instance fo the process from its name (which is specified by the element function\r
                        // in the xml application file.\r
-                       try\r
-                       {\r
-                               process = (Process*)Class::fromName(this->function);\r
-                       }\r
-                       catch(ClassNotFoundException e)\r
-                       {\r
-                               cerr << e.toString();   \r
-                       }\r
+                       // if this static method fails, it throws an exception of the class ClassNotFoundException\r
+                       process = (Process*)Class::fromName(this->function);\r
                        \r
                        // try to retrieve the host of the process from its name\r
-                       try\r
-                       {\r
-                               host = Host::getByName(this->hostName); \r
-                       }\r
-                       catch(HostNotFoundException(this->hostName))\r
-                       {\r
-                               cerr << e.toString();\r
-                       }\r
-                               \r
+                       // if this method fails, it throws an exception of the class HostNotFoundException\r
+                       host = Host::getByName(this->hostName); \r
                        \r
                        // build the list of the arguments of the newly created process.\r
                        int argc = xbt_dynar_length(this->args);\r