Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cc21c7270111d4d5d3070a97746f45898d79ea91
[simgrid.git] / src / cxx / Environment.hpp
1 /*\r
2  * Environment.hpp\r
3  *\r
4  * This file contains the declaration of the wrapper class of the native MSG task type.\r
5  *\r
6  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
7  * All right reserved. \r
8  *\r
9  * This program is free software; you can redistribute \r
10  * it and/or modify it under the terms of the license \r
11  *(GNU LGPL) which comes with this package. \r
12  *\r
13  */  \r
14  \r
15 #ifndef MSG_ENVIRONMENT_HPP\r
16 #define MSG_ENVIRONMENT_HPP\r
17 \r
18 #ifndef __cplusplus\r
19         #error Environment.hpp requires C++ compilation (use a .cxx suffix)\r
20 #endif\r
21 \r
22 #include <NullPointerException.hpp>\r
23 #include <FileNotFoundException.hpp>\r
24 #include <LogicException.hpp>\r
25 #include <MsgException.hpp>\r
26 \r
27 \r
28 namespace SimGrid\r
29 {\r
30         namespace Msg\r
31         {\r
32                 // Environment class wrapper declaration\r
33                 class Environment\r
34                 {\r
35                         public:\r
36                                 \r
37                                 /*! \brief Default constructor.\r
38                                  */\r
39                                 Environment();\r
40                                 \r
41                                 /*! \brief Copy constructor.\r
42                                  */\r
43                                 Environment(const Environment& rEnvironment);\r
44                                 \r
45                                 /*! \brief Constructor.\r
46                                  *\r
47                                  * \param file                  The xml file describing the environment of the simulation.\r
48                                  *\r
49                                  * \exception                   If this constructor fails, it throws one of the exception\r
50                                  *                                              described below:\r
51                                  *\r
52                                  *                                              [NullPointerException]          if the parameter file is NULL.\r
53                                  *\r
54                                  *                                              [FileNotFoundException]         if the file is not found.\r
55                                  */\r
56                                 Environment(const char* file)\r
57                                 throw(NullPointerException, FileNotFoundException);\r
58                                 \r
59                                 /*! \brief Destructor.\r
60                                  */\r
61                                 virtual ~Environment();\r
62                                 \r
63                         // Operations.\r
64                                 \r
65                                 /*! brief Environment::load() - Load the environment of a simulation.\r
66                                  *\r
67                                  * \exception                   If this method fails, it throws the exception described below:\r
68                                  *\r
69                                  *                                              [LogicException]                        if the file of the environment is not yet specified or\r
70                                  *                                                                                                      if the environment is already loaded.\r
71                                  */\r
72                                 void load(void)\r
73                                 throw(LogicException);\r
74                                 \r
75                                 /*! \brief Environment::load() - Load the environment of a simulation.\r
76                                  *\r
77                                  * \param file                  The xml file describing the environment of the simulation.\r
78                                  *\r
79                                  * \exception                   If this method fails, it throws one of the exceptions described below.\r
80                                  *\r
81                                  *                                              [NullPointerException]          if the parameter file is NULL.\r
82                                  *\r
83                                  *                                              [FileNotFoundException]         if the specified file is not found.\r
84                                  *\r
85                                  *                                              [LogicException]                        if the environment is already loaded.\r
86                                  */\r
87                                 void load(const char* file)\r
88                                 throw(NullPointerException, FileNotFoundException, LogicException);\r
89                                 \r
90                                 /*! \brief Environment::isLoaded() - Tests if an environment is loaded.\r
91                                  *\r
92                                  * \return                              If the environment is loaded, the method returns true. Otherwise the method\r
93                                  *                                              returns false.\r
94                                  */\r
95                                 bool isLoaded(void) const;\r
96                                 \r
97                         // Getters/setters\r
98                                 /*! \brief Environment::setFile() - Sets the xml file of the environment.\r
99                                  *\r
100                                  * \param file                  The file describing the environment.\r
101                                  *\r
102                                  * \exception                   If the method fails, it throws one of the exceptions described below:\r
103                                  *\r
104                                  *                                              [NullPointerException]          if the parameter file is NULL.\r
105                                  *                              \r
106                                  *                                              [FileNotFoundException]         if the file is not found.\r
107                                  *\r
108                                  *                                              [LogicException]                        if the environment is already loaded.\r
109                                  */\r
110                                 void setFile(const char* file)\r
111                                 throw(NullPointerException, FileNotFoundException, LogicException);\r
112                                 \r
113                                 /*! \brief Environment::getFile() - Gets the xml file environment description.\r
114                                  *\r
115                                  * \return                              The xml file describing the environment.                                \r
116                                  *\r
117                                  */\r
118                                 const char* getFile(void) const;\r
119                                 \r
120                         // Operators.\r
121                                 \r
122                                 /*! \brief Assignment operator.\r
123                                  *\r
124                                  * \exception                   If this operator fails, it throws the exception described below:\r
125                                  *\r
126                                  *                                              [LogicException]                        if you try to assign a loaded environment.\r
127                                  */\r
128                                 const Environment& operator = (const Environment& rEnvironment)\r
129                                 throw(LogicException);\r
130                                 \r
131                         private:\r
132                                 \r
133                                 // Attributes.\r
134                                 \r
135                                 // the xml file which describe the environment of the simulation.\r
136                                 const char* file;\r
137                                 \r
138                                 // flag : is true the environment of the simulation is loaded.\r
139                                 bool loaded.\r
140                 };\r
141                 \r
142         } // namespace Msg\r
143 } // namespace SimGrid\r
144 \r
145 \r
146 #endif // !MSG_ENVIRONMENT_HPP