Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The default alias name is now build from the name of the host of the process and...
[simgrid.git] / src / cxx / ProcessNotFoundException.cxx
1 /*\r
2  * ProcessNotFoundException.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  /* ProcessNotFoundException member functions implementation.\r
14   */  \r
15 \r
16 #include <ProcessNotFoundException.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                         ProcessNotFoundException::ProcessNotFoundException()\r
28                         {\r
29                                 this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
30                                 strcpy(this->reason, "Host not found : unknown");\r
31                         }\r
32                 \r
33                 \r
34                         ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)\r
35                         {\r
36                                 const char* reason = rProcessNotFoundException.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                         ProcessNotFoundException::ProcessNotFoundException(int PID)\r
44                         {\r
45                                 char buff[7] = {0};\r
46                                 _itoa(PID, buff, 10);\r
47                                 this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));\r
48                                 sprintf(this->reason, "Host not found : %s", buff);\r
49                         }\r
50                 \r
51                 \r
52                         ProcessNotFoundException::~ProcessNotFoundException()\r
53                         {\r
54                                 if(this->reason)\r
55                                         free(this->reason);\r
56                         }\r
57                                 \r
58                         const char* ProcessNotFoundException::toString(void) const\r
59                         {\r
60                                 return (const char*)(this->reason);     \r
61                         }\r
62                 \r
63                 \r
64                         const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)\r
65                         {\r
66                                 const char* reason = rProcessNotFoundException.toString();\r
67                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
68                                 \r
69                                 return *this;\r
70                         }\r
71                 \r
72         } // namespace Msg      \r
73 \r
74 }// namespace SimGrid\r
75 \r
76 \r
77 \r