Logo AND Algorithmique Numérique Distribuée

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