Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add comment and exception mechanism to the Host class.
[simgrid.git] / src / cxx / ApplicationHandler.hpp
1 #ifndef MSG_APPLICATION_HANDLER_HPP\r
2 #define MSG_APPLICATION_HANDLER_HPP\r
3 \r
4 // Compilation C++ recquise\r
5 #ifndef __cplusplus\r
6         #error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)\r
7 #endif\r
8 \r
9 #include <vector>\r
10 #include <map>\r
11 \r
12 namespace msg\r
13 {\r
14         \r
15         struct Compare\r
16         {\r
17                 public bool operator(const string& first, const string& second)\r
18                 {\r
19                         return first.compare(second);\r
20                 }\r
21         };\r
22         \r
23         typedef vector<string> Strings;\r
24         \r
25         typedef map<string, string, Compare> Properties;\r
26         \r
27         \r
28 class ApplicationHandler\r
29 {\r
30 private :\r
31         // Default constructor.\r
32         ApplicationHandler();\r
33         \r
34         // Copy constructor.\r
35         ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
36         \r
37         // Destructor\r
38         virtual ~ApplicationHandler();\r
39         \r
40         class ProcessFactory \r
41         {\r
42                 public:\r
43                 \r
44                         Strings* args;\r
45                         Properties* properties;\r
46       \r
47                 private:\r
48                         string hostName;\r
49                         string function;\r
50         \r
51                 public :\r
52         \r
53                 ProcessFactory() \r
54                 {\r
55                         this->args = new Strings();\r
56                         this->properties = new Properties();\r
57                         this->hostName = NULL;\r
58                         this->function = NULL;\r
59                 }      \r
60         \r
61                 void setProcessIdentity(const string& hostName, const string& function);\r
62     \r
63         void registerProcessArg(const string& arg) \r
64                 {\r
65                         this->args->push_back(arg);\r
66                 }\r
67 \r
68                 void setProperty(const string& id, const string& value)\r
69                 {\r
70                         this->properties->insert(Properties::value_type(id,value));     \r
71                 }\r
72 \r
73                 const String& getHostName(void)\r
74                 {\r
75                         return this->hostName;\r
76                 }\r
77 \r
78         void createProcess(void); \r
79         \r
80         };\r
81         \r
82         static ProcessFactory* processFactory;\r
83         \r
84         public:\r
85                 \r
86         static void onStartDocument(void);\r
87         \r
88         static void onEndDocument(void);\r
89                 \r
90         static void onBeginProcess(void);\r
91         \r
92         static void onProcessArg(void);\r
93         \r
94         static void OnProperty(void);\r
95         \r
96         static void onEndProcess(void);\r
97 };\r
98 \r
99 }\r
100 \r
101 #endif // !MSG_APPLICATION_HANDLER_HPP\r
102