Logo AND Algorithmique Numérique Distribuée

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