Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some new classes of CPP version of Msg
[simgrid.git] / src / cxx / ProcessNotFoundException.cxx
1 #include <ProcessNotFoundException.hpp>\r
2 \r
3 #include <string.h>\r
4 #include <stdlib.h>\r
5 #include <stdio.h>\r
6 \r
7 namespace SimGrid\r
8 {\r
9         namespace Msg\r
10         {\r
11                 \r
12                         ProcessNotFoundException::ProcessNotFoundException()\r
13                         {\r
14                                 this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
15                                 strcpy(this->reason, "Host not found : unknown");\r
16                         }\r
17                 \r
18                 \r
19                         ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)\r
20                         {\r
21                                 const char* reason = rProcessNotFoundException.toString();\r
22                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
23                                 strcpy(this->reason, reason);\r
24                                 \r
25                         }\r
26                 \r
27                 \r
28                         ProcessNotFoundException::ProcessNotFoundException(int PID)\r
29                         {\r
30                                 char buff[7] = {0};\r
31                                 _itoa(PID, buff, 10);\r
32                                 this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));\r
33                                 sprintf(this->reason, "Host not found : %s", buff);\r
34                         }\r
35                 \r
36                 \r
37                         ProcessNotFoundException::~ProcessNotFoundException()\r
38                         {\r
39                                 if(this->reason)\r
40                                         free(this->reason);\r
41                         }\r
42                                 \r
43                         const char* ProcessNotFoundException::toString(void) const\r
44                         {\r
45                                 return (const char*)(this->reason);     \r
46                         }\r
47                 \r
48                 \r
49                         const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)\r
50                         {\r
51                                 const char* reason = rProcessNotFoundException.toString();\r
52                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
53                                 \r
54                                 return *this;\r
55                         }\r
56                 \r
57         } // namespace Msg      \r
58 \r
59 }// namespace SimGrid\r
60 \r
61 \r
62 \r