Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some new classes of CPP version of Msg
[simgrid.git] / src / cxx / ProcessNotFoundException.cxx
diff --git a/src/cxx/ProcessNotFoundException.cxx b/src/cxx/ProcessNotFoundException.cxx
new file mode 100644 (file)
index 0000000..bae42a3
--- /dev/null
@@ -0,0 +1,62 @@
+#include <ProcessNotFoundException.hpp>\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+namespace SimGrid\r
+{\r
+       namespace Msg\r
+       {\r
+               \r
+                       ProcessNotFoundException::ProcessNotFoundException()\r
+                       {\r
+                               this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
+                               strcpy(this->reason, "Host not found : unknown");\r
+                       }\r
+               \r
+               \r
+                       ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)\r
+                       {\r
+                               const char* reason = rProcessNotFoundException.toString();\r
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+                               strcpy(this->reason, reason);\r
+                               \r
+                       }\r
+               \r
+               \r
+                       ProcessNotFoundException::ProcessNotFoundException(int PID)\r
+                       {\r
+                               char buff[7] = {0};\r
+                               _itoa(PID, buff, 10);\r
+                               this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));\r
+                               sprintf(this->reason, "Host not found : %s", buff);\r
+                       }\r
+               \r
+               \r
+                       ProcessNotFoundException::~ProcessNotFoundException()\r
+                       {\r
+                               if(this->reason)\r
+                                       free(this->reason);\r
+                       }\r
+                               \r
+                       const char* ProcessNotFoundException::toString(void) const\r
+                       {\r
+                               return (const char*)(this->reason);     \r
+                       }\r
+               \r
+               \r
+                       const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)\r
+                       {\r
+                               const char* reason = rProcessNotFoundException.toString();\r
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+                               \r
+                               return *this;\r
+                       }\r
+               \r
+       } // namespace Msg      \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+\r