Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some code refactoring
[simgrid.git] / src / cxx / ApplicationHandler.hpp
1 /*\r
2  * ApplicationHandler.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_APPLICATION_HANDLER_HPP\r
16 #define MSG_APPLICATION_HANDLER_HPP\r
17 \r
18 // Compilation C++ recquise\r
19 #ifndef __cplusplus\r
20         #error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)\r
21 #endif\r
22 \r
23 #include <xbt/dict.h>\r
24 #include <xbt/dynar.h>\r
25 \r
26 #include <ClassNotFoundException.hpp>\r
27 #include <HostNotFoundException.hpp>\r
28 \r
29 namespace SimGrid\r
30 {\r
31         namespace Msg\r
32         {\r
33                 class Process;\r
34 \r
35                 // Declaration of the class ApplicationHandler (Singleton).\r
36                 class SIMGRIDX_EXPORT ApplicationHandler\r
37                 {\r
38                         //friend Process;\r
39 \r
40                 public:\r
41 \r
42                         class ProcessFactory \r
43                         {\r
44                                 public:\r
45                                         \r
46                                         // the list of the argument of the process to create.\r
47                                         xbt_dynar_t args;\r
48                                         // the properties of the process to create\r
49                                         xbt_dict_t properties;\r
50                       \r
51                                 private:\r
52                                         \r
53                                         // the current host name parsed\r
54                                         const char* hostName;\r
55                                         // the name of the class of the process\r
56                                         const char* function;\r
57                         \r
58                                 public :\r
59                         \r
60                                         // Default constructor.\r
61                                         ProcessFactory(); \r
62                                         \r
63                                         // Copy constructor.\r
64                                         ProcessFactory(const ProcessFactory& rProcessFactory);\r
65                                         \r
66                                         // Destructor.\r
67                                         virtual ~ProcessFactory();\r
68                                         \r
69                                         // Set the identity of the current process.\r
70                                         void setProcessIdentity(const char* hostName, const char* function);\r
71                                 \r
72                                 // Register an argument of the current process.\r
73                                 void registerProcessArg(const char* arg); \r
74                                         \r
75                                         // Set the property of the current process.\r
76                                         void setProperty(const char* id, const char* value);\r
77                                         \r
78                                         // Return the host name of the current process.\r
79                                         const char* getHostName(void);\r
80                                         \r
81                                         // Create the current process.\r
82                                 void createProcess(void)\r
83                                 throw (ClassNotFoundException, HostNotFoundException); \r
84 \r
85                                         static void freeCstr(void* cstr);\r
86                         \r
87                         };\r
88 \r
89                 private :\r
90                         \r
91                         // Desable the default constructor, the copy constructor , the assignement operator\r
92                         // and the destructor of this class. Assume that this class is static.\r
93                         \r
94                         // Default constructor.\r
95                         ApplicationHandler();\r
96                         \r
97                         // Copy constructor.\r
98                         ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
99                         \r
100                         // Destructor\r
101                         virtual ~ApplicationHandler();\r
102                         \r
103                         // Assignement operator.\r
104                         const ApplicationHandler& operator = (const ApplicationHandler& rApplicationHandler);\r
105                         \r
106                         // the process factory used by the application handler.\r
107                         static ProcessFactory* processFactory;\r
108                         \r
109                         \r
110                         public:\r
111                         \r
112                         // Handle the begining of the parsing of the xml file describing the application.\r
113                         static void onStartDocument(void);\r
114                         \r
115                         // Handle at the end of the parsing.\r
116                         static void onEndDocument(void);\r
117                         \r
118                         // Handle the begining of the parsing of a xml process element.\r
119                         static void onBeginProcess(void);\r
120                         \r
121                         // Handle the parsing of an argument of the current xml process element.\r
122                         static void onProcessArg(void);\r
123                         \r
124                         // Handle the parsing of a property of the currnet xml process element.\r
125                         static void OnProperty(void);\r
126                         \r
127                         // Handle the end of the parsing of a xml process element\r
128                         static void onEndProcess(void);\r
129                 };\r
130 \r
131         } // namespace Msg\r
132 } // namespace SimGrid\r
133 \r
134 #endif // !MSG_APPLICATION_HANDLER_HPP\r
135 \r