Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not needed now
[simgrid.git] / src / cxx / ClassNotFoundException.cxx
1 /*\r
2  * ClassNotFoundException.cxx\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
5  * All right reserved. \r
6  *\r
7  * This program is free software; you can redistribute \r
8  * it and/or modify it under the terms of the license \r
9  *(GNU LGPL) which comes with this package. \r
10  *\r
11  */\r
12  \r
13  /* ClassNotFoundException member functions implementation.\r
14   */  \r
15 \r
16 #include <ClassNotFoundException.hpp>\r
17 \r
18 #include <string.h>\r
19 #include <stdlib.h>\r
20 #include <stdio.h>\r
21 \r
22 namespace SimGrid\r
23 {\r
24         namespace Msg\r
25         {\r
26                 \r
27                         ClassNotFoundException::ClassNotFoundException()\r
28                         {\r
29                                 this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));\r
30                                 strcpy(this->reason, "Class not found : unknown");\r
31                         }\r
32                 \r
33                 \r
34                         ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)\r
35                         {\r
36                                 const char* reason = rClassNotFoundException.toString();\r
37                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
38                                 strcpy(this->reason, reason);\r
39                                 \r
40                         }\r
41                 \r
42                 \r
43                         ClassNotFoundException::ClassNotFoundException(const char* name)\r
44                         {\r
45                                 this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));\r
46                                 sprintf(this->reason, "Class not found : %s", name);\r
47                         }\r
48                 \r
49                 \r
50                         ClassNotFoundException::~ClassNotFoundException()\r
51                         {\r
52                                 if(this->reason)\r
53                                         free(this->reason);\r
54                         }\r
55                                 \r
56                         const char* ClassNotFoundException::toString(void) const\r
57                         {\r
58                                 return (const char*)(this->reason);     \r
59                         }\r
60                 \r
61                 \r
62                         const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)\r
63                         {\r
64                                 const char* reason = rClassNotFoundException.toString();\r
65                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
66                                 \r
67                                 return *this;\r
68                         }\r
69                 \r
70         } // namespace Msg      \r
71 \r
72 }// namespace SimGrid\r
73 \r
74 \r
75 \r