Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot//simgrid/simgrid
[simgrid.git] / src / cxx / ClassNotFoundException.cxx
1 /*
2  * ClassNotFoundException.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  /* ClassNotFoundException member functions implementation.
14   */  
15
16 #include <ClassNotFoundException.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                         ClassNotFoundException::ClassNotFoundException()
28                         {
29                                 this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));
30                                 strcpy(this->reason, "Class not found : unknown");
31                         }
32                 
33                 
34                         ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)
35                         {
36                                 const char* reason = rClassNotFoundException.toString();
37                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
38                                 strcpy(this->reason, reason);
39                                 
40                         }
41                 
42                 
43                         ClassNotFoundException::ClassNotFoundException(const char* name)
44                         {
45                                 this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));
46                                 sprintf(this->reason, "Class not found : %s", name);
47                         }
48                 
49                 
50                         ClassNotFoundException::~ClassNotFoundException()
51                         {
52                                 if(this->reason)
53                                         free(this->reason);
54                         }
55                                 
56                         const char* ClassNotFoundException::toString(void) const
57                         {
58                                 return (const char*)(this->reason);     
59                         }
60                 
61                 
62                         const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)
63                         {
64                                 const char* reason = rClassNotFoundException.toString();
65                                 this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
66                                 
67                                 return *this;
68                         }
69                 
70         } // namespace Msg      
71
72 }// namespace SimGrid
73
74
75