Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
not needed now
[simgrid.git] / src / cxx / ApplicationHandler.hpp
index d450321..df91691 100644 (file)
@@ -1,3 +1,17 @@
+/*\r
+ * ApplicationHandler.hpp\r
+ *\r
+ * This file contains the declaration of the wrapper class of the native MSG task type.\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */  \r
\r
 #ifndef MSG_APPLICATION_HANDLER_HPP\r
 #define MSG_APPLICATION_HANDLER_HPP\r
 \r
        #error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
-#include <vector>\r
-#include <map>\r
+#include <xbt/dict.h>\r
+#include <xbt/dynar.h>\r
 \r
-namespace msg\r
+#include <ClassNotFoundException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+\r
+namespace SimGrid\r
 {\r
-       \r
-       struct Compare\r
+       namespace Msg\r
        {\r
-               public bool operator(const string& first, const string& second)\r
+               class Process;\r
+\r
+               // Declaration of the class ApplicationHandler (Singleton).\r
+               class SIMGRIDX_EXPORT ApplicationHandler\r
                {\r
-                       return first.compare(second);\r
-               }\r
-       };\r
-       \r
-       typedef vector<string> Strings;\r
-       \r
-       typedef map<string, string, Compare> Properties;\r
-       \r
-       \r
-class ApplicationHandler\r
-{\r
-private :\r
-       // Default constructor.\r
-       ApplicationHandler();\r
-       \r
-       // Copy constructor.\r
-       ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
-       \r
-       // Destructor\r
-       virtual ~ApplicationHandler();\r
-       \r
-       class ProcessFactory \r
-       {\r
+                       //friend Process;\r
+\r
                public:\r
-               \r
-                       Strings* args;\r
-                       Properties* properties;\r
-      \r
-               private:\r
-                       string hostName;\r
-                       string function;\r
-        \r
-               public :\r
-       \r
-               ProcessFactory() \r
-               {\r
-                       this->args = new Strings();\r
-                       this->properties = new Properties();\r
-                       this->hostName = NULL;\r
-                       this->function = NULL;\r
-               }      \r
-       \r
-               void setProcessIdentity(const string& hostName, const string& function);\r
-    \r
-       void registerProcessArg(const string& arg) \r
-               {\r
-                       this->args->push_back(arg);\r
-               }\r
 \r
-               void setProperty(const string& id, const string& value)\r
-               {\r
-                       this->properties->insert(Properties::value_type(id,value));     \r
-               }\r
+                       class ProcessFactory \r
+                       {\r
+                               public:\r
+                                       \r
+                                       // the list of the argument of the process to create.\r
+                                       xbt_dynar_t args;\r
+                                       // the properties of the process to create\r
+                                       xbt_dict_t properties;\r
+                     \r
+                               private:\r
+                                       \r
+                                       // the current host name parsed\r
+                                       const char* hostName;\r
+                                       // the name of the class of the process\r
+                                       const char* function;\r
+                       \r
+                               public :\r
+                       \r
+                                       // Default constructor.\r
+                                       ProcessFactory(); \r
+                                       \r
+                                       // Copy constructor.\r
+                                       ProcessFactory(const ProcessFactory& rProcessFactory);\r
+                                       \r
+                                       // Destructor.\r
+                                       virtual ~ProcessFactory();\r
+                                       \r
+                                       // Set the identity of the current process.\r
+                                       void setProcessIdentity(const char* hostName, const char* function);\r
+                               \r
+                               // Register an argument of the current process.\r
+                               void registerProcessArg(const char* arg); \r
+                                       \r
+                                       // Set the property of the current process.\r
+                                       void setProperty(const char* id, const char* value);\r
+                                       \r
+                                       // Return the host name of the current process.\r
+                                       const char* getHostName(void);\r
+                                       \r
+                                       // Create the current process.\r
+                               void createProcess(void)\r
+                               throw (ClassNotFoundException, HostNotFoundException); \r
 \r
-               const String& getHostName(void)\r
-               {\r
-                       return this->hostName;\r
-               }\r
+                                       static void freeCstr(void* cstr);\r
+                       \r
+                       };\r
 \r
-       void createProcess(void); \r
-       \r
-       };\r
-       \r
-       static ProcessFactory* processFactory;\r
-       \r
-       public:\r
-               \r
-       static void onStartDocument(void);\r
-       \r
-       static void onEndDocument(void);\r
-               \r
-       static void onBeginProcess(void);\r
-       \r
-       static void onProcessArg(void);\r
-       \r
-       static void OnProperty(void);\r
-       \r
-       static void onEndProcess(void);\r
-};\r
+               private :\r
+                       \r
+                       // Desable the default constructor, the copy constructor , the assignement operator\r
+                       // and the destructor of this class. Assume that this class is static.\r
+                       \r
+                       // Default constructor.\r
+                       ApplicationHandler();\r
+                       \r
+                       // Copy constructor.\r
+                       ApplicationHandler(const ApplicationHandler& rApplicationHandler);\r
+                       \r
+                       // Destructor\r
+                       virtual ~ApplicationHandler();\r
+                       \r
+                       // Assignement operator.\r
+                       const ApplicationHandler& operator = (const ApplicationHandler& rApplicationHandler);\r
+                       \r
+                       // the process factory used by the application handler.\r
+                       static ProcessFactory* processFactory;\r
+                       \r
+                       \r
+                       public:\r
+                       \r
+                       // Handle the begining of the parsing of the xml file describing the application.\r
+                       static void onStartDocument(void);\r
+                       \r
+                       // Handle at the end of the parsing.\r
+                       static void onEndDocument(void);\r
+                       \r
+                       // Handle the begining of the parsing of a xml process element.\r
+                       static void onBeginProcess(void);\r
+                       \r
+                       // Handle the parsing of an argument of the current xml process element.\r
+                       static void onProcessArg(void);\r
+                       \r
+                       // Handle the parsing of a property of the currnet xml process element.\r
+                       static void OnProperty(void);\r
+                       \r
+                       // Handle the end of the parsing of a xml process element\r
+                       static void onEndProcess(void);\r
+               };\r
 \r
-}\r
+       } // namespace Msg\r
+} // namespace SimGrid\r
 \r
 #endif // !MSG_APPLICATION_HANDLER_HPP\r
-       
\ No newline at end of file
+\r