Logo AND Algorithmique Numérique Distribuée

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