Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some new classes of CPP version of Msg
[simgrid.git] / src / cxx / ClassNotFoundException.cxx
diff --git a/src/cxx/ClassNotFoundException.cxx b/src/cxx/ClassNotFoundException.cxx
new file mode 100644 (file)
index 0000000..e61bf53
--- /dev/null
@@ -0,0 +1,60 @@
+#include <ClassNotFoundException.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
+                       ClassNotFoundException::ClassNotFoundException()\r
+                       {\r
+                               this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));\r
+                               strcpy(this->reason, "Class not found : unknown");\r
+                       }\r
+               \r
+               \r
+                       ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)\r
+                       {\r
+                               const char* reason = rClassNotFoundException.toString();\r
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+                               strcpy(this->reason, reason);\r
+                               \r
+                       }\r
+               \r
+               \r
+                       ClassNotFoundException::ClassNotFoundException(const char* name)\r
+                       {\r
+                               this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));\r
+                               sprintf(this->reason, "Class not found : %s", name);\r
+                       }\r
+               \r
+               \r
+                       ClassNotFoundException::~ClassNotFoundException()\r
+                       {\r
+                               if(this->reason)\r
+                                       free(this->reason);\r
+                       }\r
+                               \r
+                       const char* ClassNotFoundException::toString(void) const\r
+                       {\r
+                               return (const char*)(this->reason);     \r
+                       }\r
+               \r
+               \r
+                       const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)\r
+                       {\r
+                               const char* reason = rClassNotFoundException.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