Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some modifications and some files added.
[simgrid.git] / src / cxx / ApplicationHandler.cxx
1 #include <ApplicationHandler.hpp>\r
2 \r
3 namespace msg\r
4 {\r
5         \r
6 ApplicationHandler::ProcessFactory::processFactory = NULL;\r
7         \r
8 void ApplicationHandler::onStartDocument(void)\r
9 {\r
10         processFactory = new ProcessFactory();  \r
11 }\r
12 \r
13 void ApplicationHandler::onEndDocument(void)\r
14 {\r
15         if(processFactory)\r
16                 delete processFactroy;\r
17 }\r
18         \r
19 void ApplicationHandler::onBeginProcess(void)\r
20 {\r
21         processFactory->setProcessIdentity(A_surfxml_process_host, A_surfxml_process_function);\r
22 }               \r
23 \r
24 void ApplicationHandler::onProcessArg(void)\r
25 {\r
26         processFactory->registerProcessArg(A_surfxml_argument_value);\r
27 }\r
28 \r
29 void ApplicationHandler::OnProperty(void)\r
30 {\r
31          processFactory->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);\r
32 }\r
33 \r
34 void ApplicationHandler::onEndProcess(void)\r
35 {\r
36         processFactory->createProcess();\r
37 }\r
38 \r
39 void ApplicationHandler::ProcessFactory::createProcess() \r
40         {\r
41         Process* process = (Process*)Class::fromName(this->function);\r
42                 \r
43                 Host host = Host::getByName(this->hostName);\r
44 \r
45         process->create();\r
46         \r
47         Strings* args = processFactory->args;\r
48         \r
49         int size = args->size();\r
50 \r
51         for (int index = 0; index < size; index++)\r
52                 process->args->push_back(args->at(index));\r
53       \r
54         process->properties = this->properties;\r
55         this->properties = new Properties();\r
56         }\r
57         \r
58 void ApplicationHandler::ProcessFactory::setProcessIdentity(const string& hostName, const string& function) \r
59 {\r
60         this->hostName = hostName;\r
61         this->function = function;\r
62 \r
63         if (!this->args->empty())\r
64                 this->args->clear();\r
65 \r
66         if(!this->properties->empty())\r
67                 this->properties->clear();\r
68 }\r
69 \r
70 }