Logo AND Algorithmique Numérique Distribuée

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