Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
last change of cpp wrappers for msg
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 19 Aug 2008 15:48:47 +0000 (15:48 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 19 Aug 2008 15:48:47 +0000 (15:48 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5894 48e7efb5-ca39-0410-a469-dd3cf9ba447f

43 files changed:
src/cxx/Application.cxx
src/cxx/Application.hpp
src/cxx/ApplicationHandler.cxx
src/cxx/ApplicationHandler.hpp
src/cxx/BadAllocException.cxx
src/cxx/BadAllocException.hpp
src/cxx/ClassNotFoundException.cxx
src/cxx/ClassNotFoundException.hpp
src/cxx/Config.hpp
src/cxx/Environment.cxx
src/cxx/Environment.hpp
src/cxx/Exception.cxx
src/cxx/Exception.hpp
src/cxx/FileNotFoundException.cxx
src/cxx/FileNotFoundException.hpp
src/cxx/Host.cxx
src/cxx/Host.hpp
src/cxx/HostNotFoundException.cxx
src/cxx/HostNotFoundException.hpp
src/cxx/InvalidArgumentException.cxx
src/cxx/InvalidArgumentException.hpp
src/cxx/LogicException.cxx
src/cxx/LogicException.hpp
src/cxx/Msg.cxx
src/cxx/Msg.hpp
src/cxx/MsgException.cxx
src/cxx/MsgException.hpp
src/cxx/NullPointerException.cxx
src/cxx/NullPointerException.hpp
src/cxx/Object.cxx
src/cxx/Object.hpp
src/cxx/OutOfBoundsException.cxx
src/cxx/OutOfBoundsException.hpp
src/cxx/Process.cxx
src/cxx/Process.hpp
src/cxx/ProcessNotFoundException.cxx
src/cxx/ProcessNotFoundException.hpp
src/cxx/Simulation.cxx
src/cxx/Simulation.hpp
src/cxx/StringHelper.cxx
src/cxx/StringHelper.hpp
src/cxx/Task.cxx
src/cxx/Task.hpp

index c188ffb..ca37d24 100644 (file)
-/*\r
- * Application.cxx\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
- /* Application member functions implementation.\r
-  */  \r
-\r
-#include <ApplicationHandler.hpp>\r
-\r
-#include <Application.hpp>\r
-\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-#include <stdlib.h>\r
-\r
-#include <surf/surfxml_parse.h>\r
-\r
-#ifndef S_ISREG\r
-       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
-#endif\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-       \r
-               Application::Application()\r
-               {\r
-                       this->file = NULL;\r
-                       this->deployed = false;\r
-               }\r
-                               \r
-               Application::Application(const Application& rApplication)\r
-               {\r
-                               \r
-                       this->file = rApplication.getFile();\r
-                       this->deployed = rApplication.isDeployed();\r
-               }\r
-       \r
-               Application::Application(const char* file)\r
-               throw(NullPointerException, FileNotFoundException)\r
-               {\r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException(file);\r
-                               \r
-                       this->file = file;\r
-                       this->deployed = false;\r
-               }\r
-               \r
-               Application::~Application()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-                       \r
-               void Application::deploy(const char* file)\r
-               throw(NullPointerException, FileNotFoundException, LogicException, MsgException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       // check the parameters\r
-                               \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException(file);\r
-                                       \r
-                       surf_parse_reset_parser();\r
-                       \r
-                       // set the begin of the xml process element handler\r
-                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
-                               \r
-                       // set the process arg handler\r
-                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
-                               \r
-                       // set the properties handler\r
-                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
-                               \r
-                       // set the end of the xml process element handler\r
-                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
-\r
-                       surf_parse_open(file);\r
-                       \r
-                       // initialize the process factory used by the process handler to build the processes.\r
-                       ApplicationHandler::onStartDocument();\r
-                               \r
-                       if(surf_parse())\r
-                               throw MsgException("surf_parse() failed");\r
-                       \r
-                       surf_parse_close();\r
-                       \r
-                       // release the process factory\r
-                       ApplicationHandler::onEndDocument();    \r
-                       \r
-                       this->file = file;\r
-                       this->deployed = true;\r
-               }\r
-               \r
-               void Application::deploy(void)\r
-               throw(LogicException, MsgException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       // check the parameters\r
-                       if(!this->file)\r
-                               throw LogicException("you must specify the xml file which describe the application\nuse Application::setFile()"); \r
-                       \r
-                       surf_parse_reset_parser();\r
-                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
-                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
-                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
-                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
-                       \r
-                       // initialize the process factory used by the process handler to build the processes.\r
-                       ApplicationHandler::onStartDocument();\r
-\r
-                       surf_parse_open(file);\r
-                       \r
-                       if(surf_parse())\r
-                               throw MsgException("surf_parse() failed");\r
-                       \r
-                       surf_parse_close();\r
-                       \r
-                       this->deployed = true;  \r
-               }\r
-               \r
-               bool Application::isDeployed(void) const\r
-               {\r
-                       return this->deployed;\r
-               }\r
-               \r
-               void Application::setFile(const char* file)\r
-               throw (NullPointerException, FileNotFoundException, LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("your are trying to change the file of an already deployed application");\r
-                               \r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException("file (file not found)");\r
-                               \r
-                       this->file = file;\r
-                       \r
-               }\r
-               \r
-               const char* Application::getFile(void) const\r
-               {\r
-                       return this->file;\r
-               }\r
-               \r
-               const Application& Application::operator = (const Application& rApplication)\r
-               throw(LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       this->file = rApplication.getFile();\r
-                       this->deployed = rApplication.isDeployed();\r
-                       \r
-                       return *this;\r
-               }\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * Application.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Application member functions implementation.
+  */  
+
+#include <ApplicationHandler.hpp>
+
+#include <Application.hpp>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+#include <surf/surfxml_parse.h>
+
+#ifndef S_ISREG
+       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
+#endif
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+       
+               Application::Application()
+               {
+                       this->file = NULL;
+                       this->deployed = false;
+               }
+                               
+               Application::Application(const Application& rApplication)
+               {
+                               
+                       this->file = rApplication.getFile();
+                       this->deployed = rApplication.isDeployed();
+               }
+       
+               Application::Application(const char* file)
+               throw(NullPointerException, FileNotFoundException)
+               {
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException(file);
+                               
+                       this->file = file;
+                       this->deployed = false;
+               }
+               
+               Application::~Application()
+               {
+                       // NOTHING TODO
+               }
+                       
+               void Application::deploy(const char* file)
+               throw(NullPointerException, FileNotFoundException, LogicException, MsgException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       // check the parameters
+                               
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException(file);
+                                       
+                       surf_parse_reset_parser();
+                       
+                       // set the begin of the xml process element handler
+                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);
+                               
+                       // set the process arg handler
+                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);
+                               
+                       // set the properties handler
+                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);
+                               
+                       // set the end of the xml process element handler
+                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);
+
+                       surf_parse_open(file);
+                       
+                       // initialize the process factory used by the process handler to build the processes.
+                       ApplicationHandler::onStartDocument();
+                               
+                       if(surf_parse())
+                               throw MsgException("surf_parse() failed");
+                       
+                       surf_parse_close();
+                       
+                       // release the process factory
+                       ApplicationHandler::onEndDocument();    
+                       
+                       this->file = file;
+                       this->deployed = true;
+               }
+               
+               void Application::deploy(void)
+               throw(LogicException, MsgException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       // check the parameters
+                       if(!this->file)
+                               throw LogicException("you must specify the xml file which describe the application\nuse Application::setFile()"); 
+                       
+                       surf_parse_reset_parser();
+                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);
+                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);
+                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);
+                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);
+                       
+                       // initialize the process factory used by the process handler to build the processes.
+                       ApplicationHandler::onStartDocument();
+
+                       surf_parse_open(file);
+                       
+                       if(surf_parse())
+                               throw MsgException("surf_parse() failed");
+                       
+                       surf_parse_close();
+                       
+                       this->deployed = true;  
+               }
+               
+               bool Application::isDeployed(void) const
+               {
+                       return this->deployed;
+               }
+               
+               void Application::setFile(const char* file)
+               throw (NullPointerException, FileNotFoundException, LogicException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("your are trying to change the file of an already deployed application");
+                               
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException("file (file not found)");
+                               
+                       this->file = file;
+                       
+               }
+               
+               const char* Application::getFile(void) const
+               {
+                       return this->file;
+               }
+               
+               const Application& Application::operator = (const Application& rApplication)
+               throw(LogicException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       this->file = rApplication.getFile();
+                       this->deployed = rApplication.isDeployed();
+                       
+                       return *this;
+               }
+       } // namespace Msg
+} // namespace SimGrid
+
+
+
index c281870..925c1ef 100644 (file)
-/*\r
- * Application.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_HPP\r
-#define MSG_APPLICATION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error Application.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               // Application wrapper class declaration.\r
-               class SIMGRIDX_EXPORT Application\r
-               {\r
-               public:\r
-                       \r
-                       /*! \brief Default constructor.\r
-                        */\r
-                       Application();\r
-                       \r
-                       /*! \brief Copy constructor.\r
-                        */\r
-                       Application(const Application& rApplication);\r
-                       \r
-                       /* \brief A constructor which takes as parameter the xml file of the application.\r
-                        *\r
-                        * \exception           If this constructor fails, it throws on of the exceptions described\r
-                        *                                      below:\r
-                        *              \r
-                        *                                      [NullPointerException]  if the parameter file is NULL.\r
-                        *\r
-                        *                                      [FileNotFoundException] if the file is not found.\r
-                        */\r
-                       Application(const char* file)\r
-                       throw(NullPointerException, FileNotFoundException);\r
-                       \r
-                       /*! \brief Destructor.\r
-                        */\r
-                       virtual ~Application();\r
-                       \r
-               // Operations.\r
-                       \r
-                       /*! \brief Application::deploy() - deploy the appliction.\r
-                        *\r
-                        * \exception           If this method fails, it throws an exception listed below:\r
-                        *\r
-                        * \exception           [LogicException]                        if the xml file which describes the application\r
-                        *                                                                                              is not yet specified or if the application is already\r
-                        *                                                                                              deployed.\r
-                        *                                      [MsgException]                          if a internal exception occurs.\r
-                        *\r
-                        * \remark                      Before use this method, you must specify the xml file of the application to\r
-                        *                                      deploy.\r
-                        *\r
-                        * \see                         Application::setFile()\r
-                        */\r
-                        \r
-                       void deploy(void)\r
-                       throw(LogicException, MsgException);\r
-                       \r
-                       /*! \brief Application::deploy() - Deploy the appliction.\r
-                        *\r
-                        * \return                      If successfuly the application is deployed. Otherwise\r
-                        *                                      the method throws an exception listed below.\r
-                        *\r
-                        * \exception           [NullPointerException]          if the parameter file is NULL.\r
-                        *                                      \r
-                        *                                      [FileNotFoundException]         if the file is not found.\r
-                        *\r
-                        *                                      [MsgException]                          if a internal exception occurs.\r
-                        *\r
-                        *                                      [LogicException]                        if the application is already deployed.\r
-                        *\r
-                        * \\r
-                        */\r
-                       void deploy(const char* file)\r
-                       throw(NullPointerException, FileNotFoundException, LogicException, MsgException);\r
-                       \r
-                       /*! \brief Application::isDeployed() - Tests if the application is deployed.\r
-                        *\r
-                        * \return                      This method returns true is the application is deployed.\r
-                        *                                      Otherwise the method returns false.\r
-                        */\r
-                       bool isDeployed(void) const;\r
-                       \r
-                       \r
-               // Getters/setters\r
-                       \r
-                       /*! \brief Application::setFile() - this setter sets the value of the file of the application.\r
-                        *\r
-                        * \exception           If this method fails, it throws on of the exceptions listed below:\r
-                        *\r
-                        *                                      [NullPointerException]          if the parameter file is NULL.\r
-                        *\r
-                        *                                      [FileNotFoundException]         if the file is not found.\r
-                        \r
-                        *                                      [LogicException]                        if you try to set the value of the file of an\r
-                        *                                                                                              application which is already deployed.\r
-                        */\r
-                       void setFile(const char* file)\r
-                       throw (NullPointerException, FileNotFoundException, LogicException);\r
-                       \r
-                       /*! \brief Application::getFile() - This getter returns the name of the xml file which describes the \r
-                        * application of the simulation.\r
-                        */\r
-                       const char* getFile(void) const;\r
-                       \r
-               // Operators.\r
-                       \r
-                       /*! \brief Assignement operator.\r
-                        *\r
-                        * \exception           [LogicException]                        if you try to assign an application already deployed.\r
-                        */\r
-                       const Application& operator = (const Application& rApplication)\r
-                       throw(LogicException);\r
-                       \r
-               private:\r
-               // Attributes.\r
-                       \r
-                       // flag : if true the application was deployed.\r
-                       bool deployed;\r
-                       \r
-                       // the xml file which describes the application of the simulation.\r
-                       const char* file;\r
-\r
-               };\r
-               \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_APPLICATION_HPP\r
-\r
+/*
+ * Application.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_APPLICATION_HPP
+#define MSG_APPLICATION_HPP
+
+#ifndef __cplusplus
+       #error Application.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <NullPointerException.hpp>
+#include <FileNotFoundException.hpp>
+#include <LogicException.hpp>
+#include <MsgException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               // Application wrapper class declaration.
+               class SIMGRIDX_EXPORT Application
+               {
+               public:
+                       
+                       /*! \brief Default constructor.
+                        */
+                       Application();
+                       
+                       /*! \brief Copy constructor.
+                        */
+                       Application(const Application& rApplication);
+                       
+                       /* \brief A constructor which takes as parameter the xml file of the application.
+                        *
+                        * \exception           If this constructor fails, it throws on of the exceptions described
+                        *                                      below:
+                        *              
+                        *                                      [NullPointerException]  if the parameter file is NULL.
+                        *
+                        *                                      [FileNotFoundException] if the file is not found.
+                        */
+                       Application(const char* file)
+                       throw(NullPointerException, FileNotFoundException);
+                       
+                       /*! \brief Destructor.
+                        */
+                       virtual ~Application();
+                       
+               // Operations.
+                       
+                       /*! \brief Application::deploy() - deploy the appliction.
+                        *
+                        * \exception           If this method fails, it throws an exception listed below:
+                        *
+                        * \exception           [LogicException]                        if the xml file which describes the application
+                        *                                                                                              is not yet specified or if the application is already
+                        *                                                                                              deployed.
+                        *                                      [MsgException]                          if a internal exception occurs.
+                        *
+                        * \remark                      Before use this method, you must specify the xml file of the application to
+                        *                                      deploy.
+                        *
+                        * \see                         Application::setFile()
+                        */
+                        
+                       void deploy(void)
+                       throw(LogicException, MsgException);
+                       
+                       /*! \brief Application::deploy() - Deploy the appliction.
+                        *
+                        * \return                      If successfuly the application is deployed. Otherwise
+                        *                                      the method throws an exception listed below.
+                        *
+                        * \exception           [NullPointerException]          if the parameter file is NULL.
+                        *                                      
+                        *                                      [FileNotFoundException]         if the file is not found.
+                        *
+                        *                                      [MsgException]                          if a internal exception occurs.
+                        *
+                        *                                      [LogicException]                        if the application is already deployed.
+                        *
+                        * \
+                        */
+                       void deploy(const char* file)
+                       throw(NullPointerException, FileNotFoundException, LogicException, MsgException);
+                       
+                       /*! \brief Application::isDeployed() - Tests if the application is deployed.
+                        *
+                        * \return                      This method returns true is the application is deployed.
+                        *                                      Otherwise the method returns false.
+                        */
+                       bool isDeployed(void) const;
+                       
+                       
+               // Getters/setters
+                       
+                       /*! \brief Application::setFile() - this setter sets the value of the file of the application.
+                        *
+                        * \exception           If this method fails, it throws on of the exceptions listed below:
+                        *
+                        *                                      [NullPointerException]          if the parameter file is NULL.
+                        *
+                        *                                      [FileNotFoundException]         if the file is not found.
+                        
+                        *                                      [LogicException]                        if you try to set the value of the file of an
+                        *                                                                                              application which is already deployed.
+                        */
+                       void setFile(const char* file)
+                       throw (NullPointerException, FileNotFoundException, LogicException);
+                       
+                       /*! \brief Application::getFile() - This getter returns the name of the xml file which describes the 
+                        * application of the simulation.
+                        */
+                       const char* getFile(void) const;
+                       
+               // Operators.
+                       
+                       /*! \brief Assignement operator.
+                        *
+                        * \exception           [LogicException]                        if you try to assign an application already deployed.
+                        */
+                       const Application& operator = (const Application& rApplication)
+                       throw(LogicException);
+                       
+               private:
+               // Attributes.
+                       
+                       // flag : if true the application was deployed.
+                       bool deployed;
+                       
+                       // the xml file which describes the application of the simulation.
+                       const char* file;
+
+               };
+               
+       } // namespace Msg
+} // namespace SimGrid
+
+#endif // !MSG_APPLICATION_HPP
+
index 3b48213..2673dbb 100644 (file)
-/*\r
- * ApplicationHandler.cxx\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
- /* ApplicationHandler member functions implementation.\r
-  */  \r
-\r
-\r
-#include <Object.hpp>\r
-#include <ApplicationHandler.hpp>\r
-\r
-#include <Process.hpp>\r
-#include <Host.hpp>\r
-\r
-\r
-\r
-\r
-\r
-#include <stdlib.h>\r
-\r
-#include <surf/surfxml_parse.h>\r
-#include <xbt/sysdep.h>\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               ApplicationHandler::ProcessFactory* ApplicationHandler::processFactory = NULL;\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::ApplicationHandler()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-               \r
-               // Copy constructor.\r
-               ApplicationHandler::ApplicationHandler(const ApplicationHandler& rApplicationHandler)\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-               \r
-               // Destructor\r
-               ApplicationHandler::~ApplicationHandler()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-               \r
-               // Assignement operator.\r
-               const ApplicationHandler& ApplicationHandler::operator = (const ApplicationHandler& rApplicationHandler)\r
-               {\r
-                       return *this;\r
-               }\r
-               \r
-               void ApplicationHandler::onStartDocument(void)\r
-               {\r
-                       // instanciate the factory at the begining of the parsing\r
-                       processFactory = new ProcessFactory();  \r
-               }\r
-               \r
-               void ApplicationHandler::onEndDocument(void)\r
-               {\r
-                       // release the handler at the end of the parsing.\r
-                       if(processFactory)\r
-                               delete processFactory;\r
-               }\r
-                       \r
-               void ApplicationHandler::onBeginProcess(void)\r
-               {\r
-                       // set the process identity at the begin of the xml process element.\r
-                       processFactory->setProcessIdentity(A_surfxml_process_host, A_surfxml_process_function);\r
-               }               \r
-               \r
-               void ApplicationHandler::onProcessArg(void)\r
-               {\r
-                       // register the argument of the current xml process element.\r
-                       processFactory->registerProcessArg(A_surfxml_argument_value);\r
-               }\r
-               \r
-               void ApplicationHandler::OnProperty(void)\r
-               {\r
-                       // set the property of the current xml process element.\r
-                        processFactory->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);\r
-               }\r
-               \r
-               void ApplicationHandler::onEndProcess(void)\r
-               {\r
-                       // at the end of the xml process element create the wrapper process (of the native Msg process)\r
-                       processFactory->createProcess();\r
-               }\r
-               \r
-               /////////////////////////////////////////////////////////////////////////////////////////////////\r
-               // Process factory connected member functions\r
-               \r
-               ApplicationHandler::ProcessFactory::ProcessFactory() \r
-               {\r
-                       this->args = xbt_dynar_new(sizeof(char*),ApplicationHandler::ProcessFactory::freeCstr);\r
-                       this->properties = NULL; // TODO instanciate the dictionary\r
-                       this->hostName = NULL;\r
-                       this->function = NULL;\r
-               } \r
-\r
-               ApplicationHandler::ProcessFactory::~ProcessFactory()\r
-               {\r
-                       xbt_dynar_free(&(this->args));\r
-               }\r
-               \r
-               // create the cxx process wrapper.\r
-               void ApplicationHandler::ProcessFactory::createProcess() \r
-               throw (ClassNotFoundException, HostNotFoundException)\r
-               {\r
-                       Host host;\r
-                       Class* c;\r
-                       Process* process;\r
-                       \r
-                       // try to dynamicaly create an instance fo the process from its name (which is specified by the element function\r
-                       // in the xml application file.\r
-                       // if this static method fails, it throws an exception of the class ClassNotFoundException\r
-                       c = Class::fromName(this->function);\r
-                       process = reinterpret_cast<Process*>(c->createObject());\r
-                       \r
-                       // try to retrieve the host of the process from its name\r
-                       // if this method fails, it throws an exception of the class HostNotFoundException\r
-                       host = Host::getByName(this->hostName); \r
-                       \r
-                       // build the list of the arguments of the newly created process.\r
-                       int argc = xbt_dynar_length(this->args);\r
-                       \r
-                       char** argv = (char**)calloc(argc, sizeof(char*));\r
-                       \r
-                       for(int i = argc -1; i >= 0; i--)\r
-                               xbt_dynar_pop(this->args, &(argv[i]));\r
-                       \r
-                       // finaly create the process (for more detail on the process creation see Process::create()\r
-                       process->create(host, this->function , argc, argv);\r
-                       \r
-                       // TODO add the properties of the process\r
-                       /*process->properties = this->properties;\r
-                       this->properties = new Properties();*/\r
-               }\r
-                       \r
-               void ApplicationHandler::ProcessFactory::setProcessIdentity(const char* hostName, const char* function) \r
-               {\r
-                       this->hostName = hostName;\r
-                       this->function = function;\r
-               \r
-                       /*if (!this->args->empty())\r
-                               this->args->clear();\r
-               \r
-                       if(!this->properties->empty())\r
-                               this->properties->clear();*/\r
-               }\r
-               \r
-               // callback function used by the dynamic array to cleanup all of its elements.\r
-               void ApplicationHandler::ProcessFactory::freeCstr(void* cstr)\r
-               {\r
-                       free(*(void**)cstr);\r
-               }\r
-               \r
-               void ApplicationHandler::ProcessFactory::registerProcessArg(const char* arg) \r
-               {\r
-                       char* cstr = _strdup(arg);\r
-                       xbt_dynar_push(this->args, &cstr);\r
-               }\r
-               \r
-               void ApplicationHandler::ProcessFactory::setProperty(const char* id, const char* value)\r
-               {\r
-                       // TODO implement this function;        \r
-               }\r
-               \r
-               const char* ApplicationHandler::ProcessFactory::getHostName(void)\r
-               {\r
-                       return this->hostName;\r
-               }\r
-\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
+/*
+ * ApplicationHandler.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* ApplicationHandler member functions implementation.
+  */  
+
+
+#include <Object.hpp>
+#include <ApplicationHandler.hpp>
+
+#include <Process.hpp>
+#include <Host.hpp>
+
+
+
+
+
+#include <stdlib.h>
+
+#include <surf/surfxml_parse.h>
+#include <xbt/sysdep.h>
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               ApplicationHandler::ProcessFactory* ApplicationHandler::processFactory = NULL;
+                       
+               // Desable the default constructor, the copy constructor , the assignement operator
+               // and the destructor of this class. Assume that this class is static.
+               
+               // Default constructor.
+               ApplicationHandler::ApplicationHandler()
+               {
+                       // NOTHING TODO
+               }
+               
+               // Copy constructor.
+               ApplicationHandler::ApplicationHandler(const ApplicationHandler& rApplicationHandler)
+               {
+                       // NOTHING TODO
+               }
+               
+               // Destructor
+               ApplicationHandler::~ApplicationHandler()
+               {
+                       // NOTHING TODO
+               }
+               
+               // Assignement operator.
+               const ApplicationHandler& ApplicationHandler::operator = (const ApplicationHandler& rApplicationHandler)
+               {
+                       return *this;
+               }
+               
+               void ApplicationHandler::onStartDocument(void)
+               {
+                       // instanciate the factory at the begining of the parsing
+                       processFactory = new ProcessFactory();  
+               }
+               
+               void ApplicationHandler::onEndDocument(void)
+               {
+                       // release the handler at the end of the parsing.
+                       if(processFactory)
+                               delete processFactory;
+               }
+                       
+               void ApplicationHandler::onBeginProcess(void)
+               {
+                       // set the process identity at the begin of the xml process element.
+                       processFactory->setProcessIdentity(A_surfxml_process_host, A_surfxml_process_function);
+               }               
+               
+               void ApplicationHandler::onProcessArg(void)
+               {
+                       // register the argument of the current xml process element.
+                       processFactory->registerProcessArg(A_surfxml_argument_value);
+               }
+               
+               void ApplicationHandler::OnProperty(void)
+               {
+                       // set the property of the current xml process element.
+                        processFactory->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
+               }
+               
+               void ApplicationHandler::onEndProcess(void)
+               {
+                       // at the end of the xml process element create the wrapper process (of the native Msg process)
+                       processFactory->createProcess();
+               }
+               
+               /////////////////////////////////////////////////////////////////////////////////////////////////
+               // Process factory connected member functions
+               
+               ApplicationHandler::ProcessFactory::ProcessFactory() 
+               {
+                       this->args = xbt_dynar_new(sizeof(char*),ApplicationHandler::ProcessFactory::freeCstr);
+                       this->properties = NULL; // TODO instanciate the dictionary
+                       this->hostName = NULL;
+                       this->function = NULL;
+               } 
+
+               ApplicationHandler::ProcessFactory::~ProcessFactory()
+               {
+                       xbt_dynar_free(&(this->args));
+               }
+               
+               // create the cxx process wrapper.
+               void ApplicationHandler::ProcessFactory::createProcess() 
+               throw (ClassNotFoundException, HostNotFoundException)
+               {
+                       Host host;
+                       Class* c;
+                       Process* process;
+                       
+                       // try to dynamicaly create an instance of the process from its name (which is specified by the element function
+                       // in the xml application file.
+                       // if this static method fails, it throws an exception of the class ClassNotFoundException
+                       c = Class::fromName(this->function);
+                       process = reinterpret_cast<Process*>(c->createObject());
+                       
+                       // try to retrieve the host of the process from its name
+                       // if this method fails, it throws an exception of the class HostNotFoundException
+                       host = Host::getByName(this->hostName); 
+                       
+                       // build the list of the arguments of the newly created process.
+                       int argc = xbt_dynar_length(this->args);
+                       
+                       char** argv = (char**)calloc(argc, sizeof(char*));
+                       
+                       for(int i = argc -1; i >= 0; i--)
+                               xbt_dynar_pop(this->args, &(argv[i]));
+                       
+                       // finaly create the process (for more detail on the process creation see Process::create()
+                       process->create(host, this->function , argc, argv);
+                       
+                       // TODO add the properties of the process
+                       /*process->properties = this->properties;
+                       this->properties = new Properties();*/
+               }
+                       
+               void ApplicationHandler::ProcessFactory::setProcessIdentity(const char* hostName, const char* function) 
+               {
+                       this->hostName = hostName;
+                       this->function = function;
+               
+                       /*if (!this->args->empty())
+                               this->args->clear();
+               
+                       if(!this->properties->empty())
+                               this->properties->clear();*/
+               }
+               
+               // callback function used by the dynamic array to cleanup all of its elements.
+               void ApplicationHandler::ProcessFactory::freeCstr(void* cstr)
+               {
+                       free(*(void**)cstr);
+               }
+               
+               void ApplicationHandler::ProcessFactory::registerProcessArg(const char* arg) 
+               {
+                       char* cstr = _strdup(arg);
+                       xbt_dynar_push(this->args, &cstr);
+               }
+               
+               void ApplicationHandler::ProcessFactory::setProperty(const char* id, const char* value)
+               {
+                       // TODO implement this function;        
+               }
+               
+               const char* ApplicationHandler::ProcessFactory::getHostName(void)
+               {
+                       return this->hostName;
+               }
+
+       } // namespace Msg
+} // namespace SimGrid
+
index df91691..46c7c8a 100644 (file)
-/*\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
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
-       #error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <xbt/dict.h>\r
-#include <xbt/dynar.h>\r
-\r
-#include <ClassNotFoundException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class Process;\r
-\r
-               // Declaration of the class ApplicationHandler (Singleton).\r
-               class SIMGRIDX_EXPORT ApplicationHandler\r
-               {\r
-                       //friend Process;\r
-\r
-               public:\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
-                                       static void freeCstr(void* cstr);\r
-                       \r
-                       };\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
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_APPLICATION_HANDLER_HPP\r
-\r
+/*
+ * ApplicationHandler.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_APPLICATION_HANDLER_HPP
+#define MSG_APPLICATION_HANDLER_HPP
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+       #error ApplicationHandler.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <xbt/dict.h>
+#include <xbt/dynar.h>
+
+#include <ClassNotFoundException.hpp>
+#include <HostNotFoundException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class Process;
+
+               // Declaration of the class ApplicationHandler (Singleton).
+               class SIMGRIDX_EXPORT ApplicationHandler
+               {
+                       //friend Process;
+
+               public:
+
+                       class ProcessFactory 
+                       {
+                               public:
+                                       
+                                       // the list of the argument of the process to create.
+                                       xbt_dynar_t args;
+                                       // the properties of the process to create
+                                       xbt_dict_t properties;
+                     
+                               private:
+                                       
+                                       // the current host name parsed
+                                       const char* hostName;
+                                       // the name of the class of the process
+                                       const char* function;
+                       
+                               public :
+                       
+                                       // Default constructor.
+                                       ProcessFactory(); 
+                                       
+                                       // Copy constructor.
+                                       ProcessFactory(const ProcessFactory& rProcessFactory);
+                                       
+                                       // Destructor.
+                                       virtual ~ProcessFactory();
+                                       
+                                       // Set the identity of the current process.
+                                       void setProcessIdentity(const char* hostName, const char* function);
+                               
+                               // Register an argument of the current process.
+                               void registerProcessArg(const char* arg); 
+                                       
+                                       // Set the property of the current process.
+                                       void setProperty(const char* id, const char* value);
+                                       
+                                       // Return the host name of the current process.
+                                       const char* getHostName(void);
+                                       
+                                       // Create the current process.
+                               void createProcess(void)
+                               throw (ClassNotFoundException, HostNotFoundException); 
+
+                                       static void freeCstr(void* cstr);
+                       
+                       };
+
+               private :
+                       
+                       // Desable the default constructor, the copy constructor , the assignement operator
+                       // and the destructor of this class. Assume that this class is static.
+                       
+                       // Default constructor.
+                       ApplicationHandler();
+                       
+                       // Copy constructor.
+                       ApplicationHandler(const ApplicationHandler& rApplicationHandler);
+                       
+                       // Destructor
+                       virtual ~ApplicationHandler();
+                       
+                       // Assignement operator.
+                       const ApplicationHandler& operator = (const ApplicationHandler& rApplicationHandler);
+                       
+                       // the process factory used by the application handler.
+                       static ProcessFactory* processFactory;
+                       
+                       
+                       public:
+                       
+                       // Handle the begining of the parsing of the xml file describing the application.
+                       static void onStartDocument(void);
+                       
+                       // Handle at the end of the parsing.
+                       static void onEndDocument(void);
+                       
+                       // Handle the begining of the parsing of a xml process element.
+                       static void onBeginProcess(void);
+                       
+                       // Handle the parsing of an argument of the current xml process element.
+                       static void onProcessArg(void);
+                       
+                       // Handle the parsing of a property of the currnet xml process element.
+                       static void OnProperty(void);
+                       
+                       // Handle the end of the parsing of a xml process element
+                       static void onEndProcess(void);
+               };
+
+       } // namespace Msg
+} // namespace SimGrid
+
+#endif // !MSG_APPLICATION_HANDLER_HPP
+
index 265f5de..24d0279 100644 (file)
@@ -1,74 +1,74 @@
-/*\r
- * BadAllocationException.cxx\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
- /* BadAllocationException member functions implementation.\r
-  */  \r
-\r
-#include <BadAllocException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       BadAllocException::BadAllocException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Not enough memory") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Not enough memory");\r
-                       }\r
-               \r
-               \r
-                       BadAllocException::BadAllocException(const BadAllocException& rBadAllocException)\r
-                       {\r
-                               const char* reason = rBadAllocException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-                       BadAllocException::BadAllocException(const char* objectName)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Not enough memory to allocate ") + strlen(objectName) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Not enough memory to allocate %s", objectName);\r
-                       }\r
-               \r
-               \r
-                       BadAllocException::~BadAllocException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* BadAllocException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const BadAllocException& BadAllocException::operator = (const BadAllocException& rBadAllocException)\r
-                       {\r
-                               const char* reason = rBadAllocException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * BadAllocationException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* BadAllocationException member functions implementation.
+  */  
+
+#include <BadAllocException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       BadAllocException::BadAllocException()
+                       {
+                               this->reason = (char*) calloc(strlen("Not enough memory") + 1, sizeof(char));
+                               strcpy(this->reason, "Not enough memory");
+                       }
+               
+               
+                       BadAllocException::BadAllocException(const BadAllocException& rBadAllocException)
+                       {
+                               const char* reason = rBadAllocException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+                       BadAllocException::BadAllocException(const char* objectName)
+                       {
+                               this->reason = (char*) calloc(strlen("Not enough memory to allocate ") + strlen(objectName) + 1, sizeof(char));
+                               sprintf(this->reason, "Not enough memory to allocate %s", objectName);
+                       }
+               
+               
+                       BadAllocException::~BadAllocException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* BadAllocException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const BadAllocException& BadAllocException::operator = (const BadAllocException& rBadAllocException)
+                       {
+                               const char* reason = rBadAllocException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index b5726ee..69221ce 100644 (file)
@@ -1,69 +1,69 @@
-/*\r
- * BadAllocException.hpp\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_BADALLOCEXCEPTION_HPP\r
-#define MSG_BADALLOCEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error BadAllocException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT BadAllocException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               BadAllocException();\r
-                       \r
-                       // Copy constructor.\r
-                               BadAllocException(const BadAllocException& rBadAllocException);\r
-                       \r
-                       // This constructor takes the name of the object of the allocation failure.\r
-                               BadAllocException(const char* objectName);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~BadAllocException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Not enough memory to allocate : `object name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const BadAllocException& operator = (const BadAllocException& rBadAllocException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_BADALLOCEXCEPTION_HPP\r
-\r
+/*
+ * BadAllocException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_BADALLOCEXCEPTION_HPP
+#define MSG_BADALLOCEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error BadAllocException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT BadAllocException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               BadAllocException();
+                       
+                       // Copy constructor.
+                               BadAllocException(const BadAllocException& rBadAllocException);
+                       
+                       // This constructor takes the name of the object of the allocation failure.
+                               BadAllocException(const char* objectName);
+                       
+                       // Destructor.
+                               virtual ~BadAllocException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Not enough memory to allocate : `object name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const BadAllocException& operator = (const BadAllocException& rBadAllocException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_BADALLOCEXCEPTION_HPP
+
index 236ba2a..13887a2 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * ClassNotFoundException.cxx\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
- /* ClassNotFoundException member functions implementation.\r
-  */  \r
-\r
-#include <ClassNotFoundException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       ClassNotFoundException::ClassNotFoundException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Class not found : unknown");\r
-                       }\r
-               \r
-               \r
-                       ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)\r
-                       {\r
-                               const char* reason = rClassNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       ClassNotFoundException::ClassNotFoundException(const char* name)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Class not found : %s", name);\r
-                       }\r
-               \r
-               \r
-                       ClassNotFoundException::~ClassNotFoundException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* ClassNotFoundException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)\r
-                       {\r
-                               const char* reason = rClassNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * ClassNotFoundException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* ClassNotFoundException member functions implementation.
+  */  
+
+#include <ClassNotFoundException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       ClassNotFoundException::ClassNotFoundException()
+                       {
+                               this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));
+                               strcpy(this->reason, "Class not found : unknown");
+                       }
+               
+               
+                       ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)
+                       {
+                               const char* reason = rClassNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       ClassNotFoundException::ClassNotFoundException(const char* name)
+                       {
+                               this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));
+                               sprintf(this->reason, "Class not found : %s", name);
+                       }
+               
+               
+                       ClassNotFoundException::~ClassNotFoundException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* ClassNotFoundException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)
+                       {
+                               const char* reason = rClassNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index bc90970..36a77b9 100644 (file)
@@ -1,69 +1,69 @@
-/*\r
- * ClassNotFoundException.hpp\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_CLASSNOTFOUNDEXCEPTION_HPP\r
-#define MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error ClassNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT ClassNotFoundException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               ClassNotFoundException();\r
-                       \r
-                       // Copy constructor.\r
-                               ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException);\r
-                       \r
-                       // This constructor takes the name of the class not found.\r
-                               ClassNotFoundException(const char* name);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~ClassNotFoundException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Host not found `host name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const ClassNotFoundException& operator = (const ClassNotFoundException& rClassNotFoundException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
-\r
+/*
+ * ClassNotFoundException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_CLASSNOTFOUNDEXCEPTION_HPP
+#define MSG_CLASSNOTFOUNDEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error ClassNotFoundException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT ClassNotFoundException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               ClassNotFoundException();
+                       
+                       // Copy constructor.
+                               ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException);
+                       
+                       // This constructor takes the name of the class not found.
+                               ClassNotFoundException(const char* name);
+                       
+                       // Destructor.
+                               virtual ~ClassNotFoundException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Host not found `host name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const ClassNotFoundException& operator = (const ClassNotFoundException& rClassNotFoundException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_CLASSNOTFOUNDEXCEPTION_HPP
+
index 0fc1e6f..2f9ed2d 100644 (file)
@@ -1,44 +1,44 @@
-\r
-/*\r
- * Config.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_CONFIG_HPP\r
-#define MSG_CONFIG_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error Config.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               #if defined(WIN32) && !defined(__MINGW32__)\r
-                       #if defined(SIMGRIDX_EXPORTS)\r
-                               #define SIMGRIDX_EXPORT __declspec(dllexport)\r
-                       #else\r
-                               #define SIMGRIDX_EXPORT __declspec(dllimport)\r
-                       #endif\r
-               #else\r
-                       #define SIMGRIDX_EXPORT\r
-               #endif \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#ifndef WIN32\r
-#define _strdup strdup\r
-#endif\r
-\r
-#endif // MSG_CONFIG_HPP\r
-\r
+
+/*
+ * Config.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+
+#ifndef MSG_CONFIG_HPP
+#define MSG_CONFIG_HPP
+
+#ifndef __cplusplus
+       #error Config.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               #if defined(WIN32) && !defined(__MINGW32__)
+                       #if defined(SIMGRIDX_EXPORTS)
+                               #define SIMGRIDX_EXPORT __declspec(dllexport)
+                       #else
+                               #define SIMGRIDX_EXPORT __declspec(dllimport)
+                       #endif
+               #else
+                       #define SIMGRIDX_EXPORT
+               #endif 
+       } // namespace Msg
+} // namespace SimGrid
+
+#ifndef WIN32
+#define _strdup strdup
+#endif
+
+#endif // MSG_CONFIG_HPP
+
index 71e0acf..0d9b003 100644 (file)
-/*\r
- * Environment.cxx\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
- /* Environment member functions implementation.\r
-  */  \r
-  \r
-#include <Environment.hpp>\r
-\r
-#include <stdlib.h>\r
-\r
-#include <sys/types.h>\r
-#include <sys/stat.h>\r
-\r
-#include <msg/msg.h>\r
-\r
-#ifndef S_ISREG\r
-       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
-#endif\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               Environment::Environment()\r
-               {\r
-                       this->file = NULL;\r
-                       this->loaded = false;\r
-               }\r
-                               \r
-               Environment::Environment(const Environment& rEnvironment)\r
-               {\r
-                       this->file = rEnvironment.getFile();\r
-                       this->loaded = rEnvironment.isLoaded();\r
-               }\r
-               \r
-               Environment::Environment(const char* file)\r
-               throw(NullPointerException, FileNotFoundException)\r
-               {\r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file (must not be NULL");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException("file (file not found)");\r
-                               \r
-                       this->file = file;\r
-                       this->loaded = false;\r
-               }\r
-               \r
-               Environment::~Environment()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-               \r
-               // Operations.\r
-               \r
-               void Environment::load(void)\r
-               throw(LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->loaded)\r
-                               throw LogicException("environement already loaded");\r
-                       \r
-                       // check the parameters\r
-                       if(!this->file)\r
-                               throw LogicException("you must specify the xml file which describe the environment to load\nuse Environment::setFile()"); \r
-                       \r
-                       MSG_create_environment(file);\r
-                       \r
-                       this->loaded = true;            \r
-               }\r
-               \r
-               void Environment::load(const char* file)\r
-               throw(NullPointerException, FileNotFoundException, LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->loaded)\r
-                               throw LogicException("environment already loaded");\r
-                       \r
-                       // check the parameters\r
-                               \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException(file);\r
-                                       \r
-                       MSG_create_environment(file);\r
-                       \r
-                       this->file = file;\r
-                       this->loaded = true;    \r
-               }\r
-               \r
-               bool Environment::isLoaded(void) const\r
-               {\r
-                       return this->loaded;\r
-               }\r
-               \r
-               // Getters/setters\r
-               void Environment::setFile(const char* file)\r
-               throw(NullPointerException, FileNotFoundException, LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->loaded)\r
-                               throw LogicException("your are trying to change the file of an already loaded environment");\r
-                               \r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file (must not be NULL");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException("file (file not found)");\r
-                               \r
-                       this->file = file;\r
-               }\r
-               \r
-               const char* Environment::getFile(void) const\r
-               {\r
-                       return this->file;\r
-               }\r
-       \r
-               \r
-               const Environment& Environment::operator = (const Environment& rEnvironment)\r
-               throw(LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->loaded)\r
-                               throw LogicException("environment already loaded");\r
-                       \r
-                       this->file = rEnvironment.getFile();\r
-                       this->loaded = rEnvironment.isLoaded();\r
-                       \r
-                       return *this;\r
-               }\r
-                               \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
+/*
+ * Environment.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Environment member functions implementation.
+  */  
+  
+#include <Environment.hpp>
+
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <msg/msg.h>
+
+#ifndef S_ISREG
+       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
+#endif
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               Environment::Environment()
+               {
+                       this->file = NULL;
+                       this->loaded = false;
+               }
+                               
+               Environment::Environment(const Environment& rEnvironment)
+               {
+                       this->file = rEnvironment.getFile();
+                       this->loaded = rEnvironment.isLoaded();
+               }
+               
+               Environment::Environment(const char* file)
+               throw(NullPointerException, FileNotFoundException)
+               {
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file (must not be NULL");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException("file (file not found)");
+                               
+                       this->file = file;
+                       this->loaded = false;
+               }
+               
+               Environment::~Environment()
+               {
+                       // NOTHING TODO
+               }
+               
+               // Operations.
+               
+               void Environment::load(void)
+               throw(LogicException)
+               {
+                       // check logic
+                       
+                       if(this->loaded)
+                               throw LogicException("environement already loaded");
+                       
+                       // check the parameters
+                       if(!this->file)
+                               throw LogicException("you must specify the xml file which describe the environment to load\nuse Environment::setFile()"); 
+                       
+                       MSG_create_environment(file);
+                       
+                       this->loaded = true;            
+               }
+               
+               void Environment::load(const char* file)
+               throw(NullPointerException, FileNotFoundException, LogicException)
+               {
+                       // check logic
+                       
+                       if(this->loaded)
+                               throw LogicException("environment already loaded");
+                       
+                       // check the parameters
+                               
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException(file);
+                                       
+                       MSG_create_environment(file);
+                       
+                       this->file = file;
+                       this->loaded = true;    
+               }
+               
+               bool Environment::isLoaded(void) const
+               {
+                       return this->loaded;
+               }
+               
+               // Getters/setters
+               void Environment::setFile(const char* file)
+               throw(NullPointerException, FileNotFoundException, LogicException)
+               {
+                       // check logic
+                       
+                       if(this->loaded)
+                               throw LogicException("your are trying to change the file of an already loaded environment");
+                               
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file (must not be NULL");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException("file (file not found)");
+                               
+                       this->file = file;
+               }
+               
+               const char* Environment::getFile(void) const
+               {
+                       return this->file;
+               }
+       
+               
+               const Environment& Environment::operator = (const Environment& rEnvironment)
+               throw(LogicException)
+               {
+                       // check logic
+                       
+                       if(this->loaded)
+                               throw LogicException("environment already loaded");
+                       
+                       this->file = rEnvironment.getFile();
+                       this->loaded = rEnvironment.isLoaded();
+                       
+                       return *this;
+               }
+                               
+       } // namespace Msg
+} // namespace SimGrid
+
index 89f6e48..8f8e0a0 100644 (file)
-/*\r
- * Environment.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_ENVIRONMENT_HPP\r
-#define MSG_ENVIRONMENT_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error Environment.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class NullPointerException;\r
-               class FileNotFoundException;\r
-               class InvalidArgumentException;\r
-               class LogicException;\r
-               class MsgException;\r
-\r
-               // Environment class wrapper declaration\r
-               class SIMGRIDX_EXPORT Environment\r
-               {\r
-                       public:\r
-                               \r
-                               /*! \brief Default constructor.\r
-                                */\r
-                               Environment();\r
-                               \r
-                               /*! \brief Copy constructor.\r
-                                */\r
-                               Environment(const Environment& rEnvironment);\r
-                               \r
-                               /*! \brief Constructor.\r
-                                *\r
-                                * \param file                  The xml file describing the environment of the simulation.\r
-                                *\r
-                                * \exception                   If this constructor fails, it throws one of the exception\r
-                                *                                              described below:\r
-                                *\r
-                                *                                              [NullPointerException]          if the parameter file is NULL.\r
-                                *\r
-                                *                                              [FileNotFoundException]         if the file is not found.\r
-                                */\r
-                               Environment(const char* file)\r
-                               throw(NullPointerException, FileNotFoundException);\r
-                               \r
-                               /*! \brief Destructor.\r
-                                */\r
-                               virtual ~Environment();\r
-                               \r
-                       // Operations.\r
-                               \r
-                               /*! brief Environment::load() - Load the environment of a simulation.\r
-                                *\r
-                                * \exception                   If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                              [LogicException]                        if the file of the environment is not yet specified or\r
-                                *                                                                                                      if the environment is already loaded.\r
-                                */\r
-                               void load(void)\r
-                               throw(LogicException);\r
-                               \r
-                               /*! \brief Environment::load() - Load the environment of a simulation.\r
-                                *\r
-                                * \param file                  The xml file describing the environment of the simulation.\r
-                                *\r
-                                * \exception                   If this method fails, it throws one of the exceptions described below.\r
-                                *\r
-                                *                                              [NullPointerException]          if the parameter file is NULL.\r
-                                *\r
-                                *                                              [FileNotFoundException]         if the specified file is not found.\r
-                                *\r
-                                *                                              [LogicException]                        if the environment is already loaded.\r
-                                */\r
-                               void load(const char* file)\r
-                               throw(NullPointerException, FileNotFoundException, LogicException);\r
-                               \r
-                               /*! \brief Environment::isLoaded() - Tests if an environment is loaded.\r
-                                *\r
-                                * \return                              If the environment is loaded, the method returns true. Otherwise the method\r
-                                *                                              returns false.\r
-                                */\r
-                               bool isLoaded(void) const;\r
-                               \r
-                       // Getters/setters\r
-                               /*! \brief Environment::setFile() - Sets the xml file of the environment.\r
-                                *\r
-                                * \param file                  The file describing the environment.\r
-                                *\r
-                                * \exception                   If the method fails, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                              [NullPointerException]          if the parameter file is NULL.\r
-                                *                              \r
-                                *                                              [FileNotFoundException]         if the file is not found.\r
-                                *\r
-                                *                                              [LogicException]                        if the environment is already loaded.\r
-                                */\r
-                               void setFile(const char* file)\r
-                               throw(NullPointerException, FileNotFoundException, LogicException);\r
-                               \r
-                               /*! \brief Environment::getFile() - Gets the xml file environment description.\r
-                                *\r
-                                * \return                              The xml file describing the environment.                                \r
-                                *\r
-                                */\r
-                               const char* getFile(void) const;\r
-                               \r
-                       // Operators.\r
-                               \r
-                               /*! \brief Assignment operator.\r
-                                *\r
-                                * \exception                   If this operator fails, it throws the exception described below:\r
-                                *\r
-                                *                                              [LogicException]                        if you try to assign a loaded environment.\r
-                                */\r
-                               const Environment& operator = (const Environment& rEnvironment)\r
-                               throw(LogicException);\r
-                               \r
-                       private:\r
-                               \r
-                               // Attributes.\r
-                               \r
-                               // the xml file which describe the environment of the simulation.\r
-                               const char* file;\r
-                               \r
-                               // flag : is true the environment of the simulation is loaded.\r
-                               bool loaded;\r
-               };\r
-               \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-\r
-#endif // !MSG_ENVIRONMENT_HPP\r
-\r
+/*
+ * Environment.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_ENVIRONMENT_HPP
+#define MSG_ENVIRONMENT_HPP
+
+#ifndef __cplusplus
+       #error Environment.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <NullPointerException.hpp>
+#include <FileNotFoundException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <LogicException.hpp>
+#include <MsgException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class NullPointerException;
+               class FileNotFoundException;
+               class InvalidArgumentException;
+               class LogicException;
+               class MsgException;
+
+               // Environment class wrapper declaration
+               class SIMGRIDX_EXPORT Environment
+               {
+                       public:
+                               
+                               /*! \brief Default constructor.
+                                */
+                               Environment();
+                               
+                               /*! \brief Copy constructor.
+                                */
+                               Environment(const Environment& rEnvironment);
+                               
+                               /*! \brief Constructor.
+                                *
+                                * \param file                  The xml file describing the environment of the simulation.
+                                *
+                                * \exception                   If this constructor fails, it throws one of the exception
+                                *                                              described below:
+                                *
+                                *                                              [NullPointerException]          if the parameter file is NULL.
+                                *
+                                *                                              [FileNotFoundException]         if the file is not found.
+                                */
+                               Environment(const char* file)
+                               throw(NullPointerException, FileNotFoundException);
+                               
+                               /*! \brief Destructor.
+                                */
+                               virtual ~Environment();
+                               
+                       // Operations.
+                               
+                               /*! brief Environment::load() - Load the environment of a simulation.
+                                *
+                                * \exception                   If this method fails, it throws the exception described below:
+                                *
+                                *                                              [LogicException]                        if the file of the environment is not yet specified or
+                                *                                                                                                      if the environment is already loaded.
+                                */
+                               void load(void)
+                               throw(LogicException);
+                               
+                               /*! \brief Environment::load() - Load the environment of a simulation.
+                                *
+                                * \param file                  The xml file describing the environment of the simulation.
+                                *
+                                * \exception                   If this method fails, it throws one of the exceptions described below.
+                                *
+                                *                                              [NullPointerException]          if the parameter file is NULL.
+                                *
+                                *                                              [FileNotFoundException]         if the specified file is not found.
+                                *
+                                *                                              [LogicException]                        if the environment is already loaded.
+                                */
+                               void load(const char* file)
+                               throw(NullPointerException, FileNotFoundException, LogicException);
+                               
+                               /*! \brief Environment::isLoaded() - Tests if an environment is loaded.
+                                *
+                                * \return                              If the environment is loaded, the method returns true. Otherwise the method
+                                *                                              returns false.
+                                */
+                               bool isLoaded(void) const;
+                               
+                       // Getters/setters
+                               /*! \brief Environment::setFile() - Sets the xml file of the environment.
+                                *
+                                * \param file                  The file describing the environment.
+                                *
+                                * \exception                   If the method fails, it throws one of the exceptions described below:
+                                *
+                                *                                              [NullPointerException]          if the parameter file is NULL.
+                                *                              
+                                *                                              [FileNotFoundException]         if the file is not found.
+                                *
+                                *                                              [LogicException]                        if the environment is already loaded.
+                                */
+                               void setFile(const char* file)
+                               throw(NullPointerException, FileNotFoundException, LogicException);
+                               
+                               /*! \brief Environment::getFile() - Gets the xml file environment description.
+                                *
+                                * \return                              The xml file describing the environment.                                
+                                *
+                                */
+                               const char* getFile(void) const;
+                               
+                       // Operators.
+                               
+                               /*! \brief Assignment operator.
+                                *
+                                * \exception                   If this operator fails, it throws the exception described below:
+                                *
+                                *                                              [LogicException]                        if you try to assign a loaded environment.
+                                */
+                               const Environment& operator = (const Environment& rEnvironment)
+                               throw(LogicException);
+                               
+                       private:
+                               
+                               // Attributes.
+                               
+                               // the xml file which describe the environment of the simulation.
+                               const char* file;
+                               
+                               // flag : is true the environment of the simulation is loaded.
+                               bool loaded;
+               };
+               
+       } // namespace Msg
+} // namespace SimGrid
+
+
+#endif // !MSG_ENVIRONMENT_HPP
+
index 94ae26e..c314f13 100644 (file)
@@ -1,64 +1,64 @@
-/*\r
- * Exception.cxx\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
- /* Exception member functions implementation.\r
-  * The base class of all the types of exceptions of SimGrid::Msg.\r
-  */  \r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       Exception::Exception()\r
-                       {\r
-                               reason = "Unknown reason";\r
-                       }\r
-               \r
-               \r
-                       Exception::Exception(const Exception& rException)\r
-                       {\r
-                               this->reason = rException.toString();\r
-                       }\r
-               \r
-               \r
-                       Exception::Exception(const char* reason)\r
-                       {\r
-                               this->reason = reason;\r
-                       }\r
-               \r
-               \r
-                       Exception::~Exception()\r
-                       {\r
-                               // NOTHING TODO\r
-                       }\r
-                               \r
-                       const char* Exception::toString(void) const\r
-                       {\r
-                               return this->reason;    \r
-                       }\r
-               \r
-               \r
-                       const Exception& Exception::operator = (const Exception& rException)\r
-                       {\r
-                               this->reason = rException.toString();\r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * Exception.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Exception member functions implementation.
+  * The base class of all the types of exceptions of SimGrid::Msg.
+  */  
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       Exception::Exception()
+                       {
+                               reason = "Unknown reason";
+                       }
+               
+               
+                       Exception::Exception(const Exception& rException)
+                       {
+                               this->reason = rException.toString();
+                       }
+               
+               
+                       Exception::Exception(const char* reason)
+                       {
+                               this->reason = reason;
+                       }
+               
+               
+                       Exception::~Exception()
+                       {
+                               // NOTHING TODO
+                       }
+                               
+                       const char* Exception::toString(void) const
+                       {
+                               return this->reason;    
+                       }
+               
+               
+                       const Exception& Exception::operator = (const Exception& rException)
+                       {
+                               this->reason = rException.toString();
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index 1b1a8ee..2fc3067 100644 (file)
@@ -1,68 +1,68 @@
-/*\r
- * Exception.hpp\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_EXCEPTION_HPP\r
-#define MSG_EXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error Exception.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Config.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               Exception();\r
-                       \r
-                       // Copy constructor.\r
-                               Exception(const Exception& rException);\r
-                       \r
-                       // This constructor takes the reason of the exception.\r
-                               Exception(const char* reason);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~Exception();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception.\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const Exception& operator = (const Exception& rException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // The reason of the exceptions.\r
-                               const char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_EXCEPTION_HPP\r
-\r
+/*
+ * Exception.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_EXCEPTION_HPP
+#define MSG_EXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error Exception.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Config.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               Exception();
+                       
+                       // Copy constructor.
+                               Exception(const Exception& rException);
+                       
+                       // This constructor takes the reason of the exception.
+                               Exception(const char* reason);
+                       
+                       // Destructor.
+                               virtual ~Exception();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception.
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const Exception& operator = (const Exception& rException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // The reason of the exceptions.
+                               const char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_EXCEPTION_HPP
+
index 297d60c..3ceec07 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * FileNotFoundException.cxx\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
- /* FileNotFoundException member functions implementation.\r
-  */  \r
-\r
-#include <FileNotFoundException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       FileNotFoundException::FileNotFoundException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("File not found") + 1, sizeof(char));\r
-                               strcpy(this->reason, "File not found");\r
-                       }\r
-               \r
-               \r
-                       FileNotFoundException::FileNotFoundException(const FileNotFoundException& rFileNotFoundException)\r
-                       {\r
-                               const char* reason = rFileNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-                       FileNotFoundException::FileNotFoundException(const char* file)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("File not found ") + strlen(file) + 1, sizeof(char));\r
-                               sprintf(this->reason, "File not found %s", file);\r
-                       }\r
-               \r
-               \r
-                       FileNotFoundException::~FileNotFoundException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* FileNotFoundException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const FileNotFoundException& FileNotFoundException::operator = (const FileNotFoundException& rFileNotFoundException)\r
-                       {\r
-                               const char* reason = rFileNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * FileNotFoundException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* FileNotFoundException member functions implementation.
+  */  
+
+#include <FileNotFoundException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       FileNotFoundException::FileNotFoundException()
+                       {
+                               this->reason = (char*) calloc(strlen("File not found") + 1, sizeof(char));
+                               strcpy(this->reason, "File not found");
+                       }
+               
+               
+                       FileNotFoundException::FileNotFoundException(const FileNotFoundException& rFileNotFoundException)
+                       {
+                               const char* reason = rFileNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+                       FileNotFoundException::FileNotFoundException(const char* file)
+                       {
+                               this->reason = (char*) calloc(strlen("File not found ") + strlen(file) + 1, sizeof(char));
+                               sprintf(this->reason, "File not found %s", file);
+                       }
+               
+               
+                       FileNotFoundException::~FileNotFoundException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* FileNotFoundException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const FileNotFoundException& FileNotFoundException::operator = (const FileNotFoundException& rFileNotFoundException)
+                       {
+                               const char* reason = rFileNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index a7ddfbc..53a6247 100644 (file)
@@ -1,69 +1,69 @@
-/*\r
- * FileNotFoundException.hpp\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_FILENOTFOUND_HPP\r
-#define MSG_FILENOTFOUND_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error FileNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT FileNotFoundException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               FileNotFoundException();\r
-                       \r
-                       // Copy constructor.\r
-                               FileNotFoundException(const FileNotFoundException& rFileNotFoundException);\r
-                       \r
-                       // This constructor takes the name of the file.\r
-                               FileNotFoundException(const char* file);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~FileNotFoundException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "File not found : `object name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const FileNotFoundException& operator = (const FileNotFoundException& rFileNotFoundException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_MSGEXCEPTION_HPP\r
-\r
+/*
+ * FileNotFoundException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_FILENOTFOUND_HPP
+#define MSG_FILENOTFOUND_HPP
+
+#ifndef __cplusplus
+       #error FileNotFoundException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT FileNotFoundException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               FileNotFoundException();
+                       
+                       // Copy constructor.
+                               FileNotFoundException(const FileNotFoundException& rFileNotFoundException);
+                       
+                       // This constructor takes the name of the file.
+                               FileNotFoundException(const char* file);
+                       
+                       // Destructor.
+                               virtual ~FileNotFoundException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "File not found : `object name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const FileNotFoundException& operator = (const FileNotFoundException& rFileNotFoundException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_MSGEXCEPTION_HPP
+
index 18997ea..39f40eb 100644 (file)
-/*\r
- * Host.cxx\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
- /* Host class member functions implementation.\r
-  */ \r
-\r
-#include <Task.hpp>\r
-#include <Process.hpp>\r
-\r
-#include <Host.hpp>\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-#include <msg/msg.h>\r
-#include <msg/private.h>\r
-\r
-#include <xbt/fifo.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               Host::Host()\r
-               {\r
-                       nativeHost = NULL;\r
-                       data = NULL;\r
-               }\r
-               \r
-               Host::Host(const Host& rHost)\r
-               {\r
-                       this->nativeHost = rHost.nativeHost;\r
-                       this->data = rHost.getData();   \r
-               }\r
-               \r
-               Host::~Host()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-               \r
-               \r
-               Host& Host::getByName(const char* hostName)\r
-               throw(HostNotFoundException, NullPointerException, BadAllocException)\r
-               {\r
-                       // check the parameters\r
-                       if(!hostName)\r
-                               throw NullPointerException("hostName");\r
-                               \r
-                       m_host_t nativeHost = NULL;     // native host.\r
-                       Host* host = NULL;                      // wrapper host.\r
-                       \r
-                       if(!(nativeHost = MSG_get_host_by_name(hostName))) \r
-                               throw HostNotFoundException(hostName);\r
-                       \r
-                       if(!nativeHost->data) \r
-                       { // native host not associated yet with  its wrapper\r
-                       \r
-                               // instanciate a new wrapper \r
-                               if(!(host = new Host()))\r
-                                       throw BadAllocException(hostName);\r
-                               \r
-                               host->nativeHost = nativeHost; \r
-                       \r
-                               // the native host data field is set with its wrapper returned \r
-                               nativeHost->data = (void*)host;\r
-                       }\r
-                       \r
-                       // return the reference to cxx wrapper\r
-                       return *((Host*)nativeHost->data);                              \r
-               }\r
-               \r
-               int Host::getNumber(void)\r
-               {\r
-                       return MSG_get_host_number();\r
-               }\r
-               \r
-               Host& Host::currentHost(void)\r
-               {\r
-                       Host* host = NULL;\r
-                       m_host_t nativeHost = MSG_host_self();\r
-                       \r
-                       if(!nativeHost->data) \r
-                       {\r
-                               // the native host not yet associated with its wrapper\r
-                       \r
-                               // instanciate a new wrapper\r
-                               host = new Host();\r
-                       \r
-                               host->nativeHost = nativeHost;\r
-                       \r
-                               nativeHost->data = (void*)host;\r
-                       } \r
-                       else \r
-                       {\r
-                               host = (Host*)nativeHost->data;\r
-                       }\r
-                       \r
-                       return *host;\r
-               }\r
-               \r
-               void Host::all(Host*** hosts, int* len) \r
-               throw(InvalidArgumentException, BadAllocException) \r
-               {\r
-                       // check the parameters\r
-                       if(!hosts)\r
-                               throw InvalidArgumentException("hosts");\r
-                               \r
-                       if(len < 0)\r
-                               throw InvalidArgumentException("len parameter must be positive");\r
-                       \r
-                       int count = xbt_fifo_size(msg_global->host);\r
-                       \r
-                       if(*len < count)\r
-                               throw InvalidArgumentException("len parameter must be more than the number of installed host\n (use Host::getNumber() to get the number of hosts)");\r
-                       \r
-                       int index;\r
-                       m_host_t nativeHost;\r
-                       Host* host;\r
-               \r
-                       m_host_t* table = (m_host_t *)xbt_fifo_to_array(msg_global->host);\r
-                       \r
-                       for(index = 0; index < count; index++) \r
-                       {\r
-                               nativeHost = table[index];\r
-                               host = (Host*)(nativeHost->data);\r
-                       \r
-                               if(!host) \r
-                               {\r
-                                       if(!(host = new Host()))\r
-                                       {\r
-                                               // release all allocated memory.\r
-                                               for(int i = 0; i < index; i++)\r
-                                                       delete (*(hosts)[i]);\r
-                                               \r
-                                               throw BadAllocException("to fill the table of the hosts installed on your platform");\r
-                                       }\r
-                                       \r
-                                       host->nativeHost = nativeHost;\r
-                                       nativeHost->data = (void*)host;\r
-                               }\r
-                               \r
-                               (*hosts)[index] = host;\r
-                 }\r
-               \r
-                 *len = count;  \r
-               }\r
-               \r
-               const char* Host::getName(void) const\r
-               {\r
-                       return nativeHost->name;\r
-               }\r
-               \r
-               void Host::setData(void* data)\r
-               {\r
-                       this->data = data;\r
-               }\r
-               \r
-               void* Host::getData(void) const\r
-               {\r
-                       return this->data;\r
-               }\r
-               \r
-               int Host::getRunningTaskNumber(void) const\r
-               {\r
-                       return MSG_get_host_msgload(nativeHost); \r
-               }\r
-               \r
-               double Host::getSpeed(void) const\r
-               {\r
-                       return MSG_get_host_speed(nativeHost);\r
-               }\r
-               \r
-               bool Host::hasData(void) const\r
-               {\r
-                       return (NULL != this->data);\r
-               }\r
-               \r
-               int Host::isAvailable(void) const\r
-               {\r
-                       return SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
-               }\r
-               \r
-               void Host::put(int channel, Task* task) \r
-               throw(MsgException, InvalidArgumentException)\r
-               {\r
-                       // checks the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must be more or equal to zero)");\r
-                               \r
-                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , -1.0))\r
-                               throw MsgException("MSG_task_put_with_timeout() failed");\r
-               } \r
-\r
-               void Host::put(int channel, Task* task, double timeout) \r
-               throw(MsgException, InvalidArgumentException) \r
-               {\r
-                       // checks the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must be more or equal to zero)");\r
-                               \r
-                       if(timeout < 0.0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must be more or equal to zero or equal to -1.0)");     \r
-                               \r
-                               \r
-                   if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , timeout))\r
-                               throw MsgException("MSG_task_put_with_timeout() failed");\r
-               }\r
-               \r
-               void Host::putBounded(int channel, Task* task, double maxRate) \r
-               throw(MsgException, InvalidArgumentException)\r
-               {\r
-                   // checks the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must be more or equal to zero)");\r
-                               \r
-                       if(maxRate < 0.0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must be more or equal to zero or equal to -1.0)");     \r
-                   \r
-                       if(MSG_OK != MSG_task_put_bounded(task->nativeTask, nativeHost, channel, maxRate))\r
-                               throw MsgException("MSG_task_put_bounded() failed");\r
-               }\r
-               \r
-               void Host::send(Task* task) \r
-               throw(MsgException, BadAllocException)  \r
-               {       \r
-                       MSG_error_t rv;\r
-                       \r
-                       char* alias = (char*)calloc(strlen(this->getName())+ strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
-                               \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
-                               \r
-                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, -1.0);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               } \r
-               \r
-               void Host::send(const char* alias, Task* task) \r
-               throw(InvalidArgumentException, MsgException) \r
-               {\r
-                       // check the parameters\r
-                       if(!alias)\r
-                               throw InvalidArgumentException("alias (must not be NULL)");\r
-                       \r
-                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, -1.0))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Host::send(Task* task, double timeout) \r
-               throw(InvalidArgumentException, BadAllocException, MsgException) \r
-               {\r
-                       // check the parameters\r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must be positive or equal to zero or equal to -1.0)");\r
-                       \r
-                       MSG_error_t rv;\r
-                       \r
-                       char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
-                               \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
-                               \r
-                               \r
-                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, timeout);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Host::send(const char* alias, Task* task, double timeout) \r
-               throw(InvalidArgumentException, MsgException) \r
-               {\r
-                       // check the parameter\r
-                       \r
-                       if(!alias)\r
-                               throw InvalidArgumentException("alias (must not be NULL)");\r
-                               \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must be positive or equal to zero or equal to -1.0)");\r
-                                       \r
-                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, timeout))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               \r
-               void Host::sendBounded(Task* task, double maxRate) \r
-               throw(InvalidArgumentException, BadAllocException, MsgException) \r
-               {\r
-                       if(maxRate < 0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must be positive or equal to zero or equal to -1.0)");\r
-                       \r
-                       MSG_error_t rv;\r
-                       \r
-                       char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
-                               \r
-                       rv = MSG_task_send_bounded(task->nativeTask, alias, maxRate);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-               }  \r
-               \r
-               void Host::sendBounded(const char* alias, Task* task, double maxRate) \r
-               throw(InvalidArgumentException, MsgException) \r
-               {\r
-                       // check the parameters\r
-                       if(!alias)\r
-                               throw InvalidArgumentException("alias (must not be NULL)");\r
-                       \r
-                       if(maxRate < 0 && maxRate != -1)\r
-                               throw InvalidArgumentException("maxRate (must be positive or equal to zero or equal to -1.0)");\r
-                       \r
-                       if(MSG_OK != MSG_task_send_bounded(task->nativeTask, alias, maxRate))\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-                       \r
-               }\r
-       } // namspace Msg\r
-} // namespace SimGrid\r
-\r
+/*
+ * Host.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Host class member functions implementation.
+  */ 
+
+#include <Task.hpp>
+#include <Process.hpp>
+
+#include <Host.hpp>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <msg/msg.h>
+#include <msg/private.h>
+
+#include <xbt/fifo.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               Host::Host()
+               {
+                       nativeHost = NULL;
+                       data = NULL;
+               }
+               
+               Host::Host(const Host& rHost)
+               {
+                       this->nativeHost = rHost.nativeHost;
+                       this->data = rHost.getData();   
+               }
+               
+               Host::~Host()
+               {
+                       // NOTHING TODO
+               }
+               
+               
+               Host& Host::getByName(const char* hostName)
+               throw(HostNotFoundException, NullPointerException, BadAllocException)
+               {
+                       // check the parameters
+                       if(!hostName)
+                               throw NullPointerException("hostName");
+                               
+                       m_host_t nativeHost = NULL;     // native host.
+                       Host* host = NULL;                      // wrapper host.
+                       
+                       if(!(nativeHost = MSG_get_host_by_name(hostName))) 
+                               throw HostNotFoundException(hostName);
+                       
+                       if(!nativeHost->data) 
+                       { // native host not associated yet with  its wrapper
+                       
+                               // instanciate a new wrapper 
+                               if(!(host = new Host()))
+                                       throw BadAllocException(hostName);
+                               
+                               host->nativeHost = nativeHost; 
+                       
+                               // the native host data field is set with its wrapper returned 
+                               nativeHost->data = (void*)host;
+                       }
+                       
+                       // return the reference to cxx wrapper
+                       return *((Host*)nativeHost->data);                              
+               }
+               
+               int Host::getNumber(void)
+               {
+                       return MSG_get_host_number();
+               }
+               
+               Host& Host::currentHost(void)
+               {
+                       Host* host = NULL;
+                       m_host_t nativeHost = MSG_host_self();
+                       
+                       if(!nativeHost->data) 
+                       {
+                               // the native host not yet associated with its wrapper
+                       
+                               // instanciate a new wrapper
+                               host = new Host();
+                       
+                               host->nativeHost = nativeHost;
+                       
+                               nativeHost->data = (void*)host;
+                       } 
+                       else 
+                       {
+                               host = (Host*)nativeHost->data;
+                       }
+                       
+                       return *host;
+               }
+               
+               void Host::all(Host*** hosts, int* len) 
+               throw(InvalidArgumentException, BadAllocException) 
+               {
+                       // check the parameters
+                       if(!hosts)
+                               throw InvalidArgumentException("hosts");
+                               
+                       if(len < 0)
+                               throw InvalidArgumentException("len parameter must be positive");
+                       
+                       int count = xbt_fifo_size(msg_global->host);
+                       
+                       if(*len < count)
+                               throw InvalidArgumentException("len parameter must be more than the number of installed host\n (use Host::getNumber() to get the number of hosts)");
+                       
+                       int index;
+                       m_host_t nativeHost;
+                       Host* host;
+               
+                       m_host_t* table = (m_host_t *)xbt_fifo_to_array(msg_global->host);
+                       
+                       for(index = 0; index < count; index++) 
+                       {
+                               nativeHost = table[index];
+                               host = (Host*)(nativeHost->data);
+                       
+                               if(!host) 
+                               {
+                                       if(!(host = new Host()))
+                                       {
+                                               // release all allocated memory.
+                                               for(int i = 0; i < index; i++)
+                                                       delete (*(hosts)[i]);
+                                               
+                                               throw BadAllocException("to fill the table of the hosts installed on your platform");
+                                       }
+                                       
+                                       host->nativeHost = nativeHost;
+                                       nativeHost->data = (void*)host;
+                               }
+                               
+                               (*hosts)[index] = host;
+                 }
+               
+                 *len = count;  
+               }
+               
+               const char* Host::getName(void) const
+               {
+                       return nativeHost->name;
+               }
+               
+               void Host::setData(void* data)
+               {
+                       this->data = data;
+               }
+               
+               void* Host::getData(void) const
+               {
+                       return this->data;
+               }
+               
+               int Host::getRunningTaskNumber(void) const
+               {
+                       return MSG_get_host_msgload(nativeHost); 
+               }
+               
+               double Host::getSpeed(void) const
+               {
+                       return MSG_get_host_speed(nativeHost);
+               }
+               
+               bool Host::hasData(void) const
+               {
+                       return (NULL != this->data);
+               }
+               
+               int Host::isAvailable(void) const
+               {
+                       return SIMIX_host_get_state(nativeHost->simdata->smx_host);
+               }
+               
+               void Host::put(int channel, Task* task) 
+               throw(MsgException, InvalidArgumentException)
+               {
+                       // checks the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must be more or equal to zero)");
+                               
+                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , -1.0))
+                               throw MsgException("MSG_task_put_with_timeout() failed");
+               } 
+
+               void Host::put(int channel, Task* task, double timeout) 
+               throw(MsgException, InvalidArgumentException) 
+               {
+                       // checks the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must be more or equal to zero)");
+                               
+                       if(timeout < 0.0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must be more or equal to zero or equal to -1.0)");     
+                               
+                               
+                   if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, nativeHost, channel , timeout))
+                               throw MsgException("MSG_task_put_with_timeout() failed");
+               }
+               
+               void Host::putBounded(int channel, Task* task, double maxRate) 
+               throw(MsgException, InvalidArgumentException)
+               {
+                   // checks the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must be more or equal to zero)");
+                               
+                       if(maxRate < 0.0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must be more or equal to zero or equal to -1.0)");     
+                   
+                       if(MSG_OK != MSG_task_put_bounded(task->nativeTask, nativeHost, channel, maxRate))
+                               throw MsgException("MSG_task_put_bounded() failed");
+               }
+               
+               void Host::send(Task* task) 
+               throw(MsgException, BadAllocException)  
+               {       
+                       MSG_error_t rv;
+                       
+                       char* alias = (char*)calloc(strlen(this->getName())+ strlen(Process::currentProcess().getName()) + 2, sizeof(char));
+                               
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());
+                               
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, -1.0);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               } 
+               
+               void Host::send(const char* alias, Task* task) 
+               throw(InvalidArgumentException, MsgException) 
+               {
+                       // check the parameters
+                       if(!alias)
+                               throw InvalidArgumentException("alias (must not be NULL)");
+                       
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, -1.0))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Host::send(Task* task, double timeout) 
+               throw(InvalidArgumentException, BadAllocException, MsgException) 
+               {
+                       // check the parameters
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must be positive or equal to zero or equal to -1.0)");
+                       
+                       MSG_error_t rv;
+                       
+                       char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));
+                               
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());
+                               
+                               
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, timeout);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Host::send(const char* alias, Task* task, double timeout) 
+               throw(InvalidArgumentException, MsgException) 
+               {
+                       // check the parameter
+                       
+                       if(!alias)
+                               throw InvalidArgumentException("alias (must not be NULL)");
+                               
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must be positive or equal to zero or equal to -1.0)");
+                                       
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias, timeout))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               
+               void Host::sendBounded(Task* task, double maxRate) 
+               throw(InvalidArgumentException, BadAllocException, MsgException) 
+               {
+                       if(maxRate < 0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must be positive or equal to zero or equal to -1.0)");
+                       
+                       MSG_error_t rv;
+                       
+                       char* alias = (char*)calloc(strlen(this->getName()) + strlen(Process::currentProcess().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());
+                               
+                       rv = MSG_task_send_bounded(task->nativeTask, alias, maxRate);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_bounded() failed");
+               }  
+               
+               void Host::sendBounded(const char* alias, Task* task, double maxRate) 
+               throw(InvalidArgumentException, MsgException) 
+               {
+                       // check the parameters
+                       if(!alias)
+                               throw InvalidArgumentException("alias (must not be NULL)");
+                       
+                       if(maxRate < 0 && maxRate != -1)
+                               throw InvalidArgumentException("maxRate (must be positive or equal to zero or equal to -1.0)");
+                       
+                       if(MSG_OK != MSG_task_send_bounded(task->nativeTask, alias, maxRate))
+                               throw MsgException("MSG_task_send_bounded() failed");
+                       
+               }
+       } // namspace Msg
+} // namespace SimGrid
+
index 0228097..c012513 100644 (file)
-/*\r
- * Host.hpp\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
-#ifndef MSG_HOST_HPP\r
-#define MSG_HOST_HPP\r
-\r
-\r
-/*! \brief Host class declaration.\r
- *\r
- * An host instance represents a location (any possible place) where a process may run. \r
- * Thus it is represented as a physical resource with computing capabilities, some \r
- * mailboxes to enable running process to communicate with remote ones, and some private \r
- * data that can be only accessed by local process. An instance of this class is always \r
- * binded with the corresponding native host. All the native hosts are automaticaly created \r
- * during the call of the static method Msg::createEnvironment(). This method takes as parameter\r
- * the platform file which describes all elements of the platform (host, link, root..).\r
- * You never need to create an host your self.\r
- *\r
- * The best way to get an host is to call the static method \r
- * Host.getByName() which returns a reference.\r
- *\r
- * For example to get the instance of the host. If your platform\r
- * file description contains an host named "Jacquelin" :\r
- *\r
- * \verbatim\r
-using namespace SimGrid.Msg;\r
-\r
-Host jacquelin;\r
-\r
-try \r
-{ \r
-       jacquelin = Host::getByName("Jacquelin");\r
-}\r
-catch(HostNotFoundException e) \r
-{\r
-       cerr << e.toString();\r
-}\r
-...\r
-\endverbatim\r
- *\r
- */\r
-\r
-#ifndef __cplusplus\r
-       #error Host.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <msg/datatypes.h>\r
-\r
-#include <InvalidArgumentException.hpp>\r
-#include <BadAllocException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <MsgException.hpp>\r
-#include <NullPointerException.hpp>\r
-\r
-\r
-\r
-// namespace SimGrid::Msg\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class Task;\r
-               class Process;\r
-\r
-               // Declaration of the class SimGrid::Msg::Host.\r
-               class SIMGRIDX_EXPORT Host // final class.\r
-               {\r
-                       friend class Process;\r
-                       friend class Task;\r
-\r
-                       // Desable the default constructor.\r
-                       // The best way to get an host instance is to use the static method Host::getByName().\r
-                       \r
-                       public :\r
-                               \r
-                       // Default constructor (desabled).\r
-                               Host();\r
-                       \r
-                       public: \r
-                               \r
-                       // Copy constructor (desabled).\r
-                               Host(const Host& rHost);\r
-                               \r
-                       // Destructor (desable).\r
-                               virtual ~Host();\r
-                       \r
-                       // Operations\r
-                       \r
-                               /*! \brief Host::getByName() - returns an host by its name\r
-                                *\r
-                                * This static method returns a reference to the host instance associated \r
-                                * with a native host of your platform. This is the best way to get a host.\r
-                                *\r
-                                * \param hostName      The name of the host.\r
-                                *\r
-                                * \return                      If successful the method returns a reference to the instance\r
-                                *                                      associated with the native host having the name specified\r
-                                *                                      as parameter of your platform. Otherwise the method throws\r
-                                *                                      one of the exceptions detailed below.\r
-                                *\r
-                                * \exception           [HostNotFoundException]         if no host with the specified name\r
-                                *                                                                                              was found.\r
-                                *                                      [InvalidArgumentException]      if the hostName parameter is invalid (NULL).\r
-                                *                                      [BadAllocException]                     if there is not enough memory to allocate the host.\r
-                                */ \r
-                               static Host& getByName(const char* hostName)\r
-                               throw(HostNotFoundException, NullPointerException, BadAllocException);\r
-                               \r
-                               /*! \brief Host::getNumber() - returns the number of the installed hosts.\r
-                                *\r
-                                * \return                      The number of hosts installed.\r
-                                */\r
-                               static int getNumber(void);\r
-                               \r
-                               \r
-                               /*! \brief Host::currentHost() - This static method returns the location on which the current \r
-                                * process is executed.\r
-                                *\r
-                                * \return                      The host of the current process.\r
-                                *\r
-                                * \see                         Process::currentProcess().\r
-                                */\r
-                               static Host& currentHost(void);\r
-                               \r
-                               /*! \brief Host::all() - This static method retrieves all of the hosts of the installed platform.\r
-                                *\r
-                                * \param hosts         A pointer to array of Host pointers that receives all the hosts of the platform.\r
-                                *\r
-                                * \param len           A pointer to the length of the table of pointers.\r
-                                *\r
-                                * \return                      If successful the hosts table is filled and\r
-                                *                                      the parameter len is set with the number of hosts of the platform.\r
-                                *                                      Otherwise the method throw one of the exception described below.\r
-                                *\r
-                                * \exception           [InvalidArgumentException]      if the parameter hosts is invalid or\r
-                                *                                                                                              if the parameter len is negative or\r
-                                *                                                                                              less than the number of hosts installed\r
-                                *                                                                                              on the current platform.\r
-                                *                                      [BadAllocException]                     If the method can't allocate memory to fill\r
-                                *                                                                                              the table of hosts.\r
-                                *\r
-                                *\r
-                                * \remark                      To get the number of hosts installed on your platform use the static method\r
-                                *                                      Host::getNumber().\r
-                                *\r
-                                * \see                         Host::getNumber().\r
-                                *\r
-                                *\verbatim\r
-                                * // This example show how to use this method to get the list of hosts installed on your platform.\r
-                                *\r
-                                *      using namespace SimGrid::Msg;\r
-                                *      using <iostream>\r
-                                *\r
-                                *      // (1) get the number of hosts.\r
-                                *      int number = Host::getNumber();\r
-                                *      \r
-                                *      // (2) allocate the array that receives the list of hosts.\r
-                                *      HostPtr* ar = new HostPtr[number];      // HostPtr is defined as (typedef Host* HostPtr at the end of the\r
-                                *                                                                              // declaration of this class.\r
-                                *\r
-                                *      // (3) call the method\r
-                                *      try\r
-                                *      {\r
-                                *              Host::all(&ar, &number);\r
-                                *      }\r
-                                *      catch(BadAllocException e)\r
-                                *      {\r
-                                *              cerr << e.toString() << endl;\r
-                                *              ...\r
-                                *      }\r
-                                *      catch(InvalidArgumentException e)\r
-                                *      {\r
-                                *              cerr << e.toString() << endl;\r
-                                *              ..\r
-                                *      } \r
-                                *\r
-                                *      // (4) use the table of host (for example print all the name of all the hosts);\r
-                                *      \r
-                                *      for(int i = 0; i < number ; i++)\r
-                                *              cout << ar[i]->getName() << endl;\r
-                                *\r
-                                *      ...\r
-                                *              \r
-                                *      // (5) release the allocate table\r
-                                *      \r
-                                *      delete[] ar;\r
-                                *\r
-                                */ \r
-                               static void all(Host*** hosts /*in|out*/, int* len /*in|out*/)\r
-                               throw(InvalidArgumentException, BadAllocException) ;\r
-                               \r
-                               /*! \brief Host::getName() - This method return the name of the Msg host object.\r
-                                *\r
-                                * \return                      The name of the host object.\r
-                                */\r
-                               const char* getName(void) const;\r
-                               \r
-                               /*! \brief Host::setData() - Set the user data of an host object.\r
-                                *\r
-                                * \param data          The user data to set.\r
-                                */\r
-                               void setData(void* data);\r
-                               \r
-                               /*! \brief Host::getData() - Get the user data of a host object.\r
-                                *\r
-                                * \return                      The user data of the host object.\r
-                                */\r
-                               void* getData(void) const;\r
-                               \r
-                               /*! \brief Host::hasData() - Test if an host object has some data.\r
-                                *\r
-                                * \return                      This method returns true if the host object has some user data.\r
-                                *                                      Otherwise the method returns false.\r
-                                */\r
-                               bool hasData(void) const;\r
-                               \r
-                               /*! \brief Host::getRunningTaskNumber() - returns the number of tasks currently running on a host.\r
-                                *\r
-                                * \return                      The number of task currently running of the host object.\r
-                                *\r
-                                * \remark                      The external load is not taken in account.\r
-                                */\r
-                               int getRunningTaskNumber(void) const;\r
-                               \r
-                               /*! \brief Host::getSpeed() - returns the speed of the processor of a host,\r
-                                * regardless of the current load of the machine.\r
-                                *\r
-                                * \return                      The speed of the processor of the host in flops.\r
-                                */ \r
-                               double getSpeed(void) const;\r
-                               \r
-                               /*! \brief Host::isAvailable - tests if an host is availabled.\r
-                                * \r
-                                * \return                      Is the host is availabled the method returns\r
-                                *                                      1. Otherwise the method returns 0.\r
-                                */ \r
-                               int isAvailable(void) const;\r
-                               \r
-                               /* ! \brief Host::put() - put a task on the given channel of a host .\r
-                                *\r
-                                * \param channel       The channel where to put the task.\r
-                                * \param rTask         A refercence to the task object containing the native task to\r
-                                *                                      put on the channel specified by the parameter channel.\r
-                                *\r
-                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
-                                *                                      the method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [MsgException]                          if an internal error occurs.\r
-                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
-                                *                                                                                              parameter is negative.\r
-                                */\r
-                               void put(int channel, Task* task) \r
-                               throw(MsgException, InvalidArgumentException);\r
-                               \r
-                               /* ! \brief Host::put() - put a task on the given channel of a host object (waiting at most timeout seconds).\r
-                                *\r
-                                * \param channel       The channel where to put the task.\r
-                                * \param rTask         A refercence to the task object containing the native task to\r
-                                *                                      put on the channel specified by the parameter channel.\r
-                                * \param timeout       The timeout in seconds.\r
-                                *\r
-                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
-                                *                                      the method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [MsgException]                          if an internal error occurs.\r
-                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
-                                *                                                                                              parameter is negative or if the timeout value\r
-                                *                                                                                              is less than zero and différent of -1.\r
-                                *\r
-                                * \remark                      To specify no timeout set the timeout value with -1.0.\r
-                                */\r
-                               void put(int channel, Task* task, double timeout) \r
-                               throw(MsgException, InvalidArgumentException);\r
-                               \r
-                               /* ! \brief Host::putBounded() - put a task on the given channel of a host object (capping the emission rate to maxrate).\r
-                                *\r
-                                * \param channel       The channel where to put the task.\r
-                                * \param rTask         A refercence to the task object containing the native task to\r
-                                *                                      put on the channel specified by the parameter channel.\r
-                                * \param maxRate       The maximum rate.\r
-                                *\r
-                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
-                                *                                      the method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [MsgException]                          if an internal error occurs.\r
-                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
-                                *                                                                                              parameter is negative or if the maxRate parameter value\r
-                                *                                                                                              is less than zero and différent of -1.0.\r
-                                *\r
-                                * \remark                      To specify no rate set the maxRate parameter value with -1.0.\r
-                                */\r
-                               void putBounded(int channel, Task* task, double maxRate) \r
-                               throw(MsgException, InvalidArgumentException);\r
-                               \r
-                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias.\r
-                                *\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [BadAllocException]                     if there is not enough memory to allocate\r
-                                *                                                                                              the default alias variable.\r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                */\r
-                               void send(Task* task) \r
-                               throw(MsgException, BadAllocException);\r
-                               \r
-                               /* ! brief Host::send() - sends the given task to mailbox identified by the specified alias parameter.\r
-                                *\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                * \param alias         The alias of the mailbox where to send the task.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [InvalidArgumentException]      if alias parameter is invalid (NULL).\r
-                                *                                      [BadAllocException]                     if there is not enough memory to allocate\r
-                                *                                                                                              the default alias variable.\r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                */\r
-                               void send(const char* alias, Task* task) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                               \r
-                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias\r
-                                *  (waiting at most timeout seconds).\r
-                                *\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                * \param timeout       The timeout value to wait for.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [BadAllocException]                     if there is not enough memory to allocate\r
-                                *                                                                                              the default alias variable.\r
-                                *                                      [InvalidArgumentException]      if the timeout value is negative and different of\r
-                                *                                                                                              -1.0.                   \r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                *\r
-                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous \r
-                                *                                      version of this method.\r
-                                *\r
-                                */\r
-                               void send(Task* task, double timeout) \r
-                               throw(InvalidArgumentException, BadAllocException, MsgException);\r
-                               \r
-                               /* ! brief Host::send() - sends the given task to mailbox identified by the parameter alias\r
-                                *  (waiting at most timeout seconds).\r
-                                *\r
-                                * \param alias         The alias of the mailbox to send the task.\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                * \param timeout       The timeout value to wait for.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [InvalidArgumentException]      if the timeout value is negative and different of\r
-                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       \r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                *\r
-                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous \r
-                                *                                      version of this method.\r
-                                *\r
-                                */\r
-                               void send(const char* alias, Task* task, double timeout) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                               \r
-                               /* ! brief Host::sendBounded() - sends the given task to mailbox associated to the default alias\r
-                                *  (capping the emission rate to maxRate).\r
-                                *\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                * \param maxRate       The maximum rate value.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of\r
-                                *                                                                                              -1.0.                   \r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                *                                      [BadAllocException]                     if there is not enough memory to allocate\r
-                                *                                                                                              the default alias variable.\r
-                                *\r
-                                * \remark                      To specify no rate set its value with -1.0.\r
-                                *\r
-                                */\r
-                               void sendBounded(Task* task, double maxRate) \r
-                               throw(InvalidArgumentException, BadAllocException, MsgException);\r
-                               \r
-                               /* ! brief Host::sendBounded() - sends the given task to mailbox identified by the parameter alias\r
-                                *  (capping the emission rate to maxRate).\r
-                                *\r
-                                * \param alias         The alias of the mailbox where to send the task.\r
-                                * \param rTask         A reference to the task object containing the native msg task to send.\r
-                                * \param maxRate       The maximum rate value.\r
-                                *\r
-                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
-                                *                                      method throws one of the exceptions described below.\r
-                                *\r
-                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of\r
-                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       \r
-                                *                                      [MsgException]                          if an internal error occurs.\r
-                                *\r
-                                * \remark                      To specify no rate set its value with -1.0.\r
-                                *\r
-                                */\r
-                               void sendBounded(const char* alias, Task* task, double maxRate) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                       protected:\r
-                       // Attributes.\r
-                       \r
-                               /**\r
-                                * This attribute represents the msg native host object. \r
-                                * It is set automaticatly during the call of the static \r
-                                * method Host::getByName().\r
-                                *\r
-                                * \see                         Host::getByName().\r
-                                */ \r
-                               m_host_t nativeHost;\r
-                       \r
-                       private:\r
-                               /**\r
-                                * User host data. \r
-                                */ \r
-                               void* data;\r
-               };\r
-               \r
-               typedef Host* HostPtr;\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_HOST_HPP\r
+/*
+ * Host.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_HOST_HPP
+#define MSG_HOST_HPP
+
+
+/*! \brief Host class declaration.
+ *
+ * An host instance represents a location (any possible place) where a process may run. 
+ * Thus it is represented as a physical resource with computing capabilities, some 
+ * mailboxes to enable running process to communicate with remote ones, and some private 
+ * data that can be only accessed by local process. An instance of this class is always 
+ * binded with the corresponding native host. All the native hosts are automaticaly created 
+ * during the call of the static method Msg::createEnvironment(). This method takes as parameter
+ * the platform file which describes all elements of the platform (host, link, root..).
+ * You never need to create an host your self.
+ *
+ * The best way to get an host is to call the static method 
+ * Host.getByName() which returns a reference.
+ *
+ * For example to get the instance of the host. If your platform
+ * file description contains an host named "Jacquelin" :
+ *
+ * \verbatim
+using namespace SimGrid.Msg;
+
+Host jacquelin;
+
+try 
+{ 
+       jacquelin = Host::getByName("Jacquelin");
+}
+catch(HostNotFoundException e) 
+{
+       cerr << e.toString();
+}
+...
+\endverbatim
+ *
+ */
+
+#ifndef __cplusplus
+       #error Host.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <msg/datatypes.h>
+
+#include <InvalidArgumentException.hpp>
+#include <BadAllocException.hpp>
+#include <HostNotFoundException.hpp>
+#include <MsgException.hpp>
+#include <NullPointerException.hpp>
+
+
+
+// namespace SimGrid::Msg
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class Task;
+               class Process;
+
+               // Declaration of the class SimGrid::Msg::Host.
+               class SIMGRIDX_EXPORT Host // final class.
+               {
+                       friend class Process;
+                       friend class Task;
+
+                       // Desable the default constructor.
+                       // The best way to get an host instance is to use the static method Host::getByName().
+                       
+                       public :
+                               
+                       // Default constructor (desabled).
+                               Host();
+                       
+                       public: 
+                               
+                       // Copy constructor (desabled).
+                               Host(const Host& rHost);
+                               
+                       // Destructor (desable).
+                               virtual ~Host();
+                       
+                       // Operations
+                       
+                               /*! \brief Host::getByName() - returns an host by its name
+                                *
+                                * This static method returns a reference to the host instance associated 
+                                * with a native host of your platform. This is the best way to get a host.
+                                *
+                                * \param hostName      The name of the host.
+                                *
+                                * \return                      If successful the method returns a reference to the instance
+                                *                                      associated with the native host having the name specified
+                                *                                      as parameter of your platform. Otherwise the method throws
+                                *                                      one of the exceptions detailed below.
+                                *
+                                * \exception           [HostNotFoundException]         if no host with the specified name
+                                *                                                                                              was found.
+                                *                                      [InvalidArgumentException]      if the hostName parameter is invalid (NULL).
+                                *                                      [BadAllocException]                     if there is not enough memory to allocate the host.
+                                */ 
+                               static Host& getByName(const char* hostName)
+                               throw(HostNotFoundException, NullPointerException, BadAllocException);
+                               
+                               /*! \brief Host::getNumber() - returns the number of the installed hosts.
+                                *
+                                * \return                      The number of hosts installed.
+                                */
+                               static int getNumber(void);
+                               
+                               
+                               /*! \brief Host::currentHost() - This static method returns the location on which the current 
+                                * process is executed.
+                                *
+                                * \return                      The host of the current process.
+                                *
+                                * \see                         Process::currentProcess().
+                                */
+                               static Host& currentHost(void);
+                               
+                               /*! \brief Host::all() - This static method retrieves all of the hosts of the installed platform.
+                                *
+                                * \param hosts         A pointer to array of Host pointers that receives all the hosts of the platform.
+                                *
+                                * \param len           A pointer to the length of the table of pointers.
+                                *
+                                * \return                      If successful the hosts table is filled and
+                                *                                      the parameter len is set with the number of hosts of the platform.
+                                *                                      Otherwise the method throw one of the exception described below.
+                                *
+                                * \exception           [InvalidArgumentException]      if the parameter hosts is invalid or
+                                *                                                                                              if the parameter len is negative or
+                                *                                                                                              less than the number of hosts installed
+                                *                                                                                              on the current platform.
+                                *                                      [BadAllocException]                     If the method can't allocate memory to fill
+                                *                                                                                              the table of hosts.
+                                *
+                                *
+                                * \remark                      To get the number of hosts installed on your platform use the static method
+                                *                                      Host::getNumber().
+                                *
+                                * \see                         Host::getNumber().
+                                *
+                                *\verbatim
+                                * // This example show how to use this method to get the list of hosts installed on your platform.
+                                *
+                                *      using namespace SimGrid::Msg;
+                                *      using <iostream>
+                                *
+                                *      // (1) get the number of hosts.
+                                *      int number = Host::getNumber();
+                                *      
+                                *      // (2) allocate the array that receives the list of hosts.
+                                *      HostPtr* ar = new HostPtr[number];      // HostPtr is defined as (typedef Host* HostPtr at the end of the
+                                *                                                                              // declaration of this class.
+                                *
+                                *      // (3) call the method
+                                *      try
+                                *      {
+                                *              Host::all(&ar, &number);
+                                *      }
+                                *      catch(BadAllocException e)
+                                *      {
+                                *              cerr << e.toString() << endl;
+                                *              ...
+                                *      }
+                                *      catch(InvalidArgumentException e)
+                                *      {
+                                *              cerr << e.toString() << endl;
+                                *              ..
+                                *      } 
+                                *
+                                *      // (4) use the table of host (for example print all the name of all the hosts);
+                                *      
+                                *      for(int i = 0; i < number ; i++)
+                                *              cout << ar[i]->getName() << endl;
+                                *
+                                *      ...
+                                *              
+                                *      // (5) release the allocate table
+                                *      
+                                *      delete[] ar;
+                                *
+                                */ 
+                               static void all(Host*** hosts /*in|out*/, int* len /*in|out*/)
+                               throw(InvalidArgumentException, BadAllocException) ;
+                               
+                               /*! \brief Host::getName() - This method return the name of the Msg host object.
+                                *
+                                * \return                      The name of the host object.
+                                */
+                               const char* getName(void) const;
+                               
+                               /*! \brief Host::setData() - Set the user data of an host object.
+                                *
+                                * \param data          The user data to set.
+                                */
+                               void setData(void* data);
+                               
+                               /*! \brief Host::getData() - Get the user data of a host object.
+                                *
+                                * \return                      The user data of the host object.
+                                */
+                               void* getData(void) const;
+                               
+                               /*! \brief Host::hasData() - Test if an host object has some data.
+                                *
+                                * \return                      This method returns true if the host object has some user data.
+                                *                                      Otherwise the method returns false.
+                                */
+                               bool hasData(void) const;
+                               
+                               /*! \brief Host::getRunningTaskNumber() - returns the number of tasks currently running on a host.
+                                *
+                                * \return                      The number of task currently running of the host object.
+                                *
+                                * \remark                      The external load is not taken in account.
+                                */
+                               int getRunningTaskNumber(void) const;
+                               
+                               /*! \brief Host::getSpeed() - returns the speed of the processor of a host,
+                                * regardless of the current load of the machine.
+                                *
+                                * \return                      The speed of the processor of the host in flops.
+                                */ 
+                               double getSpeed(void) const;
+                               
+                               /*! \brief Host::isAvailable - tests if an host is availabled.
+                                * 
+                                * \return                      Is the host is availabled the method returns
+                                *                                      1. Otherwise the method returns 0.
+                                */ 
+                               int isAvailable(void) const;
+                               
+                               /* ! \brief Host::put() - put a task on the given channel of a host .
+                                *
+                                * \param channel       The channel where to put the task.
+                                * \param rTask         A refercence to the task object containing the native task to
+                                *                                      put on the channel specified by the parameter channel.
+                                *
+                                * \return                      If successful the task is puted on the specified channel. Otherwise
+                                *                                      the method throws one of the exceptions described below.
+                                *
+                                * \exception           [MsgException]                          if an internal error occurs.
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as
+                                *                                                                                              parameter is negative.
+                                */
+                               void put(int channel, Task* task) 
+                               throw(MsgException, InvalidArgumentException);
+                               
+                               /* ! \brief Host::put() - put a task on the given channel of a host object (waiting at most timeout seconds).
+                                *
+                                * \param channel       The channel where to put the task.
+                                * \param rTask         A refercence to the task object containing the native task to
+                                *                                      put on the channel specified by the parameter channel.
+                                * \param timeout       The timeout in seconds.
+                                *
+                                * \return                      If successful the task is puted on the specified channel. Otherwise
+                                *                                      the method throws one of the exceptions described below.
+                                *
+                                * \exception           [MsgException]                          if an internal error occurs.
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as
+                                *                                                                                              parameter is negative or if the timeout value
+                                *                                                                                              is less than zero and différent of -1.
+                                *
+                                * \remark                      To specify no timeout set the timeout value with -1.0.
+                                */
+                               void put(int channel, Task* task, double timeout) 
+                               throw(MsgException, InvalidArgumentException);
+                               
+                               /* ! \brief Host::putBounded() - put a task on the given channel of a host object (capping the emission rate to maxrate).
+                                *
+                                * \param channel       The channel where to put the task.
+                                * \param rTask         A refercence to the task object containing the native task to
+                                *                                      put on the channel specified by the parameter channel.
+                                * \param maxRate       The maximum rate.
+                                *
+                                * \return                      If successful the task is puted on the specified channel. Otherwise
+                                *                                      the method throws one of the exceptions described below.
+                                *
+                                * \exception           [MsgException]                          if an internal error occurs.
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as
+                                *                                                                                              parameter is negative or if the maxRate parameter value
+                                *                                                                                              is less than zero and différent of -1.0.
+                                *
+                                * \remark                      To specify no rate set the maxRate parameter value with -1.0.
+                                */
+                               void putBounded(int channel, Task* task, double maxRate) 
+                               throw(MsgException, InvalidArgumentException);
+                               
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias.
+                                *
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [BadAllocException]                     if there is not enough memory to allocate
+                                *                                                                                              the default alias variable.
+                                *                                      [MsgException]                          if an internal error occurs.
+                                */
+                               void send(Task* task) 
+                               throw(MsgException, BadAllocException);
+                               
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the specified alias parameter.
+                                *
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                * \param alias         The alias of the mailbox where to send the task.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [InvalidArgumentException]      if alias parameter is invalid (NULL).
+                                *                                      [BadAllocException]                     if there is not enough memory to allocate
+                                *                                                                                              the default alias variable.
+                                *                                      [MsgException]                          if an internal error occurs.
+                                */
+                               void send(const char* alias, Task* task) 
+                               throw(InvalidArgumentException, MsgException);
+                               
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias
+                                *  (waiting at most timeout seconds).
+                                *
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                * \param timeout       The timeout value to wait for.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [BadAllocException]                     if there is not enough memory to allocate
+                                *                                                                                              the default alias variable.
+                                *                                      [InvalidArgumentException]      if the timeout value is negative and different of
+                                *                                                                                              -1.0.                   
+                                *                                      [MsgException]                          if an internal error occurs.
+                                *
+                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous 
+                                *                                      version of this method.
+                                *
+                                */
+                               void send(Task* task, double timeout) 
+                               throw(InvalidArgumentException, BadAllocException, MsgException);
+                               
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the parameter alias
+                                *  (waiting at most timeout seconds).
+                                *
+                                * \param alias         The alias of the mailbox to send the task.
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                * \param timeout       The timeout value to wait for.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [InvalidArgumentException]      if the timeout value is negative and different of
+                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       
+                                *                                      [MsgException]                          if an internal error occurs.
+                                *
+                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous 
+                                *                                      version of this method.
+                                *
+                                */
+                               void send(const char* alias, Task* task, double timeout) 
+                               throw(InvalidArgumentException, MsgException);
+                               
+                               /* ! brief Host::sendBounded() - sends the given task to mailbox associated to the default alias
+                                *  (capping the emission rate to maxRate).
+                                *
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                * \param maxRate       The maximum rate value.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of
+                                *                                                                                              -1.0.                   
+                                *                                      [MsgException]                          if an internal error occurs.
+                                *                                      [BadAllocException]                     if there is not enough memory to allocate
+                                *                                                                                              the default alias variable.
+                                *
+                                * \remark                      To specify no rate set its value with -1.0.
+                                *
+                                */
+                               void sendBounded(Task* task, double maxRate) 
+                               throw(InvalidArgumentException, BadAllocException, MsgException);
+                               
+                               /* ! brief Host::sendBounded() - sends the given task to mailbox identified by the parameter alias
+                                *  (capping the emission rate to maxRate).
+                                *
+                                * \param alias         The alias of the mailbox where to send the task.
+                                * \param rTask         A reference to the task object containing the native msg task to send.
+                                * \param maxRate       The maximum rate value.
+                                *
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the
+                                *                                      method throws one of the exceptions described below.
+                                *
+                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of
+                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       
+                                *                                      [MsgException]                          if an internal error occurs.
+                                *
+                                * \remark                      To specify no rate set its value with -1.0.
+                                *
+                                */
+                               void sendBounded(const char* alias, Task* task, double maxRate) 
+                               throw(InvalidArgumentException, MsgException);
+                       
+                       protected:
+                       // Attributes.
+                       
+                               /**
+                                * This attribute represents the msg native host object. 
+                                * It is set automaticatly during the call of the static 
+                                * method Host::getByName().
+                                *
+                                * \see                         Host::getByName().
+                                */ 
+                               m_host_t nativeHost;
+                       
+                       private:
+                               /**
+                                * User host data. 
+                                */ 
+                               void* data;
+               };
+               
+               typedef Host* HostPtr;
+       } // namespace Msg
+} // namespace SimGrid
+
+#endif // !MSG_HOST_HPP
index c2b9211..213ab12 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * HostNotFoundException.cxx\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
- /* HostNotFoundException member functions implementation.\r
-  */  \r
-\r
-#include <HostNotFoundException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       HostNotFoundException::HostNotFoundException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Host not found : unknown");\r
-                       }\r
-               \r
-               \r
-                       HostNotFoundException::HostNotFoundException(const HostNotFoundException& rHostNotFoundException)\r
-                       {\r
-                               const char* reason = rHostNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       HostNotFoundException::HostNotFoundException(const char* name)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Host not found : ") + strlen(name) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Host not found : %s", name);\r
-                       }\r
-               \r
-               \r
-                       HostNotFoundException::~HostNotFoundException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* HostNotFoundException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const HostNotFoundException& HostNotFoundException::operator = (const HostNotFoundException& rHostNotFoundException)\r
-                       {\r
-                               const char* reason = rHostNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * HostNotFoundException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* HostNotFoundException member functions implementation.
+  */  
+
+#include <HostNotFoundException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       HostNotFoundException::HostNotFoundException()
+                       {
+                               this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));
+                               strcpy(this->reason, "Host not found : unknown");
+                       }
+               
+               
+                       HostNotFoundException::HostNotFoundException(const HostNotFoundException& rHostNotFoundException)
+                       {
+                               const char* reason = rHostNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       HostNotFoundException::HostNotFoundException(const char* name)
+                       {
+                               this->reason = (char*) calloc(strlen("Host not found : ") + strlen(name) + 1, sizeof(char));
+                               sprintf(this->reason, "Host not found : %s", name);
+                       }
+               
+               
+                       HostNotFoundException::~HostNotFoundException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* HostNotFoundException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const HostNotFoundException& HostNotFoundException::operator = (const HostNotFoundException& rHostNotFoundException)
+                       {
+                               const char* reason = rHostNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index a810d04..c8458ba 100644 (file)
@@ -1,70 +1,70 @@
-/*\r
- * HostNotFoundException.hpp\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_HOSTNOTFOUNDEXCEPTION_HPP\r
-#define MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error HostNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT HostNotFoundException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               HostNotFoundException();\r
-                       \r
-                       // Copy constructor.\r
-                               HostNotFoundException(const HostNotFoundException& rHostNotFoundException);\r
-                       \r
-                       // This constructor takes the name of the host not found.\r
-                               HostNotFoundException(const char* name);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~HostNotFoundException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Host not found `host name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const HostNotFoundException& operator = (const HostNotFoundException& rHostNotFoundException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
-\r
-\r
+/*
+ * HostNotFoundException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_HOSTNOTFOUNDEXCEPTION_HPP
+#define MSG_HOSTNOTFOUNDEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error HostNotFoundException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT HostNotFoundException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               HostNotFoundException();
+                       
+                       // Copy constructor.
+                               HostNotFoundException(const HostNotFoundException& rHostNotFoundException);
+                       
+                       // This constructor takes the name of the host not found.
+                               HostNotFoundException(const char* name);
+                       
+                       // Destructor.
+                               virtual ~HostNotFoundException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Host not found `host name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const HostNotFoundException& operator = (const HostNotFoundException& rHostNotFoundException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_HOSTNOTFOUNDEXCEPTION_HPP
+
+
index dc44244..c82d517 100644 (file)
@@ -1,76 +1,76 @@
-/*\r
- * InvalidArgumentException.cxx\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
- /* InvalidArgumentException member functions implementation.\r
-  */  \r
-\r
-\r
-#include <InvalidArgumentException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       InvalidArgumentException::InvalidArgumentException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Invalid argument : unknown") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Invalid argument : unknown");\r
-                       }\r
-               \r
-               \r
-                       InvalidArgumentException::InvalidArgumentException(const InvalidArgumentException& rInvalidArgumentException)\r
-                       {\r
-                               const char* reason = rInvalidArgumentException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       InvalidArgumentException::InvalidArgumentException(const char* name)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Invalid argument : ") + strlen(name) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Invalid argument : %s", name);\r
-                       }\r
-               \r
-               \r
-                       InvalidArgumentException::~InvalidArgumentException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* InvalidArgumentException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const InvalidArgumentException& InvalidArgumentException::operator = (const InvalidArgumentException& rInvalidArgumentException)\r
-                       {\r
-                               const char* reason = rInvalidArgumentException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * InvalidArgumentException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* InvalidArgumentException member functions implementation.
+  */  
+
+
+#include <InvalidArgumentException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       InvalidArgumentException::InvalidArgumentException()
+                       {
+                               this->reason = (char*) calloc(strlen("Invalid argument : unknown") + 1, sizeof(char));
+                               strcpy(this->reason, "Invalid argument : unknown");
+                       }
+               
+               
+                       InvalidArgumentException::InvalidArgumentException(const InvalidArgumentException& rInvalidArgumentException)
+                       {
+                               const char* reason = rInvalidArgumentException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       InvalidArgumentException::InvalidArgumentException(const char* name)
+                       {
+                               this->reason = (char*) calloc(strlen("Invalid argument : ") + strlen(name) + 1, sizeof(char));
+                               sprintf(this->reason, "Invalid argument : %s", name);
+                       }
+               
+               
+                       InvalidArgumentException::~InvalidArgumentException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* InvalidArgumentException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const InvalidArgumentException& InvalidArgumentException::operator = (const InvalidArgumentException& rInvalidArgumentException)
+                       {
+                               const char* reason = rInvalidArgumentException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index fc4b201..5b779b5 100644 (file)
@@ -1,69 +1,69 @@
-/*\r
- * InvalidArgumentException.hpp\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_INVALIDARGUMENTEXCEPTION_HPP\r
-#define MSG_INVALIDARGUMENTEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error InvalidArgumentException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT InvalidArgumentException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               InvalidArgumentException();\r
-                       \r
-                       // Copy constructor.\r
-                               InvalidArgumentException(const InvalidArgumentException& rInvalidArgumentException);\r
-                       \r
-                       // This constructor takes the name of the invalid argument.\r
-                               InvalidArgumentException(const char* name);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~InvalidArgumentException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Invalid argument `argument name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const InvalidArgumentException& operator = (const InvalidArgumentException& rInvalidArgumentException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
-\r
+/*
+ * InvalidArgumentException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_INVALIDARGUMENTEXCEPTION_HPP
+#define MSG_INVALIDARGUMENTEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error InvalidArgumentException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT InvalidArgumentException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               InvalidArgumentException();
+                       
+                       // Copy constructor.
+                               InvalidArgumentException(const InvalidArgumentException& rInvalidArgumentException);
+                       
+                       // This constructor takes the name of the invalid argument.
+                               InvalidArgumentException(const char* name);
+                       
+                       // Destructor.
+                               virtual ~InvalidArgumentException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Invalid argument `argument name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const InvalidArgumentException& operator = (const InvalidArgumentException& rInvalidArgumentException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP
+
index e1594f2..b911229 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * LogicException.cxx\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
- /* LogicException member functions implementation.\r
-  */  \r
-\r
-#include <LogicException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       LogicException::LogicException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Logic exception : no detail") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Logic exception : no detail");\r
-                       }\r
-               \r
-               \r
-                       LogicException::LogicException(const LogicException& rLogicException)\r
-                       {\r
-                               const char* reason = rLogicException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       LogicException::LogicException(const char* detail)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Logic exception : ") + strlen(detail) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Logic exception : %s", detail);\r
-                       }\r
-               \r
-               \r
-                       LogicException::~LogicException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* LogicException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const LogicException& LogicException::operator = (const LogicException& rLogicException)\r
-                       {\r
-                               const char* reason = rLogicException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * LogicException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* LogicException member functions implementation.
+  */  
+
+#include <LogicException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       LogicException::LogicException()
+                       {
+                               this->reason = (char*) calloc(strlen("Logic exception : no detail") + 1, sizeof(char));
+                               strcpy(this->reason, "Logic exception : no detail");
+                       }
+               
+               
+                       LogicException::LogicException(const LogicException& rLogicException)
+                       {
+                               const char* reason = rLogicException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       LogicException::LogicException(const char* detail)
+                       {
+                               this->reason = (char*) calloc(strlen("Logic exception : ") + strlen(detail) + 1, sizeof(char));
+                               sprintf(this->reason, "Logic exception : %s", detail);
+                       }
+               
+               
+                       LogicException::~LogicException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* LogicException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const LogicException& LogicException::operator = (const LogicException& rLogicException)
+                       {
+                               const char* reason = rLogicException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index a357439..fb2ffd9 100644 (file)
@@ -1,70 +1,70 @@
-/*\r
- * LogicException.hpp\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_LOGICEXCEPTION_HPP\r
-#define MSG_LOGICEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error LogicException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT LogicException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               LogicException();\r
-                       \r
-                       // Copy constructor.\r
-                               LogicException(const LogicException& rLogicException);\r
-                       \r
-                       // This constructor takes the detail of the logic exception.\r
-                               LogicException(const char* detail);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~LogicException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Logic exception `detail'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const LogicException& operator = (const LogicException& rLogicException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
-\r
-\r
+/*
+ * LogicException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_LOGICEXCEPTION_HPP
+#define MSG_LOGICEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error LogicException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT LogicException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               LogicException();
+                       
+                       // Copy constructor.
+                               LogicException(const LogicException& rLogicException);
+                       
+                       // This constructor takes the detail of the logic exception.
+                               LogicException(const char* detail);
+                       
+                       // Destructor.
+                               virtual ~LogicException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Logic exception `detail'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const LogicException& operator = (const LogicException& rLogicException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP
+
+
index daac88e..eb23f4f 100644 (file)
-\r
-/*\r
- * Msg.cxx\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
- /* Msg functions implementation.\r
-  */  \r
-\r
-\r
-#include <Msg.hpp>\r
-#include <Host.hpp>\r
-#include <Process.hpp>\r
-\r
-\r
-#include <msg/msg.h>\r
-#include <msg/private.h>\r
-\r
-#include <iostream>\r
-using std::cout;\r
-using std::endl;\r
-using std::streamsize;\r
-\r
-#include <iomanip>\r
-using std::setprecision;\r
-using std::setw;\r
-\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)\r
-               \r
-               void init(int argc, char** argv)\r
-               {\r
-                       MSG_global_init(&argc,argv);\r
-\r
-                       if(getMaxChannelNumber() == 0)\r
-                               setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);\r
-               }       \r
-               \r
-               void finalize(void)\r
-               throw (MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_clean())\r
-                               throw MsgException("MSG_clean() failed");\r
-                       \r
-               }\r
-               \r
-               void info(const StringHelper& s)\r
-               {\r
-                       StringHelper clock;\r
-                       \r
-                       cout << "[";\r
-                       cout << Host::currentHost().getName();\r
-                       cout << ":";\r
-                       cout << Process::currentProcess().getName();\r
-                       cout << ":(";\r
-                       cout << Process::currentProcess().getPID();\r
-                       cout << ") " ;\r
-                       cout << clock.append(getClock(), "%07lf");\r
-                       cout << "] [cxx4msg/INFO] ";\r
-                       cout << s;\r
-                       cout << endl;\r
-               }\r
-\r
-               void info(const char* s)\r
-               {\r
-                       StringHelper clock;\r
-                       \r
-                       cout << "[";\r
-                       cout << Host::currentHost().getName();\r
-                       cout << ":";\r
-                       cout << Process::currentProcess().getName();\r
-                       cout << ":(";\r
-                       cout << Process::currentProcess().getPID();\r
-                       cout << ") " ;\r
-                       cout << clock.append(getClock(), "%07lf");\r
-                       cout << "] [cxx4msg/INFO] ";\r
-                       cout << s;\r
-                       cout << endl;\r
-               }\r
-\r
-               void error(const StringHelper& s)\r
-               {\r
-                       StringHelper clock;\r
-                       \r
-                       cout << "[";\r
-                       cout << Host::currentHost().getName();\r
-                       cout << ":";\r
-                       cout << Process::currentProcess().getName();\r
-                       cout << ":(";\r
-                       cout << Process::currentProcess().getPID();\r
-                       cout << ") " ;\r
-                       cout << clock.append(getClock(), "%07lf");\r
-                       cout << "] [cxx4msg/ERROR] ";\r
-                       cout << s;\r
-                       cout << endl;\r
-               }\r
-\r
-               void error(const char* s)\r
-               {\r
-                       StringHelper clock;\r
-                       \r
-                       cout << "[";\r
-                       cout << Host::currentHost().getName();\r
-                       cout << ":";\r
-                       cout << Process::currentProcess().getName();\r
-                       cout << ":(";\r
-                       cout << Process::currentProcess().getPID();\r
-                       cout << ") " ;\r
-                       cout << clock.append(getClock(), "%07lf");\r
-                       cout << "] [cxx4msg/ERROR] ";\r
-                       cout << s;\r
-                       cout << endl;\r
-               }\r
-\r
-               double getClock(void)\r
-               {\r
-                       return MSG_get_clock();\r
-               }\r
-\r
-               void setMaxChannelNumber(int number)\r
-               throw(InvalidArgumentException, LogicException)\r
-               {\r
-                       if(msg_global->max_channel > 0)\r
-                               throw LogicException("Max channel number already setted");\r
-\r
-                       if(number < 0)\r
-                               throw InvalidArgumentException("number");\r
-\r
-                       msg_global->max_channel = number;\r
-               }\r
-\r
-               int getMaxChannelNumber(void)\r
-               {\r
-                       return msg_global->max_channel;\r
-               }\r
-\r
-       } // namespace Msg\r
-\r
-} // namespace SimGrid\r
-\r
+
+/*
+ * Msg.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Msg functions implementation.
+  */  
+
+
+#include <Msg.hpp>
+#include <Host.hpp>
+#include <Process.hpp>
+
+
+#include <msg/msg.h>
+#include <msg/private.h>
+
+#include <iostream>
+using std::cout;
+using std::endl;
+using std::streamsize;
+
+#include <iomanip>
+using std::setprecision;
+using std::setw;
+
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               #define SIMGRIDX_DEFAULT_CHANNEL_NUMBER ((int)10)
+               
+               void init(int argc, char** argv)
+               {
+                       MSG_global_init(&argc,argv);
+
+                       if(getMaxChannelNumber() == 0)
+                               setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);
+               }       
+               
+               void finalize(void)
+               throw (MsgException)
+               {
+                       if(MSG_OK != MSG_clean())
+                               throw MsgException("MSG_clean() failed");
+                       
+               }
+               
+               void info(const StringHelper& s)
+               {
+                       StringHelper clock;
+                       
+                       cout << "[";
+                       cout << Host::currentHost().getName();
+                       cout << ":";
+                       cout << Process::currentProcess().getName();
+                       cout << ":(";
+                       cout << Process::currentProcess().getPID();
+                       cout << ") " ;
+                       cout << clock.append(getClock(), "%07lf");
+                       cout << "] [cxx4msg/INFO] ";
+                       cout << s;
+                       cout << endl;
+               }
+
+               void info(const char* s)
+               {
+                       StringHelper clock;
+                       
+                       cout << "[";
+                       cout << Host::currentHost().getName();
+                       cout << ":";
+                       cout << Process::currentProcess().getName();
+                       cout << ":(";
+                       cout << Process::currentProcess().getPID();
+                       cout << ") " ;
+                       cout << clock.append(getClock(), "%07lf");
+                       cout << "] [cxx4msg/INFO] ";
+                       cout << s;
+                       cout << endl;
+               }
+
+               void error(const StringHelper& s)
+               {
+                       StringHelper clock;
+                       
+                       cout << "[";
+                       cout << Host::currentHost().getName();
+                       cout << ":";
+                       cout << Process::currentProcess().getName();
+                       cout << ":(";
+                       cout << Process::currentProcess().getPID();
+                       cout << ") " ;
+                       cout << clock.append(getClock(), "%07lf");
+                       cout << "] [cxx4msg/ERROR] ";
+                       cout << s;
+                       cout << endl;
+               }
+
+               void error(const char* s)
+               {
+                       StringHelper clock;
+                       
+                       cout << "[";
+                       cout << Host::currentHost().getName();
+                       cout << ":";
+                       cout << Process::currentProcess().getName();
+                       cout << ":(";
+                       cout << Process::currentProcess().getPID();
+                       cout << ") " ;
+                       cout << clock.append(getClock(), "%07lf");
+                       cout << "] [cxx4msg/ERROR] ";
+                       cout << s;
+                       cout << endl;
+               }
+
+               double getClock(void)
+               {
+                       return MSG_get_clock();
+               }
+
+               void setMaxChannelNumber(int number)
+               throw(InvalidArgumentException, LogicException)
+               {
+                       if(msg_global->max_channel > 0)
+                               throw LogicException("Max channel number already setted");
+
+                       if(number < 0)
+                               throw InvalidArgumentException("number");
+
+                       msg_global->max_channel = number;
+               }
+
+               int getMaxChannelNumber(void)
+               {
+                       return msg_global->max_channel;
+               }
+
+       } // namespace Msg
+
+} // namespace SimGrid
+
index 048e38c..95095fb 100644 (file)
@@ -1,80 +1,80 @@
-/*\r
- * Msg.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_HPP\r
-#define MSG_HPP\r
-\r
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
-       #error Msg.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <MsgException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <LogicException.hpp>\r
-\r
-#include <StringHelper.hpp>\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class MsgException;\r
-               class InvalidArgumentException;\r
-               class LogicException;\r
-               \r
-               /*! \brief init() - Initialize MSG (This function must be called at the begining of each simulation).\r
-                *\r
-                * \param argv                  A list of arguments.\r
-                * \param argc                  The number of arguments of the list.\r
-                */\r
-               SIMGRIDX_EXPORT void init(int argc, char** argv);\r
-               \r
-               /*! \brief finalize() - Finalize MSG (This function must be called at the end of each simulation).\r
-                *\r
-                * \exception                   If this function fails, it throws a exception describing the cause of the failure.\r
-                */\r
-               SIMGRIDX_EXPORT void finalize(void)\r
-               throw (MsgException);\r
-               \r
-               /*! \brief info() - Display information (using xbt log format).\r
-                *\r
-                * \param s                             The information to display.\r
-                */\r
-               SIMGRIDX_EXPORT void info(const StringHelper& s);\r
-\r
-               SIMGRIDX_EXPORT void info(const char* s);\r
-\r
-               SIMGRIDX_EXPORT void error(const StringHelper& s);\r
-\r
-               SIMGRIDX_EXPORT void error(const char* s);\r
-\r
-\r
-               /*! \brief getClock() -  Retrieve the simulation time\r
-                *\r
-                * \return                              The current simulation time.\r
-                */\r
-               SIMGRIDX_EXPORT double getClock(void);\r
-\r
-\r
-               SIMGRIDX_EXPORT void setMaxChannelNumber(int number)\r
-               throw(InvalidArgumentException, LogicException);\r
-\r
-               SIMGRIDX_EXPORT int getMaxChannelNumber(void);\r
-               \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_HPP\r
+/*
+ * Msg.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_HPP
+#define MSG_HPP
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+       #error Msg.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <MsgException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <LogicException.hpp>
+
+#include <StringHelper.hpp>
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class MsgException;
+               class InvalidArgumentException;
+               class LogicException;
+               
+               /*! \brief init() - Initialize MSG (This function must be called at the begining of each simulation).
+                *
+                * \param argv                  A list of arguments.
+                * \param argc                  The number of arguments of the list.
+                */
+               SIMGRIDX_EXPORT void init(int argc, char** argv);
+               
+               /*! \brief finalize() - Finalize MSG (This function must be called at the end of each simulation).
+                *
+                * \exception                   If this function fails, it throws a exception describing the cause of the failure.
+                */
+               SIMGRIDX_EXPORT void finalize(void)
+               throw (MsgException);
+               
+               /*! \brief info() - Display information (using xbt log format).
+                *
+                * \param s                             The information to display.
+                */
+               SIMGRIDX_EXPORT void info(const StringHelper& s);
+
+               SIMGRIDX_EXPORT void info(const char* s);
+
+               SIMGRIDX_EXPORT void error(const StringHelper& s);
+
+               SIMGRIDX_EXPORT void error(const char* s);
+
+
+               /*! \brief getClock() -  Retrieve the simulation time
+                *
+                * \return                              The current simulation time.
+                */
+               SIMGRIDX_EXPORT double getClock(void);
+
+
+               SIMGRIDX_EXPORT void setMaxChannelNumber(int number)
+               throw(InvalidArgumentException, LogicException);
+
+               SIMGRIDX_EXPORT int getMaxChannelNumber(void);
+               
+       } // namespace Msg
+} // namespace SimGrid
+
+#endif // !MSG_HPP
index 891588f..25c1ab2 100644 (file)
@@ -1,74 +1,74 @@
-/*\r
- * MsgException.cxx\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
- /* MsgException member functions implementation.\r
-  */  \r
-\r
-#include <MsgException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       MsgException::MsgException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Internal exception : unknown reason") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Internal exception : unknown reason");\r
-                       }\r
-               \r
-               \r
-                       MsgException::MsgException(const MsgException& rMsgException)\r
-                       {\r
-                               const char* reason = rMsgException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-                       MsgException::MsgException(const char* reason)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Internal exception : ") + strlen(reason) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Invalid exception : %s", reason);\r
-                       }\r
-               \r
-               \r
-                       MsgException::~MsgException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* MsgException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const MsgException& MsgException::operator = (const MsgException& rMsgException)\r
-                       {\r
-                               const char* reason = rMsgException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * MsgException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* MsgException member functions implementation.
+  */  
+
+#include <MsgException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       MsgException::MsgException()
+                       {
+                               this->reason = (char*) calloc(strlen("Internal exception : unknown reason") + 1, sizeof(char));
+                               strcpy(this->reason, "Internal exception : unknown reason");
+                       }
+               
+               
+                       MsgException::MsgException(const MsgException& rMsgException)
+                       {
+                               const char* reason = rMsgException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+                       MsgException::MsgException(const char* reason)
+                       {
+                               this->reason = (char*) calloc(strlen("Internal exception : ") + strlen(reason) + 1, sizeof(char));
+                               sprintf(this->reason, "Invalid exception : %s", reason);
+                       }
+               
+               
+                       MsgException::~MsgException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* MsgException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const MsgException& MsgException::operator = (const MsgException& rMsgException)
+                       {
+                               const char* reason = rMsgException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index 7d978f3..b39fc12 100644 (file)
@@ -1,65 +1,65 @@
-/*\r
- * MsgException.hpp\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_MSGEXCEPTION_HPP\r
-#define MSG_MSGEXCEPTION_HPP\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT MsgException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               MsgException();\r
-                       \r
-                       // Copy constructor.\r
-                               MsgException(const MsgException& rMsgException);\r
-                       \r
-                       // This constructor takes the reason of the exception.\r
-                               MsgException(const char* reason);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~MsgException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Internal exception `reason'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const MsgException& operator = (const MsgException& rMsgException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_MSGEXCEPTION_HPP\r
-\r
+/*
+ * MsgException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_MSGEXCEPTION_HPP
+#define MSG_MSGEXCEPTION_HPP
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT MsgException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               MsgException();
+                       
+                       // Copy constructor.
+                               MsgException(const MsgException& rMsgException);
+                       
+                       // This constructor takes the reason of the exception.
+                               MsgException(const char* reason);
+                       
+                       // Destructor.
+                               virtual ~MsgException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Internal exception `reason'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const MsgException& operator = (const MsgException& rMsgException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_MSGEXCEPTION_HPP
+
index 79aac80..df42ea3 100644 (file)
@@ -1,75 +1,75 @@
-/*\r
- * NullPointerException.cxx\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
- /* NullPointerException member functions implementation.\r
-  */  \r
-\r
-#include <NullPointerException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       NullPointerException::NullPointerException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Null pointer : unknown") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Null pointer : unknown");\r
-                       }\r
-               \r
-               \r
-                       NullPointerException::NullPointerException(const NullPointerException& rNullPointerException)\r
-                       {\r
-                               const char* reason = rNullPointerException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       NullPointerException::NullPointerException(const char* name)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Null pointer : ") + strlen(name) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Null pointer : %s", name);\r
-                       }\r
-               \r
-               \r
-                       NullPointerException::~NullPointerException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* NullPointerException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const NullPointerException& NullPointerException::operator = (const NullPointerException& rNullPointerException)\r
-                       {\r
-                               const char* reason = rNullPointerException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * NullPointerException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* NullPointerException member functions implementation.
+  */  
+
+#include <NullPointerException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       NullPointerException::NullPointerException()
+                       {
+                               this->reason = (char*) calloc(strlen("Null pointer : unknown") + 1, sizeof(char));
+                               strcpy(this->reason, "Null pointer : unknown");
+                       }
+               
+               
+                       NullPointerException::NullPointerException(const NullPointerException& rNullPointerException)
+                       {
+                               const char* reason = rNullPointerException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       NullPointerException::NullPointerException(const char* name)
+                       {
+                               this->reason = (char*) calloc(strlen("Null pointer : ") + strlen(name) + 1, sizeof(char));
+                               sprintf(this->reason, "Null pointer : %s", name);
+                       }
+               
+               
+                       NullPointerException::~NullPointerException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* NullPointerException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const NullPointerException& NullPointerException::operator = (const NullPointerException& rNullPointerException)
+                       {
+                               const char* reason = rNullPointerException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index 659e3ad..d23f8c6 100644 (file)
@@ -1,69 +1,69 @@
-/*\r
- * NullPointerException.hpp\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_NULLPOINTEREXCEPTION_HPP\r
-#define MSG_NULLPOINTEREXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error NullPointerException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT NullPointerException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               NullPointerException();\r
-                       \r
-                       // Copy constructor.\r
-                               NullPointerException(const NullPointerException& rNullPointerException);\r
-                       \r
-                       // This constructor takes the name of the invalid argument.\r
-                               NullPointerException(const char* name);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~NullPointerException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Null pointer `pointer name'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const NullPointerException& operator = (const NullPointerException& rNullPointerException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_NULLPOINTEREXCEPTION_HPP\r
-\r
+/*
+ * NullPointerException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_NULLPOINTEREXCEPTION_HPP
+#define MSG_NULLPOINTEREXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error NullPointerException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT NullPointerException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               NullPointerException();
+                       
+                       // Copy constructor.
+                               NullPointerException(const NullPointerException& rNullPointerException);
+                       
+                       // This constructor takes the name of the invalid argument.
+                               NullPointerException(const char* name);
+                       
+                       // Destructor.
+                               virtual ~NullPointerException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Null pointer `pointer name'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const NullPointerException& operator = (const NullPointerException& rNullPointerException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_NULLPOINTEREXCEPTION_HPP
+
index 5d91680..b7ca4b4 100644 (file)
-/*\r
- * Object.cxx\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
- /* SimGrid::Msg RTTI implementation.\r
-  */  \r
-\r
-#include <Object.hpp>\r
-#include <string.h>\r
-\r
-#include <xbt/dynar.h>\r
-\r
-\r
-\r
-\r
-DeclaringClasses* DeclaringClass::declaringClasses = NULL;\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               // Generate static object constructor for class registration\r
-               void DeclareClass(Class* c)\r
-               {\r
-                       MSG_DELCARING_CLASSES.lock();\r
-                       MSG_DELCARING_CLASSES.addHead(c);\r
-                       MSG_DELCARING_CLASSES.unlock();\r
-               }\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-// Implémentation des fonctions membre de la classe Class\r
-\r
-// true if the class is derived from base classe referenced \r
-// by pBaseClass\r
-bool Class::isDerivedFrom(const Class* baseClass) const\r
-{\r
-       const Class* cur = this;\r
-\r
-       while(cur)\r
-       {\r
-               if(cur == baseClass)\r
-                       return true;\r
-\r
-               cur = cur->baseClass;\r
-       }\r
-\r
-       return false;\r
-}\r
-\r
-// Dynamic name lookup and creation\r
-Class* Class::fromName(const char* name)\r
-throw (ClassNotFoundException)\r
-{\r
-       Class* cur;\r
-\r
-       MSG_DELCARING_CLASSES.lock();\r
-       \r
-       for(cur = MSG_DELCARING_CLASSES.getHead(); cur; cur = cur->next)\r
-       {\r
-               if(!strcmp(name,cur->name))\r
-                       return cur;\r
-\r
-       }\r
-\r
-       MSG_DELCARING_CLASSES.unlock();\r
-       throw ClassNotFoundException(name);\r
-}\r
-\r
-\r
-Object* Class::createObject(const char* name)\r
-{\r
-       Class* c = fromName(name);\r
-       return c->createObject();\r
-}\r
-\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-// Object members implementation\r
-\r
-// Special runtime-class structure for Object (no base class)\r
-const struct Class Object::classObject =\r
-{ \r
-       "Object",               // name\r
-       sizeof(Object), // typeSize\r
-       NULL,                   // baseClass\r
-       NULL,                   // next\r
-       NULL                    // declaringClass\r
-};\r
-\r
-\r
-//////////////////////////////////////////////////////////////////////////////\r
-// DeclaringClasses members implementation\r
-//\r
-\r
-DeclaringClasses::DeclaringClasses()\r
-{\r
-        head = NULL;\r
-        count = 0;\r
-}\r
-\r
-\r
-// Ajoute une nouvelle classe en tête de liste\r
-void DeclaringClasses::addHead(Class* c)\r
-{\r
-       if(NULL != head)\r
-               c->next = head;\r
-\r
-       head = c;\r
-    count++;\r
-}\r
-\r
-// Retourne la tête de liste et la retire de la liste\r
-Class* DeclaringClasses::removeHead(void)\r
-{\r
-       Class* c = NULL;\r
-\r
-       if(NULL != head)\r
-       {\r
-               c = head;\r
-               head = head->next;\r
-               count--;\r
-       }\r
-\r
-       return c;\r
-}\r
-\r
-// Retire la classe pClasse de la liste, mais ne la détruit pas \r
-bool DeclaringClasses::remove(Class* c)\r
-{\r
-       if(NULL == head)\r
-               return false;\r
-\r
-       bool success = false;\r
-\r
-       if(head == c)\r
-       {\r
-               head = c->next;\r
-        count--;\r
-               success = true;\r
-       }\r
-       else\r
-       {\r
-               Class* cur = head;\r
-\r
-               while((NULL != cur) && (cur->next!= c))\r
-                       cur = cur->next;\r
-\r
-               if(NULL != cur)\r
-               {\r
-                       cur->next = c->next;\r
-            count--;\r
-                       success = true;\r
-               }\r
-       }\r
-       \r
-       return success;\r
-}\r
-\r
-bool Object::isInstanceOf(const char* className)\r
-{\r
-       Class* c = Class::fromName(className);\r
-\r
-       return this->getClass()->isDerivedFrom(c);\r
-}\r
-               \r
-\r
+/*
+ * Object.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* SimGrid::Msg RTTI implementation.
+  */  
+
+#include <Object.hpp>
+#include <string.h>
+
+#include <xbt/dynar.h>
+
+
+
+
+DeclaringClasses* DeclaringClass::declaringClasses = NULL;
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               // Generate static object constructor for class registration
+               void DeclareClass(Class* c)
+               {
+                       MSG_DELCARING_CLASSES.lock();
+                       MSG_DELCARING_CLASSES.addHead(c);
+                       MSG_DELCARING_CLASSES.unlock();
+               }
+       } // namespace Msg
+} // namespace SimGrid
+
+//////////////////////////////////////////////////////////////////////////////
+// Implémentation des fonctions membre de la classe Class
+
+// true if the class is derived from base classe referenced 
+// by pBaseClass
+bool Class::isDerivedFrom(const Class* baseClass) const
+{
+       const Class* cur = this;
+
+       while(cur)
+       {
+               if(cur == baseClass)
+                       return true;
+
+               cur = cur->baseClass;
+       }
+
+       return false;
+}
+
+// Dynamic name lookup and creation
+Class* Class::fromName(const char* name)
+throw (ClassNotFoundException)
+{
+       Class* cur;
+
+       MSG_DELCARING_CLASSES.lock();
+       
+       for(cur = MSG_DELCARING_CLASSES.getHead(); cur; cur = cur->next)
+       {
+               if(!strcmp(name,cur->name))
+               {
+                       MSG_DELCARING_CLASSES.unlock();
+                       return cur;
+               }
+       }
+
+       MSG_DELCARING_CLASSES.unlock();
+       throw ClassNotFoundException(name);
+}
+
+
+Object* Class::createObject(const char* name)
+{
+       Class* c = fromName(name);
+       return c->createObject();
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+// Object members implementation
+
+// Special runtime-class structure for Object (no base class)
+const struct Class Object::classObject =
+{ 
+       "Object",               // name
+       sizeof(Object), // typeSize
+       NULL,                   // baseClass
+       NULL,                   // next
+       NULL                    // declaringClass
+};
+
+
+//////////////////////////////////////////////////////////////////////////////
+// DeclaringClasses members implementation
+//
+
+DeclaringClasses::DeclaringClasses()
+{
+        head = NULL;
+        count = 0;
+}
+
+
+// Ajoute une nouvelle classe en tête de liste
+void DeclaringClasses::addHead(Class* c)
+{
+       if(NULL != head)
+               c->next = head;
+
+       head = c;
+    count++;
+}
+
+// Retourne la tête de liste et la retire de la liste
+Class* DeclaringClasses::removeHead(void)
+{
+       Class* c = NULL;
+
+       if(NULL != head)
+       {
+               c = head;
+               head = head->next;
+               count--;
+       }
+
+       return c;
+}
+
+// Retire la classe pClasse de la liste, mais ne la détruit pas 
+bool DeclaringClasses::remove(Class* c)
+{
+       if(NULL == head)
+               return false;
+
+       bool success = false;
+
+       if(head == c)
+       {
+               head = c->next;
+        count--;
+               success = true;
+       }
+       else
+       {
+               Class* cur = head;
+
+               while((NULL != cur) && (cur->next!= c))
+                       cur = cur->next;
+
+               if(NULL != cur)
+               {
+                       cur->next = c->next;
+            count--;
+                       success = true;
+               }
+       }
+       
+       return success;
+}
+
+bool Object::isInstanceOf(const char* className)
+{
+       Class* c = Class::fromName(className);
+
+       return this->getClass()->isDerivedFrom(c);
+}
+               
+
index d44ff2b..fc89d91 100644 (file)
-/*\r
- * Object.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
-#ifndef MSG_OBJECT_H\r
-#define MSG_OBJECT_H\r
-\r
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
-       #error Object.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <stdlib.h>\r
-\r
-#include <ClassNotFoundException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               //////////////////////////////////////////////////////////////////////////////\r
-               // Macros\r
-               \r
-               // Returns the runtime class of the class_name object.\r
-               #define MSG_GET_CLASS(class_name) \\r
-                                       ((Class*)(&class_name::class##class_name))\r
-                       \r
-               // Declare the class class_name as dynamic\r
-               #define MSG_DECLARE_DYNAMIC(class_name) \\r
-               public: \\r
-                       static Class class##class_name; \\r
-                       virtual Class* getClass() const; \\r
-                       static Object*  createObject() \\r
-\r
-               // The runtime class implementation.    \r
-               #define MSG_IMPLEMENT_CLASS(class_name, base_class_name, pfn,class_init) \\r
-                       Class class_name::class##class_name = { \\r
-                               #class_name, sizeof(class class_name),pfn, \\r
-                                       MSG_GET_CLASS(base_class_name), NULL,class_init}; \\r
-                       Class* class_name::getClass() const \\r
-                                { return MSG_GET_CLASS(class_name); } \\r
-               \r
-               // CreateObject implementation. \r
-               #define MSG_IMPLEMENT_DYNAMIC(class_name, base_class_name) \\r
-                       Object* class_name::createObject() \\r
-                               { return (Object*)(new class_name); } \\r
-                       DeclaringClass _declaringClass_##class_name(MSG_GET_CLASS(class_name)); \\r
-                       MSG_IMPLEMENT_CLASS(class_name, base_class_name, \\r
-                               class_name::createObject, &_declaringClass_##class_name) \\r
-\r
-               //////////////////////////////////////////////////////////////////////////////\r
-               // Classes declared in this file.\r
-\r
-               class Object;   // The msg object.\r
-\r
-               //////////////////////////////////////////////////////////////////////////////\r
-               // Structures declared in this files.\r
-\r
-               struct Class;           // used during the rtti operations\r
-               struct DeclaringClass;  // used during the instances registration.\r
-\r
-\r
-        class DeclaringClasses;\r
-\r
-               //////////////////////////////////////////////////////////////////////////////\r
-               // Global functions\r
-\r
-               // Used during the registration.\r
-               void DeclareClass(Class* c);\r
-\r
-               //////////////////////////////////////////////////////////////////////////////\r
-               // DeclaringClass\r
-\r
-               struct SIMGRIDX_EXPORT DeclaringClass\r
-               {\r
-                       // Constructor : add the runtime classe in the list.\r
-                       DeclaringClass(Class* c);\r
-                       \r
-                       // Destructor\r
-                       virtual ~DeclaringClass(void);\r
-\r
-               // Attributes :\r
-                   // the list of runtime classes.\r
-                   static DeclaringClasses* declaringClasses;\r
-               };\r
-\r
-        #define MSG_DELCARING_CLASSES (*(DeclaringClass::declaringClasses))\r
-               \r
-               \r
-               struct SIMGRIDX_EXPORT Class\r
-               {\r
-               \r
-               // Attributes\r
-       \r
-                       const char* name;                                               // class name.\r
-                       size_t typeSize;                                                // type size.                   \r
-                       Object* (*createObjectFn)(void);                // pointer to the create object function. \r
-                       Class* baseClass;                                               // the runtime class of the runtime class.\r
-                       Class* next;                                                    // the next runtime class in the list.\r
-                       const DeclaringClass* declaringClass;   // used during the registration of the class.\r
-               \r
-               // Operations\r
-               \r
-                       // Create the runtime class from its name.\r
-                       static Class* fromName(const char* name)\r
-                       throw (ClassNotFoundException);\r
-                       \r
-                       // Create an object from the name of the its class.\r
-                       static Object* createObject(const char* name);\r
-                       \r
-                       // Create an instance of the class.\r
-                       Object* createObject(void);\r
-                       \r
-                       // Return true is the class is dervived from the base class baseClass.\r
-                       bool isDerivedFrom(const Class* baseClass) const;\r
-\r
-               };\r
-\r
-        // Create an instance of the class.\r
-        inline Object* Class::createObject(void)\r
-        {\r
-            return (*createObjectFn)();\r
-        }\r
-       \r
-            \r
-               class SIMGRIDX_EXPORT Object\r
-               {\r
-               public:\r
-               \r
-                       // Default constructor.\r
-                       Object(){}\r
-                       \r
-                       // Destructor.\r
-                       virtual ~Object(){}\r
-                       \r
-                       // Operations.\r
-               \r
-                       // Get the runtime class.\r
-                       virtual Class* getClass(void) const;\r
-                       \r
-                       // Returns true if the class is derived from the class baseClass. Otherwise\r
-                       // the method returns false.\r
-                       bool isDerivedFrom(const Class* baseClass) const;\r
-                       \r
-                       // Returns true if the object is valid. Otherwise the method returns false.\r
-                       virtual bool isValid(void) const;\r
-\r
-                       // Returns true is the object is an instance of the class specified as parameter.\r
-                       bool isInstanceOf(const char* className);\r
-                       \r
-                       // Operators.\r
-\r
-                       // Attributes.\r
-                       \r
-                       // The runtime class.\r
-                       static const Class classObject;\r
-               };\r
-\r
-               // inline member functions of the class Object.\r
-               \r
-               // Returns the runtime class of the object.\r
-               inline Class* Object::getClass(void) const\r
-               {\r
-                       return MSG_GET_CLASS(Object);\r
-               }\r
-\r
-        // Returns true if the class is derived from the class pBaseClass. Otherwise\r
-               // the method returns false.\r
-        inline bool Object::isDerivedFrom(const Class* baseClass) const\r
-        {\r
-            return (getClass()->isDerivedFrom(baseClass));\r
-        }\r
-               \r
-               // Returns true if the object is valid. Otherwise the method returns false.\r
-               inline bool Object::isValid(void) const\r
-               {\r
-                       // returns always true.\r
-                       return true;    \r
-               }\r
-\r
-       \r
-               class DeclaringClasses \r
-               {\r
-               public:\r
-               \r
-                       // Constructor.\r
-                       DeclaringClasses();\r
-\r
-                       // Destructor.\r
-                       virtual ~DeclaringClasses(){}\r
-               \r
-               // Operations.\r
-               \r
-                       // Add the class at the head of the list.\r
-                       void addHead(Class* c);\r
-                       \r
-                       // Get the runtime class of the head of the list.\r
-                       Class* getHead(void) const ;\r
-                       \r
-                       // Remove the class from the list (don't destroy it).\r
-                       bool remove(Class* c);\r
-            \r
-            // Remove the head of the list.\r
-                       Class* removeHead(void);\r
-                       \r
-                       // Return true if the list is empty.\r
-                       \r
-                       bool isEmpty(void) const;\r
-                       \r
-                       // Remove of the elements of the list.\r
-                       void removeAll(void);\r
-                       \r
-                       // Get the number of classes in the list.\r
-                   unsigned int getCount(void);\r
-                   \r
-                   void lock(void){}\r
-                   \r
-                   void unlock(void){}\r
-               \r
-                       //Attributes\r
-               \r
-                       // The head of the list.\r
-                       Class* head;\r
-\r
-               private:\r
-               \r
-               // Attributes\r
-               \r
-                       // The number of elements of the list.\r
-                       unsigned int count;\r
-               };\r
-\r
-               typedef Object* ObjectPtr;\r
-\r
-\r
-        // Constructor (Add the class in the list).\r
-        inline DeclaringClass::DeclaringClass(Class* c)\r
-        {\r
-                if(!declaringClasses)\r
-                        declaringClasses = new DeclaringClasses();\r
-\r
-                DeclareClass(c);\r
-        }\r
-\r
-        // Destructor.\r
-        inline DeclaringClass::~DeclaringClass()\r
-        {\r
-                /*if(NULL != declaringClasses)\r
-                        delete declaringClasses;\r
-\r
-                declaringClasses=NULL;*/\r
-\r
-        }\r
-\r
-               // Returns the number of elements of the list.\r
-               inline unsigned int DeclaringClasses::getCount()\r
-               {\r
-                       return count;\r
-               }\r
-               \r
-               // Returns the head of the list.\r
-               inline Class* DeclaringClasses::getHead() const\r
-               {\r
-                       return head;\r
-               }\r
-               \r
-               // Returns true if the list is empty. Otherwise this function\r
-               // returns false.\r
-               inline bool DeclaringClasses::isEmpty() const\r
-               {\r
-                       return(!head);\r
-               }\r
-               \r
-               // Removes all the elements of the list.\r
-               inline void DeclaringClasses::removeAll()\r
-               {\r
-                       head = 0;\r
-                   count=0;\r
-               }\r
-                       \r
-       } // namespace Msg     \r
-} // namespace SimGrid\r
-\r
-\r
-using namespace SimGrid::Msg;\r
-\r
-#define instanceOf(class_name) reinterpret_cast<class_name*>(Class::createObject(#class_name))\r
-\r
-#endif // !MSG_OBJECT_H\r
-\r
+/*
+ * Object.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_OBJECT_H
+#define MSG_OBJECT_H
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+       #error Object.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <stdlib.h>
+
+#include <ClassNotFoundException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               //////////////////////////////////////////////////////////////////////////////
+               // Macros
+               
+               // Returns the runtime class of the class_name object.
+               #define MSG_GET_CLASS(class_name) \
+                                       ((Class*)(&class_name::class##class_name))
+                       
+               // Declare the class class_name as dynamic
+               #define MSG_DECLARE_DYNAMIC(class_name) \
+               public: \
+                       static Class class##class_name; \
+                       virtual Class* getClass() const; \
+                       static Object*  createObject() \
+
+               // The runtime class implementation.    
+               #define MSG_IMPLEMENT_CLASS(class_name, base_class_name, pfn,class_init) \
+                       Class class_name::class##class_name = { \
+                               #class_name, sizeof(class class_name),pfn, \
+                                       MSG_GET_CLASS(base_class_name), NULL,class_init}; \
+                       Class* class_name::getClass() const \
+                                { return MSG_GET_CLASS(class_name); } \
+               
+               // CreateObject implementation. 
+               #define MSG_IMPLEMENT_DYNAMIC(class_name, base_class_name) \
+                       Object* class_name::createObject() \
+                               { return (Object*)(new class_name); } \
+                       DeclaringClass _declaringClass_##class_name(MSG_GET_CLASS(class_name)); \
+                       MSG_IMPLEMENT_CLASS(class_name, base_class_name, \
+                               class_name::createObject, &_declaringClass_##class_name) \
+
+               //////////////////////////////////////////////////////////////////////////////
+               // Classes declared in this file.
+
+               class Object;   // The msg object.
+
+               //////////////////////////////////////////////////////////////////////////////
+               // Structures declared in this files.
+
+               struct Class;           // used during the rtti operations
+               struct DeclaringClass;  // used during the instances registration.
+
+
+        class DeclaringClasses;
+
+               //////////////////////////////////////////////////////////////////////////////
+               // Global functions
+
+               // Used during the registration.
+               void DeclareClass(Class* c);
+
+               //////////////////////////////////////////////////////////////////////////////
+               // DeclaringClass
+
+               struct SIMGRIDX_EXPORT DeclaringClass
+               {
+                       // Constructor : add the runtime classe in the list.
+                       DeclaringClass(Class* c);
+                       
+                       // Destructor
+                       virtual ~DeclaringClass(void);
+
+               // Attributes :
+                   // the list of runtime classes.
+                   static DeclaringClasses* declaringClasses;
+               };
+
+        #define MSG_DELCARING_CLASSES (*(DeclaringClass::declaringClasses))
+               
+               
+               struct SIMGRIDX_EXPORT Class
+               {
+               
+               // Attributes
+       
+                       const char* name;                                               // class name.
+                       size_t typeSize;                                                // type size.                   
+                       Object* (*createObjectFn)(void);                // pointer to the create object function. 
+                       Class* baseClass;                                               // the runtime class of the runtime class.
+                       Class* next;                                                    // the next runtime class in the list.
+                       const DeclaringClass* declaringClass;   // used during the registration of the class.
+               
+               // Operations
+               
+                       // Create the runtime class from its name.
+                       static Class* fromName(const char* name)
+                       throw (ClassNotFoundException);
+                       
+                       // Create an object from the name of the its class.
+                       static Object* createObject(const char* name);
+                       
+                       // Create an instance of the class.
+                       Object* createObject(void);
+                       
+                       // Return true is the class is dervived from the base class baseClass.
+                       bool isDerivedFrom(const Class* baseClass) const;
+
+               };
+
+        // Create an instance of the class.
+        inline Object* Class::createObject(void)
+        {
+            return (*createObjectFn)();
+        }
+       
+            
+               class SIMGRIDX_EXPORT Object
+               {
+               public:
+               
+                       // Default constructor.
+                       Object(){}
+                       
+                       // Destructor.
+                       virtual ~Object(){}
+                       
+                       // Operations.
+               
+                       // Get the runtime class.
+                       virtual Class* getClass(void) const;
+                       
+                       // Returns true if the class is derived from the class baseClass. Otherwise
+                       // the method returns false.
+                       bool isDerivedFrom(const Class* baseClass) const;
+                       
+                       // Returns true if the object is valid. Otherwise the method returns false.
+                       virtual bool isValid(void) const;
+
+                       // Returns true is the object is an instance of the class specified as parameter.
+                       bool isInstanceOf(const char* className);
+                       
+                       // Operators.
+
+                       // Attributes.
+                       
+                       // The runtime class.
+                       static const Class classObject;
+               };
+
+               // inline member functions of the class Object.
+               
+               // Returns the runtime class of the object.
+               inline Class* Object::getClass(void) const
+               {
+                       return MSG_GET_CLASS(Object);
+               }
+
+        // Returns true if the class is derived from the class pBaseClass. Otherwise
+               // the method returns false.
+        inline bool Object::isDerivedFrom(const Class* baseClass) const
+        {
+            return (getClass()->isDerivedFrom(baseClass));
+        }
+               
+               // Returns true if the object is valid. Otherwise the method returns false.
+               inline bool Object::isValid(void) const
+               {
+                       // returns always true.
+                       return true;    
+               }
+
+       
+               class DeclaringClasses 
+               {
+               public:
+               
+                       // Constructor.
+                       DeclaringClasses();
+
+                       // Destructor.
+                       virtual ~DeclaringClasses(){}
+               
+               // Operations.
+               
+                       // Add the class at the head of the list.
+                       void addHead(Class* c);
+                       
+                       // Get the runtime class of the head of the list.
+                       Class* getHead(void) const ;
+                       
+                       // Remove the class from the list (don't destroy it).
+                       bool remove(Class* c);
+            
+            // Remove the head of the list.
+                       Class* removeHead(void);
+                       
+                       // Return true if the list is empty.
+                       
+                       bool isEmpty(void) const;
+                       
+                       // Remove of the elements of the list.
+                       void removeAll(void);
+                       
+                       // Get the number of classes in the list.
+                   unsigned int getCount(void);
+                   
+                   void lock(void){}
+                   
+                   void unlock(void){}
+               
+                       //Attributes
+               
+                       // The head of the list.
+                       Class* head;
+
+               private:
+               
+               // Attributes
+               
+                       // The number of elements of the list.
+                       unsigned int count;
+               };
+
+               typedef Object* ObjectPtr;
+
+
+        // Constructor (Add the class in the list).
+        inline DeclaringClass::DeclaringClass(Class* c)
+        {
+                if(!declaringClasses)
+                        declaringClasses = new DeclaringClasses();
+
+                DeclareClass(c);
+        }
+
+        // Destructor.
+        inline DeclaringClass::~DeclaringClass()
+        {
+                /*if(NULL != declaringClasses)
+                        delete declaringClasses;
+
+                declaringClasses=NULL;*/
+
+        }
+
+               // Returns the number of elements of the list.
+               inline unsigned int DeclaringClasses::getCount()
+               {
+                       return count;
+               }
+               
+               // Returns the head of the list.
+               inline Class* DeclaringClasses::getHead() const
+               {
+                       return head;
+               }
+               
+               // Returns true if the list is empty. Otherwise this function
+               // returns false.
+               inline bool DeclaringClasses::isEmpty() const
+               {
+                       return(!head);
+               }
+               
+               // Removes all the elements of the list.
+               inline void DeclaringClasses::removeAll()
+               {
+                       head = 0;
+                   count=0;
+               }
+                       
+       } // namespace Msg     
+} // namespace SimGrid
+
+
+using namespace SimGrid::Msg;
+
+#define instanceOf(class_name) reinterpret_cast<class_name*>(Class::createObject(#class_name))
+
+#endif // !MSG_OBJECT_H
+
index 3fb9412..fe2570e 100644 (file)
@@ -1,81 +1,81 @@
-/*\r
- * OutOfBoundsException.cxx\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
- /* OutOfBoundsException member functions implementation.\r
-  */  \r
-\r
-#include <OutOfBoundsException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       OutOfBoundsException::OutOfBoundsException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Out of bounds") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Out of bounds");\r
-                       }\r
-               \r
-               \r
-                       OutOfBoundsException::OutOfBoundsException(const OutOfBoundsException& rOutOfBoundsException)\r
-                       {\r
-                               const char* reason = rOutOfBoundsException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-                       OutOfBoundsException::OutOfBoundsException(int pos)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Out of bounds ") + 21 + 1, sizeof(char));\r
-                               sprintf(this->reason, "Out of bounds %d", pos);\r
-                       }\r
-\r
-                       OutOfBoundsException::OutOfBoundsException(int pos1, int pos2)\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Out of bounds ") + (2*21) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Out of bounds %d : %d", pos1, pos2);\r
-                       }\r
-               \r
-               \r
-                       OutOfBoundsException::~OutOfBoundsException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* OutOfBoundsException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const OutOfBoundsException& OutOfBoundsException::operator = (const OutOfBoundsException& rOutOfBoundsException)\r
-                       {\r
-                               const char* reason = rOutOfBoundsException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * OutOfBoundsException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* OutOfBoundsException member functions implementation.
+  */  
+
+#include <OutOfBoundsException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       OutOfBoundsException::OutOfBoundsException()
+                       {
+                               this->reason = (char*) calloc(strlen("Out of bounds") + 1, sizeof(char));
+                               strcpy(this->reason, "Out of bounds");
+                       }
+               
+               
+                       OutOfBoundsException::OutOfBoundsException(const OutOfBoundsException& rOutOfBoundsException)
+                       {
+                               const char* reason = rOutOfBoundsException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+                       OutOfBoundsException::OutOfBoundsException(int pos)
+                       {
+                               this->reason = (char*) calloc(strlen("Out of bounds ") + 21 + 1, sizeof(char));
+                               sprintf(this->reason, "Out of bounds %d", pos);
+                       }
+
+                       OutOfBoundsException::OutOfBoundsException(int pos1, int pos2)
+                       {
+                               this->reason = (char*) calloc(strlen("Out of bounds ") + (2*21) + 1, sizeof(char));
+                               sprintf(this->reason, "Out of bounds %d : %d", pos1, pos2);
+                       }
+               
+               
+                       OutOfBoundsException::~OutOfBoundsException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* OutOfBoundsException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const OutOfBoundsException& OutOfBoundsException::operator = (const OutOfBoundsException& rOutOfBoundsException)
+                       {
+                               const char* reason = rOutOfBoundsException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index 379c768..2b89c7b 100644 (file)
@@ -1,71 +1,71 @@
-/*\r
- * OutOfBoundsException.hpp\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_OUTOFBOUNDSEXCEPTION_HPP\r
-#define MSG_OUTOFBOUNDSEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error OutOfBoundsException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT OutOfBoundsException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               OutOfBoundsException();\r
-                       \r
-                       // Copy constructor.\r
-                               OutOfBoundsException(const OutOfBoundsException& rOutOfBoundsException);\r
-                       \r
-                       // This constructor takes the position in the range.\r
-                               OutOfBoundsException(int pos);\r
-\r
-                               OutOfBoundsException(int pos1, int pos2);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~OutOfBoundsException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Out of bounds : `pos'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const OutOfBoundsException& operator = (const OutOfBoundsException& rOutOfBoundsException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_MSGEXCEPTION_HPP\r
-\r
+/*
+ * OutOfBoundsException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_OUTOFBOUNDSEXCEPTION_HPP
+#define MSG_OUTOFBOUNDSEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error OutOfBoundsException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT OutOfBoundsException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               OutOfBoundsException();
+                       
+                       // Copy constructor.
+                               OutOfBoundsException(const OutOfBoundsException& rOutOfBoundsException);
+                       
+                       // This constructor takes the position in the range.
+                               OutOfBoundsException(int pos);
+
+                               OutOfBoundsException(int pos1, int pos2);
+                       
+                       // Destructor.
+                               virtual ~OutOfBoundsException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Out of bounds : `pos'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const OutOfBoundsException& operator = (const OutOfBoundsException& rOutOfBoundsException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_MSGEXCEPTION_HPP
+
index a43b2ea..d22fe22 100644 (file)
-/*\r
- * Process.cxx\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
- /* Process member functions implementation.\r
-  */  \r
-\r
-#include <Process.hpp>\r
-\r
-\r
-#include <ApplicationHandler.hpp>\r
-#include <Host.hpp>\r
-#include <Task.hpp>\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-#include <msg/msg.h>\r
-#include <msg/private.h>\r
-#include <msg/mailbox.h>\r
-\r
-\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               MSG_IMPLEMENT_DYNAMIC(Process, Object);\r
-\r
-               // Default constructor.\r
-               Process::Process()\r
-               {\r
-                       this->nativeProcess = NULL;\r
-               }\r
-               \r
-               Process::Process(const char* hostName, const char* name)\r
-               throw(NullPointerException, HostNotFoundException, BadAllocException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!name)\r
-                               throw NullPointerException("name");\r
-                               \r
-                       if(!hostName)\r
-                               throw NullPointerException("hostName");\r
-                       \r
-                       Host host = Host::getByName(hostName);\r
-                               \r
-                       create(host, name, 0, NULL);    \r
-               }\r
-               \r
-               Process::Process(const Host& rHost, const char* name)\r
-               throw(NullPointerException)\r
-               {\r
-                       if(!name)\r
-                               throw NullPointerException("name");\r
-                               \r
-                       create(rHost, name, 0, NULL);   \r
-               }\r
-               \r
-               Process::Process(const Host& rHost, const char* name, int argc, char** argv)\r
-               throw(NullPointerException, InvalidArgumentException, LogicException)\r
-               {\r
-                       \r
-                       // check the parameters\r
-                       \r
-                       if(!name)\r
-                               throw NullPointerException("name");\r
-                               \r
-                       if(argc < 0)\r
-                               throw InvalidArgumentException("argc (must be positive)");\r
-                               \r
-                       if(!argc && argv)\r
-                               throw LogicException("argv is not NULL but argc is zero");\r
-                       \r
-                       if(argc && !argv)\r
-                               throw LogicException("argv is NULL but argc is not zero");\r
-                       \r
-                       create(rHost, name, argc, argv);        \r
-               }\r
-               \r
-               Process::Process(const char* hostName, const char* name, int argc, char** argv)\r
-               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!name)\r
-                               throw NullPointerException("name");\r
-                               \r
-                       if(!hostName)\r
-                               throw NullPointerException("hostName");\r
-                               \r
-                       if(argc < 0)\r
-                               throw InvalidArgumentException("argc (must be positive)");\r
-                               \r
-                       if(!argc && argv)\r
-                               throw LogicException("argv is not NULL but argc is zero");\r
-                       \r
-                       if(argc && !argv)\r
-                               throw LogicException("argv is NULL but argc is not zero");\r
-                               \r
-                       Host host = Host::getByName(hostName);\r
-                               \r
-                       create(host, name, argc, argv); \r
-               }\r
-               \r
-               int Process::killAll(int resetPID) \r
-               {\r
-                   return MSG_process_killall(resetPID);\r
-               }\r
-               \r
-               void Process::suspend(void)\r
-               throw(MsgException)\r
-               {\r
-                   if(MSG_OK != MSG_process_suspend(nativeProcess)) \r
-                       throw MsgException("MSG_process_suspend() failed");\r
-               }\r
-               \r
-               void Process::resume(void) \r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_process_resume(nativeProcess))\r
-                               throw MsgException("MSG_process_resume() failed");\r
-               }\r
-               \r
-               int Process::isSuspended(void)\r
-               {\r
-                  return MSG_process_is_suspended(nativeProcess);\r
-               }  \r
-               \r
-               Host& Process::getHost(void) \r
-               {\r
-                 m_host_t nativeHost = MSG_process_get_host(nativeProcess);\r
-                       \r
-                 // return the reference to the Host object\r
-                 return (*((Host*)nativeHost->data));\r
-               }\r
-               \r
-               Process& Process::fromPID(int PID) \r
-               throw(ProcessNotFoundException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(PID < 1)\r
-                               throw InvalidArgumentException("PID (the PID of the process to retrieve is not less than 1)");\r
-                               \r
-                       Process* process = NULL;\r
-                       m_process_t nativeProcess = MSG_process_from_PID(PID);\r
-                       \r
-                       if(!nativeProcess) \r
-                               throw ProcessNotFoundException(PID);\r
-                       \r
-                       process = Process::fromNativeProcess(nativeProcess);\r
-                               \r
-                       if(!process) \r
-                               throw MsgException("Process::fromNativeProcess() failed");\r
-                       \r
-                       return (*process);   \r
-               } \r
-               \r
-               int Process::getPID(void)\r
-               {\r
-                   return MSG_process_get_PID(nativeProcess);\r
-               }\r
-               \r
-               int Process::getPPID(void)\r
-               {\r
-                       return MSG_process_get_PPID(nativeProcess);\r
-               }\r
-               \r
-               const char* Process::getName(void) const\r
-               {\r
-                       return nativeProcess->name;\r
-               }\r
-               \r
-               Process& Process::currentProcess(void)\r
-               throw(MsgException)\r
-               {\r
-                       Process* currentProcess = NULL;\r
-                   m_process_t currentNativeProcess = MSG_process_self();\r
-               \r
-               \r
-                       if(!currentNativeProcess) \r
-                               throw MsgException("MSG_process_self() failed");\r
-                       \r
-                       currentProcess = Process::fromNativeProcess(currentNativeProcess);\r
-                               \r
-                       if(!currentProcess) \r
-                               throw MsgException("Process::fromNativeProcess() failed");\r
-                       \r
-                       return (*currentProcess);  \r
-               }\r
-               \r
-               int Process::currentProcessPID(void)\r
-               {\r
-                        return MSG_process_self_PID();\r
-               }\r
-               \r
-               \r
-               int Process::currentProcessPPID(void)\r
-               {\r
-                       return MSG_process_self_PPID();\r
-               }\r
-               \r
-               void Process::migrate(const Host& rHost)\r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_process_change_host(rHost.nativeHost))\r
-                               throw MsgException("MSG_process_change_host()");\r
-                       \r
-               }\r
-               \r
-               void Process::sleep(double seconds)\r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters.\r
-                       if(seconds <= 0)\r
-                               throw InvalidArgumentException("seconds (must not be less or equals to zero");\r
-                               \r
-                       if(MSG_OK != MSG_process_sleep(seconds))\r
-                               throw MsgException("MSG_process_sleep()");\r
-                       \r
-               }\r
-               \r
-               void Process::putTask(const Host& rHost, int channel, Task* task)\r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, rHost.nativeHost, channel, -1.0))\r
-                               throw MsgException("MSG_task_put_with_timeout()");\r
-               }\r
-               \r
-               void Process::putTask(const Host& rHost, int channel, Task* task, double timeout) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be less than zero an different of -1.0)");\r
-                               \r
-                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, rHost.nativeHost, channel, timeout))\r
-                               throw MsgException("MSG_task_put_with_timeout() failed");\r
-               }\r
-               \r
-               Task* Process::getTask(int channel) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, -1.0, NULL)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Process::getTask(int channel, double timeout) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be less than zero an different of -1.0)");\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, timeout, NULL)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Process::getTask(int channel, const Host& rHost) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Process::getTask(int channel, double timeout, const Host& rHost)\r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be less than zero an different of -1.0)");\r
-                       \r
-                       m_task_t nativeTask = NULL;     \r
-                       \r
-                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               void Process::sendTask(const char* alias, Task* task, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                       \r
-                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias ,timeout))\r
-                               throw MsgException("MSG_task_send_with_timeout()");\r
-                               \r
-               }\r
-               \r
-               void Process::sendTask(const char* alias, Task* task) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias ,-1.0))\r
-                               throw MsgException("MSG_task_send_with_timeout()");\r
-               }\r
-               \r
-               void Process::sendTask(Task* task) \r
-               throw(BadAllocException, MsgException)\r
-               {\r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                               \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,-1.0);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout()");\r
-               }\r
-               \r
-               void Process::sendTask(Task* task, double timeout) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                       \r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                               \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,timeout);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout()");     \r
-               }\r
-               \r
-               Task* Process::receiveTask(const char* alias) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException(alias);\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if (MSG_OK !=  MSG_task_receive_ext(&nativeTask,alias, -1.0, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(void) \r
-               throw(BadAllocException, MsgException)\r
-               {\r
-                       \r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");       \r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK !=  rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");    \r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(const char* alias, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK !=  MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");            \r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(double timeout) \r
-               throw(InvalidArgumentException, BadAllocException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                               \r
-                       \r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, timeout, NULL);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK !=  rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");    \r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(const char* alias, double timeout, const Host& rHost) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK !=  MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(double timeout, const Host& rHost) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");\r
-                       \r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK !=  rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               \r
-               Task* Process::receiveTask(const char* alias, const Host& rHost) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       \r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK !=   MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Process::receiveTask(const Host& rHost) \r
-               throw(BadAllocException, MsgException)\r
-               {\r
-                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK !=  rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-\r
-               void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       char alias[MAX_ALIAS_NAME + 1] = {0};\r
-                       msg_mailbox_t mailbox;\r
-                       \r
-                       \r
-                       // try to retrieve the host where to createt the process from its name\r
-                       m_host_t nativeHost = rHost.nativeHost;\r
-                       \r
-                       if(!nativeHost)\r
-                               throw InvalidArgumentException("rHost"); \r
-                       \r
-                       /* allocate the data of the simulation */\r
-                       this->nativeProcess = xbt_new0(s_m_process_t,1);\r
-                       this->nativeProcess->simdata = xbt_new0(s_simdata_process_t,1);\r
-                       this->nativeProcess->name = _strdup(name);\r
-                       this->nativeProcess->simdata->m_host = nativeHost;\r
-                       this->nativeProcess->simdata->PID = msg_global->PID++;\r
-                       \r
-                       // realloc the list of the argument to add the pointer to this process instance at the end\r
-                       if(argc)\r
-                               argv = (char**)realloc(argv , (argc + 1) * sizeof(char*));\r
-                       else\r
-                               argv = (char**)calloc(1 ,sizeof(char*));\r
-                       \r
-                       // add the pointer to this instance at the end of the list of the arguments of the process\r
-                       // so the static method Process::run() (passed as argument of the MSG function xbt_context_new())\r
-                       // can retrieve the concerned process object by the run\r
-                       // so Process::run() can call the method main() of the good process\r
-                       // for more detail see Process::run() method\r
-                       argv[argc] = (char*)this;\r
-\r
-                       this->nativeProcess->simdata->argc = argc;\r
-                       this->nativeProcess->simdata->argv = argv;\r
-                       \r
-                       this->nativeProcess->simdata->s_process = SIMIX_process_create(\r
-                                                                       this->nativeProcess->name,\r
-                                                                       Process::run, \r
-                                                                       (void*)this->nativeProcess,\r
-                                                                       nativeHost->name, \r
-                                                                       argc,\r
-                                                                       argv, \r
-                                                                       NULL);\r
-                       \r
-                       if (SIMIX_process_self()) \r
-                       {/* someone created me */\r
-                               this->nativeProcess->simdata->PPID = MSG_process_get_PID((m_process_t)SIMIX_process_self()->data);\r
-                       } \r
-                       else \r
-                       {\r
-                               this->nativeProcess->simdata->PPID = -1;\r
-                       }\r
-                       \r
-                       this->nativeProcess->simdata->last_errno = MSG_OK;\r
-                       \r
-                       /* add the process to the list of the processes of the simulation */\r
-                       xbt_fifo_unshift(msg_global->process_list, this->nativeProcess);\r
-                       \r
-                       sprintf(alias,"%s:%s",(this->nativeProcess->simdata->m_host->simdata->smx_host)->name,this->nativeProcess->name);\r
-                       \r
-                       mailbox = MSG_mailbox_new(alias);\r
-                       \r
-                       MSG_mailbox_set_hostname(mailbox, this->nativeProcess->simdata->m_host->simdata->smx_host->name);       \r
-               }\r
-               \r
-               Process* Process::fromNativeProcess(m_process_t nativeProcess)\r
-               {\r
-                       return ((Process*)(nativeProcess->simdata->argv[nativeProcess->simdata->argc]));\r
-               }\r
-               \r
-               int Process::run(int argc, char** argv)\r
-               {\r
-                       \r
-                       // the last argument of the process is the pointer to the process to run\r
-                       // for more detail see Process::create() method\r
-                       return ((Process*)argv[argc])->main(argc, argv);\r
-               }\r
-\r
-               int Process::main(int argc, char** argv)\r
-               {\r
-                       throw LogicException("Process::main() not implemented");\r
-               }\r
-\r
-               /*void* Process::operator new(size_t size)\r
-               {\r
-                       // TODO\r
-               }\r
-\r
-               void Process::operator delete(void* p)\r
-               {\r
-                       // TODO\r
-               }*/\r
-               \r
-       } // namespace Msg\r
-\r
-} // namespace SimGrid\r
-\r
+/*
+ * Process.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Process member functions implementation.
+  */  
+
+#include <Process.hpp>
+
+
+#include <ApplicationHandler.hpp>
+#include <Host.hpp>
+#include <Task.hpp>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <msg/msg.h>
+#include <msg/private.h>
+#include <msg/mailbox.h>
+
+
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               MSG_IMPLEMENT_DYNAMIC(Process, Object)
+
+               // Default constructor.
+               Process::Process()
+               {
+                       this->nativeProcess = NULL;
+               }
+               
+               Process::Process(const char* hostName, const char* name)
+               throw(NullPointerException, HostNotFoundException, BadAllocException)
+               {
+                       // check the parameters
+                       
+                       if(!name)
+                               throw NullPointerException("name");
+                               
+                       if(!hostName)
+                               throw NullPointerException("hostName");
+                       
+                       Host host = Host::getByName(hostName);
+                               
+                       create(host, name, 0, NULL);    
+               }
+               
+               Process::Process(const Host& rHost, const char* name)
+               throw(NullPointerException)
+               {
+                       if(!name)
+                               throw NullPointerException("name");
+                               
+                       create(rHost, name, 0, NULL);   
+               }
+               
+               Process::Process(const Host& rHost, const char* name, int argc, char** argv)
+               throw(NullPointerException, InvalidArgumentException, LogicException)
+               {
+                       
+                       // check the parameters
+                       
+                       if(!name)
+                               throw NullPointerException("name");
+                               
+                       if(argc < 0)
+                               throw InvalidArgumentException("argc (must be positive)");
+                               
+                       if(!argc && argv)
+                               throw LogicException("argv is not NULL but argc is zero");
+                       
+                       if(argc && !argv)
+                               throw LogicException("argv is NULL but argc is not zero");
+                       
+                       create(rHost, name, argc, argv);        
+               }
+               
+               Process::Process(const char* hostName, const char* name, int argc, char** argv)
+               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException)
+               {
+                       // check the parameters
+                       
+                       if(!name)
+                               throw NullPointerException("name");
+                               
+                       if(!hostName)
+                               throw NullPointerException("hostName");
+                               
+                       if(argc < 0)
+                               throw InvalidArgumentException("argc (must be positive)");
+                               
+                       if(!argc && argv)
+                               throw LogicException("argv is not NULL but argc is zero");
+                       
+                       if(argc && !argv)
+                               throw LogicException("argv is NULL but argc is not zero");
+                               
+                       Host host = Host::getByName(hostName);
+                               
+                       create(host, name, argc, argv); 
+               }
+               
+               int Process::killAll(int resetPID) 
+               {
+                   return MSG_process_killall(resetPID);
+               }
+               
+               void Process::suspend(void)
+               throw(MsgException)
+               {
+                   if(MSG_OK != MSG_process_suspend(nativeProcess)) 
+                       throw MsgException("MSG_process_suspend() failed");
+               }
+               
+               void Process::resume(void) 
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_process_resume(nativeProcess))
+                               throw MsgException("MSG_process_resume() failed");
+               }
+               
+               int Process::isSuspended(void)
+               {
+                  return MSG_process_is_suspended(nativeProcess);
+               }  
+               
+               Host& Process::getHost(void) 
+               {
+                 m_host_t nativeHost = MSG_process_get_host(nativeProcess);
+                       
+                 // return the reference to the Host object
+                 return (*((Host*)nativeHost->data));
+               }
+               
+               Process& Process::fromPID(int PID) 
+               throw(ProcessNotFoundException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(PID < 1)
+                               throw InvalidArgumentException("PID (the PID of the process to retrieve is less than 1)");
+                               
+                       Process* process = NULL;
+                       m_process_t nativeProcess = MSG_process_from_PID(PID);
+                       
+                       if(!nativeProcess) 
+                               throw ProcessNotFoundException(PID);
+                       
+                       process = Process::fromNativeProcess(nativeProcess);
+                               
+                       if(!process) 
+                               throw MsgException("Process::fromNativeProcess() failed");
+                       
+                       return (*process);   
+               } 
+               
+               int Process::getPID(void)
+               {
+                   return MSG_process_get_PID(nativeProcess);
+               }
+               
+               int Process::getPPID(void)
+               {
+                       return MSG_process_get_PPID(nativeProcess);
+               }
+               
+               const char* Process::getName(void) const
+               {
+                       return nativeProcess->name;
+               }
+               
+               Process& Process::currentProcess(void)
+               throw(MsgException)
+               {
+                       Process* currentProcess = NULL;
+                   m_process_t currentNativeProcess = MSG_process_self();
+               
+               
+                       if(!currentNativeProcess) 
+                               throw MsgException("MSG_process_self() failed");
+                       
+                       currentProcess = Process::fromNativeProcess(currentNativeProcess);
+                               
+                       if(!currentProcess) 
+                               throw MsgException("Process::fromNativeProcess() failed");
+                       
+                       return (*currentProcess);  
+               }
+               
+               int Process::currentProcessPID(void)
+               {
+                        return MSG_process_self_PID();
+               }
+               
+               
+               int Process::currentProcessPPID(void)
+               {
+                       return MSG_process_self_PPID();
+               }
+               
+               void Process::migrate(const Host& rHost)
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_process_change_host(rHost.nativeHost))
+                               throw MsgException("MSG_process_change_host()");
+                       
+               }
+               
+               void Process::sleep(double seconds)
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters.
+                       if(seconds <= 0)
+                               throw InvalidArgumentException("seconds (must not be less or equals to zero");
+                               
+                       if(MSG_OK != MSG_process_sleep(seconds))
+                               throw MsgException("MSG_process_sleep()");
+                       
+               }
+               
+               void Process::putTask(const Host& rHost, int channel, Task* task)
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, rHost.nativeHost, channel, -1.0))
+                               throw MsgException("MSG_task_put_with_timeout()");
+               }
+               
+               void Process::putTask(const Host& rHost, int channel, Task* task, double timeout) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be less than zero and different of -1.0)");
+                               
+                       if(MSG_OK != MSG_task_put_with_timeout(task->nativeTask, rHost.nativeHost, channel, timeout))
+                               throw MsgException("MSG_task_put_with_timeout() failed");
+               }
+               
+               Task* Process::getTask(int channel) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, -1.0, NULL)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Process::getTask(int channel, double timeout) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be less than zero and different of -1.0)");
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, timeout, NULL)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Process::getTask(int channel, const Host& rHost) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Process::getTask(int channel, double timeout, const Host& rHost)
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be less than zero and different of -1.0)");
+                       
+                       m_task_t nativeTask = NULL;     
+                       
+                       if (MSG_OK != MSG_task_get_ext(&nativeTask, channel, timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               void Process::sendTask(const char* alias, Task* task, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                       
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias ,timeout))
+                               throw MsgException("MSG_task_send_with_timeout()");
+                               
+               }
+               
+               void Process::sendTask(const char* alias, Task* task) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       if(MSG_OK != MSG_task_send_with_timeout(task->nativeTask, alias ,-1.0))
+                               throw MsgException("MSG_task_send_with_timeout()");
+               }
+               
+               void Process::sendTask(Task* task) 
+               throw(BadAllocException, MsgException)
+               {
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                               
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,-1.0);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout()");
+               }
+               
+               void Process::sendTask(Task* task, double timeout) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                       
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                               
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,timeout);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout()");     
+               }
+               
+               Task* Process::receiveTask(const char* alias) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException(alias);
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if (MSG_OK !=  MSG_task_receive_ext(&nativeTask,alias, -1.0, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(void) 
+               throw(BadAllocException, MsgException)
+               {
+                       
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");       
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK !=  rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");    
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(const char* alias, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK !=  MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");            
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(double timeout) 
+               throw(InvalidArgumentException, BadAllocException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                               
+                       
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, timeout, NULL);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK !=  rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");    
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(const char* alias, double timeout, const Host& rHost) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK !=  MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(double timeout, const Host& rHost) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (the timeout value must not be negative and different than -1.0)");
+                       
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK !=  rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               
+               Task* Process::receiveTask(const char* alias, const Host& rHost) 
+               throw(NullPointerException, MsgException)
+               {
+                       
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK !=   MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Process::receiveTask(const Host& rHost) 
+               throw(BadAllocException, MsgException)
+               {
+                       char* alias = (char*)calloc( strlen(this->getHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost);
+                       
+                       free(alias);
+                       
+                       if(MSG_OK !=  rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+
+               void Process::create(const Host& rHost, const char* name, int argc, char** argv)
+               throw(InvalidArgumentException)
+               {
+                       char alias[MAX_ALIAS_NAME + 1] = {0};
+                       msg_mailbox_t mailbox;
+                       
+                       
+                       // try to retrieve the host where to create the process from its name
+                       m_host_t nativeHost = rHost.nativeHost;
+                       
+                       if(!nativeHost)
+                               throw InvalidArgumentException("rHost"); 
+                       
+                       /* allocate the data of the simulation */
+                       this->nativeProcess = xbt_new0(s_m_process_t,1);
+                       this->nativeProcess->simdata = xbt_new0(s_simdata_process_t,1);
+                       this->nativeProcess->name = _strdup(name);
+                       this->nativeProcess->simdata->m_host = nativeHost;
+                       this->nativeProcess->simdata->PID = msg_global->PID++;
+                       
+                       // realloc the list of the arguments to add the pointer to this process instance at the end
+                       if(argc)
+                       {
+                               argv = (char**)realloc(argv , (argc + 2) * sizeof(char*));
+                       }
+                       else
+                       {
+                               argv = (char**)calloc(2 ,sizeof(char*));
+                       }
+                       
+                       // add the pointer to this instance at the end of the list of the arguments of the process
+                       // so the static method Process::run() (passed as argument of the MSG function xbt_context_new())
+                       // can retrieve the concerned process object by the run
+                       // so Process::run() can call the method main() of the good process
+                       // for more detail see Process::run() method
+                       argv[argc] = NULL;
+                       argv[argc + 1] = (char*)this;
+
+                       this->nativeProcess->simdata->argc = argc;
+                       this->nativeProcess->simdata->argv = argv;
+                       
+                       this->nativeProcess->simdata->s_process = SIMIX_process_create(
+                                                                       this->nativeProcess->name,
+                                                                       Process::run, 
+                                                                       (void*)this->nativeProcess,
+                                                                       nativeHost->name, 
+                                                                       argc,
+                                                                       argv, 
+                                                                       NULL);
+                       
+                       if (SIMIX_process_self()) 
+                       {/* someone created me */
+                               this->nativeProcess->simdata->PPID = MSG_process_get_PID((m_process_t)SIMIX_process_self()->data);
+                       } 
+                       else 
+                       {
+                               this->nativeProcess->simdata->PPID = -1;
+                       }
+                       
+                       this->nativeProcess->simdata->last_errno = MSG_OK;
+                       
+                       /* add the process to the list of the processes of the simulation */
+                       xbt_fifo_unshift(msg_global->process_list, this->nativeProcess);
+                       
+                       sprintf(alias,"%s:%s",(this->nativeProcess->simdata->m_host->simdata->smx_host)->name,this->nativeProcess->name);
+                       
+                       mailbox = MSG_mailbox_new(alias);
+                       
+                       MSG_mailbox_set_hostname(mailbox, this->nativeProcess->simdata->m_host->simdata->smx_host->name);       
+               }
+               
+               Process* Process::fromNativeProcess(m_process_t nativeProcess)
+               {
+                       return ((Process*)(nativeProcess->simdata->argv[nativeProcess->simdata->argc + 1]));
+                       
+               }
+               
+               int Process::run(int argc, char** argv)
+               {
+                       
+                       // the last argument of the process is the pointer to the process to run
+                       // for more detail see Process::create() method
+                       return ((Process*)argv[argc + 1])->main(argc, argv);
+                       
+               }
+
+               int Process::main(int argc, char** argv)
+               {
+                       throw LogicException("Process::main() not implemented");
+               }
+
+               /*void* Process::operator new(size_t size)
+               {
+                       // TODO
+               }
+
+               void Process::operator delete(void* p)
+               {
+                       // TODO
+               }*/
+               
+       } // namespace Msg
+
+} // namespace SimGrid
+
index 5bc46e5..4bc5f3e 100644 (file)
-/*\r
- * Process.hpp\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_PROCESS_HPP\r
-#define MSG_PROCESS_HPP\r
-\r
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
-       #error Process.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <msg/datatypes.h>\r
-\r
-#include <ApplicationHandler.hpp>\r
-#include <Object.hpp>\r
-\r
-#include <MsgException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <ProcessNotFoundException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <BadAllocException.hpp>\r
-#include <LogicException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class ApplicationHandler;\r
-               class Host;\r
-               class Task;\r
-\r
-               // SimGrid::Msg::Process class declaration.\r
-               class SIMGRIDX_EXPORT Process : public Object\r
-               {\r
-                       friend class ApplicationHandler::ProcessFactory;\r
-                       \r
-                       MSG_DECLARE_DYNAMIC(Process);\r
-\r
-                       public:\r
-\r
-                               // Disable the default constructor.\r
-                               Process();\r
-                       \r
-                       \r
-                               /*! \brief  Constructs a process from the name of the host and its name.\r
-                                *\r
-                                * \param hostName              The host name of the process to create.\r
-                                * \param name                  The name of the process to create.\r
-                                *\r
-                                * \exception                   If the constructor failed, it throws one of the exceptions described\r
-                                *                                              below:\r
-                                *                                              \r
-                                *                                              [NullPointerException]          if the name of the process is NULL or if the\r
-                                *                                                                                                      name of the host is NULL.\r
-                                *                                              [HostNotFoundException]         if the host is not found.\r
-                                */     \r
-                               Process(const char* hostName, const char* name)\r
-                               throw(NullPointerException, HostNotFoundException, BadAllocException);\r
-                       \r
-                               /*! \brief Constructs a process from a reference to an host object and its name.\r
-                                *\r
-                                * \param rHost                 A reference to the host object representing the native\r
-                                *                                              MSG host where to create the process.\r
-                                * \param name                  The name of the process to create.\r
-                                *\r
-                                * \exception                   If the constructor failed, it throws the exception described\r
-                                *                                              below:\r
-                                *\r
-                                *                                              [NullPointerException]          if the name of process is NULL.\r
-                                */ \r
-                               Process(const Host& rHost, const char* name)\r
-                               throw(NullPointerException);\r
-                               \r
-                               /*! brief Construct a proces from reference to an host object and the name of the process.\r
-                                * This constuctor takes also the list of the arguments of the process.\r
-                                *\r
-                                * \param host                  A reference to the host where to create the process.\r
-                                * \param name                  The name of the process to create.\r
-                                * \param argc                  The number of the arguments of the process to create.\r
-                                * \param argv                  The list of arguments of the process to create.\r
-                                *\r
-                                * \exception                   If the constructor failed, it throws one of the exceptions described\r
-                                *                                              below:\r
-                                *\r
-                                *                                              [NullPointerException]          if the name of the host is NULL or\r
-                                *                                                                                                      if the name of the process is NULL.\r
-                                *                                              [InvalidArgumentException]  if the value of the parameter argv is\r
-                                *                                                                                                      negative.\r
-                                *                                              [LogicException]                        if the parameter argv is NULL and the \r
-                                *                                                                                                      parameter argc is different than zero\r
-                                *                                                                                                      if the parameter argv is not NULL and \r
-                                *                                                                                                      the parameter argc is zero.\r
-                                */\r
-                               Process(const Host& rHost, const char* name, int argc, char** argv)\r
-                               throw(NullPointerException, InvalidArgumentException, LogicException);\r
-                               \r
-                               /*! brief Constructs a proces from the name of a host and the name of the process.\r
-                                * This constuctor takes also the list of the arguments of the process.\r
-                                *\r
-                                * \param hostName              The name of the host where to create the process.\r
-                                * \param name                  The name of the process to create.\r
-                                * \param argc                  The number of the arguments of the process to create.\r
-                                * \param argv                  The list of arguments of the process to create.\r
-                                *\r
-                                * \exception                   If the constructor failed, it throws one of the exceptions described\r
-                                *                                              below:\r
-                                *                                              \r
-                                *                                              [NullPointerException]          if the name of the process or if the name\r
-                                *                                                                                                      of the host is NULL.\r
-                                *                                              [InvalidArgumentException]  if the value of the parameter argv is\r
-                                *                                                                                                      negative.\r
-                                *                                              [LogicException]                        if the parameter argv is NULL and the \r
-                                *                                                                                                      parameter argc is different than zero\r
-                                *                                                                                                      if the parameter argv is not NULL and \r
-                                *                                                                                                      the parameter argc is zero.\r
-                                *                                              [HostNotFoundException]         if the specified host is no found.\r
-                                */\r
-                               Process(const char* hostName, const char* name, int argc, char** argv)\r
-                               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException);\r
-                       \r
-                               /*! \brief Process::killAll() - kill all the running processes of the simulation.\r
-                                *\r
-                                * \param resetPID              Should we reset the PID numbers. A negative number means no reset\r
-                        *                                              and a positive number will be used to set the PID of the next newly\r
-                        *                                              created process.\r
-                        *\r
-                        * \return                              The static method returns the PID of the next created process.\r
-                        */                     \r
-                               static int killAll(int resetPID);\r
-                       \r
-                               /*! \brief Process::suspend() - Suspend an MSG process.\r
-                                * \r
-                                * \excetpion                   If this method failed, it throws one the exception described below:\r
-                                *\r
-                                *                                              [MsgException]  if an internal exception occurs during the operation.\r
-                                */\r
-                               void suspend(void)\r
-                               throw(MsgException);\r
-                               \r
-                               \r
-                       \r
-                               /*! \brief Process::resume() - Resume the MSG process.\r
-                                *\r
-                                * \exception                   If this method failed, it throws the exception described below:\r
-                                *\r
-                                *                                              [MsgException] if an internal exception occurs during the operation.\r
-                                */\r
-                               void resume(void) \r
-                               throw(MsgException);\r
-                       \r
-                               /*! \brief Process::isSuspend() - Tests if a process is suspended.\r
-                                *\r
-                                * \return                              This method returns 1 is the process is suspended.\r
-                                *                                              Otherwise the method returns 0.\r
-                                */\r
-                               int isSuspended(void);\r
-                       \r
-                               /*! \brief Process::getHost() - Retrieves the host of a process object.\r
-                                *\r
-                                * \return                              The method returns a reference to the\r
-                                *                                              host of the process.\r
-                                *\r
-                                */\r
-                               Host& getHost(void); \r
-                       \r
-                               /*! \brief Process::fromPID() - Retrieves a process from its PID.\r
-                                *\r
-                                * \param PID                   The PID of the process to retrieve.\r
-                                *\r
-                                * \return                              If successful the method returns a reference to\r
-                                *                                              to process. Otherwise, the method throws one of\r
-                                *                                              the exceptions described below:\r
-                                *\r
-                                * \exception                   [ProcessNotFoundException]      if the process is not found (no process with this PID).\r
-                                *\r
-                                *                                              [InvalidArgumentException]      if the parameter PID is less than 1.\r
-                                *\r
-                                *                                              [MsgException]                          if a native error occurs during the operation.\r
-                                */\r
-                               static Process& fromPID(int PID)\r
-                               throw(ProcessNotFoundException, InvalidArgumentException, MsgException); \r
-                       \r
-                               /*! \brief Process::getPID() - Gets the PID of a process object.\r
-                                *\r
-                                * \return                              This method returns the PID of a process object.\r
-                                */\r
-                               int getPID(void);\r
-                               \r
-                               /*! \brief Process::getPPID() - Gets the parent PID of a process object.\r
-                                *\r
-                                * \return                              This method returns the parent PID of a process object.\r
-                                */\r
-                               int getPPID(void);\r
-                               \r
-                               /*! \brief Process::getName() - Gets the name of a process object.\r
-                                *\r
-                                * \return                              This method returns the name of a process object.\r
-                                */\r
-                               const char* getName(void) const;\r
-                       \r
-                               /*! \brief Process::currentProcess() - Retrieves the current process.\r
-                                *\r
-                                * \return                              This method returns a reference to the current process. Otherwise\r
-                                *                                              the method throws the excepction described below:\r
-                                *\r
-                                * \exception                   [MsgException]  if an internal exception occurs.\r
-                                */\r
-                               static Process& currentProcess(void)\r
-                               throw (MsgException);\r
-                       \r
-                               /*! \brief Process::currentProcessPID() - Retrieves the PID of the current process.\r
-                                *\r
-                                * \return                              This method returns the PID of the current process.\r
-                                */\r
-                               static int currentProcessPID(void);\r
-                               \r
-                               /*! \brief Process::currentProcessPPID() - Retrieves the parent PID of the current process.\r
-                                *\r
-                                * \return                              This method returns the parent PID of the current process.\r
-                                */\r
-                               static int currentProcessPPID(void);\r
-                       \r
-                               /*! \brief Process::migrate() - Migrate a process object to an another host.\r
-                                *\r
-                                * \param rHost                 A reference to the host to migrate the process to.\r
-                                *\r
-                                * \return                              If successful the method migrate the process to the specified\r
-                                *                                              host. Otherwise the method throws the exception described\r
-                                *                                              below:\r
-                                *\r
-                                * \exception                   [MsgException]  if an internal exception occurs.\r
-                                */\r
-                               void migrate(const Host& rHost)\r
-                               throw(MsgException);\r
-                       \r
-                               /*! \brief Process::sleep() - Makes the current process sleep until time seconds have elapsed. \r
-                                *\r
-                                * \param seconds                       The number of seconds to sleep.\r
-                                *\r
-                                * \execption                           If this method failed, it throws one of the exceptions described\r
-                                *                                                      below: \r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the parameter seconds is\r
-                                *                                                      less or equals to zero.\r
-                                *\r
-                                *                                                      [MsgException] if an internal exception occurs.\r
-                                */\r
-                               static void sleep(double seconds)\r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::putTask() - This method puts a task on a given channel of a given host.\r
-                                *\r
-                                * \exception                   If this method failed, it throws one of the exceptions described\r
-                                *                                              below:\r
-                                *\r
-                                *                                              [InvalidArgumentException] if the channel number is negative.\r
-                                *\r
-                                *                                              [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void putTask(const Host& rHost, int channel, Task* task)\r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::putTask() - This method puts a task on a given channel of a given host (waiting at most given time).\r
-                                *\r
-                                * \exception                   If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                              [MsgException]                          if an internal error occurs.\r
-                                *\r
-                                *                                              [InvalidArgumentException]      if the value of the channel specified as\r
-                                *                                                                                                      parameter is negative or if the timeout value\r
-                                *                                                                                                      is less than zero and différent of -1.\r
-                                *\r
-                                * \remark                              Set the timeout with -1.0 to disable it.\r
-                                */\r
-                               void putTask(const Host& rHost, int channel, Task* task, double timeout) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::getTask() - Retrieves a task from a channel number (waiting at most given time).\r
-                                *\r
-                                * \param channel               The number of the channel where to get the task.\r
-                                *\r
-                                * \return                              If successful the method returns a reference to \r
-                                *                                              the getted task. Otherwise the method throws one\r
-                                *                                              of the exceptions described below:\r
-                                *\r
-                                * \exception                   [InvalidArgumentException]      if the channel number is negative.\r
-                                *\r
-                                *                                              [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* getTask(int channel) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::taskGet() - Retrieves a task from a channel number (waiting at most given time).\r
-                                *\r
-                                * \param channel               The number of the channel where to get the task.\r
-                                * \param timeout               The timeout value.\r
-                                *\r
-                                * \return                              If successful the method returns a reference to \r
-                                *                                              the getted task. Otherwise the method throws one\r
-                                *                                              of the exceptions described below:\r
-                                *\r
-                                * \exception                   [InvalidArgumentException]      if the channel number is negative\r
-                                *                                                                                                      or if the timeout value is less than\r
-                                *                                                                                                      zero and different of -1.0.\r
-                                *                                              [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* getTask(int channel, double timeout) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host.\r
-                                *\r
-                                * \param channel               The number of the channel where to get the task.\r
-                                * \param host                  The host of the channel to get the task.\r
-                                *\r
-                                * \return                              If successful the method returns a reference to \r
-                                *                                              the getted task. Otherwise the method throws one\r
-                                *                                              of the exceptions described below.\r
-                                *\r
-                                * \exception                   [InvalidArgumentException]      if the channel number is negative.\r
-                                *                                              [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* getTask(int channel, const Host& rHost) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host (waiting at most given time).\r
-                                *\r
-                                * \param channel               The number of the channel where to get the task.\r
-                                * \param timeout               The timeout value.\r
-                                * \param rHost                 The host owning the channel.\r
-                                *\r
-                                * \return                              If successful the method returns a reference to \r
-                                *                                              the getted task. Otherwise the method throws one\r
-                                *                                              of the exceptions described below:\r
-                                *\r
-                                * \exception                   [InvalidArgumentException]      if the channel number is negative or\r
-                                *                                                                                                      if the timeout value is negative and different\r
-                                *                                                                                                      of -1.0.\r
-                                *                                              [MsgException]                          if an internal exception occurs.\r
-                                *\r
-                                * \remark                              Set the timeout with -1.0 to disable it.\r
-                                */\r
-                               Task* getTask(int channel, double timeout, const Host& rHost)\r
-                               throw(InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias\r
-                                * (waiting at most given time).\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to send the task.\r
-                                * \param rTask                         A reference to the task object to send.\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias specified as parameter is NULL.\r
-                                *      \r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negative and different than\r
-                                *                                                                                                              -1.0\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                *\r
-                                * \remark                                      Set the timeout with -1.0 to disable it.\r
-                                */\r
-                               void sendTask(const char* alias, Task* task, double timeout) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias.\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to send the task.\r
-                                * \param rTask                         A reference to the task object to send.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                *\r
-                                */\r
-                               void sendTask(const char* alias, Task* task) \r
-                               throw(NullPointerException, MsgException);\r
-                       \r
-                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias.\r
-                                *\r
-                                * \param rTask                         A reference to the task object to send.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *                                                      \r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                *\r
-                                */\r
-                               void sendTask(Task* task) \r
-                               throw(BadAllocException, MsgException);\r
-                       \r
-                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias\r
-                                * (waiting at most given time).\r
-                                *\r
-                                * \param rTask                         A reference to the task object to send.\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negative and different than -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                *\r
-                                * \remark                                      set the timeout value with -1.0 to disable it.\r
-                                */\r
-                               void sendTask(Task* task, double timeout) \r
-                               throw(BadAllocException, InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
-                                * parameter.\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to retrieve the task.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [NullPointerException]  if the parameter alias is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                  if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(const char* alias) \r
-                               throw(NullPointerException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [BadAllocException]             if there is not enough memory to build the alias.                       \r
-                                *                                                      [MsgException]                  if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(void) \r
-                               throw(BadAllocException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
-                                * parameter(waiting at most given time).\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to retrieve the task.\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below.\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.\r
-                                *\r
-                                *                                                      [NullPointerException]          if the parameter alias is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(const char* alias, double timeout) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias\r
-                                * (waiting at most given time).\r
-                                *\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different than -1.0.\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the alias.\r
-                                *                      \r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(double timeout) \r
-                               throw(InvalidArgumentException, BadAllocException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as\r
-                                * parameter located on a given host (waiting at most given time).\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to retrieve the task.\r
-                                * \param timeout                       The timeout value.\r
-                                * \param rHost                         A reference to the host object owning the mailbox.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.\r
-                                *\r
-                                *                                                      [NullPointerException]          if the parameter alias is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(const char* alias, double timeout, const Host& rHost) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias\r
-                                *  and located on a given host (waiting at most given time).\r
-                                *\r
-                                * \param timeout                       The timeout value.\r
-                                * \param rHost                         A reference to the host object owning the mailbox.\r
-                                *\r
-                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                                      throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the timeout value is negative and different than -1.0.\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(double timeout, const Host& rHost) \r
-                               throw(BadAllocException, InvalidArgumentException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias\r
-                                *  specified as parameter and located on a given host.\r
-                                *\r
-                                * \param alias                 The alias using to identify the mailbox from which to get the task.\r
-                                * \param rHost                 A reference to the host object owning the mailbox.\r
-                                *\r
-                                * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                              throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                   [NullPointerException]                  if the parameter alias is NULL.\r
-                                *\r
-                                *                                              [MsgException]                                  if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(const char* alias, const Host& rHost) \r
-                               throw(NullPointerException, MsgException);\r
-                       \r
-                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias\r
-                                *  and located on a given host.\r
-                                *\r
-                                * \param rHost                 A reference to the host object owning the mailbox.\r
-                                *\r
-                                * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method\r
-                                *                                              throws one of the exceptions described below:\r
-                                *\r
-                                * \exception                   [BadAllocException]                             if there is not enough memory to build the alias.\r
-                                *\r
-                                *                                              [MsgException]                                  if an internal exception occurs.\r
-                                */\r
-                               Task* receiveTask(const Host& rHost) \r
-                               throw(BadAllocException, MsgException);\r
-                       \r
-                               \r
-                       private:\r
-                       \r
-                               /* Process::create() - Creates a process on a given host.\r
-                                *\r
-                                * param rHost                  A reference to a host object where to create the process.\r
-                                * param name                   The name of the process to create.\r
-                                * param argc                   The number of argument to pass to the main function of the process.\r
-                                * param argv                   The list of the arguments of the main function of the process.\r
-                                *\r
-                                * exception                    If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                              [HostNotFoundException] if the host specified as parameter doesn't exist.\r
-                                */\r
-                               void create(const Host& rHost, const char* name, int argc, char** argv) \r
-                               throw(InvalidArgumentException);\r
-                               \r
-                               /* Process::fromNativeProcess() - Retrieves the process wrapper associated with a native process.\r
-                                *\r
-                                * \param nativeProcess The native process to get the wrapper.\r
-                                *\r
-                                * \return                              The wrapper associated with the native process specified as parameter.\r
-                                */\r
-                               static Process* fromNativeProcess(m_process_t nativeProcess);\r
-                       \r
-                       \r
-                       public:\r
-                       \r
-                               /* Process::run() - used to set the field code of the context of the process.\r
-                                */ \r
-                               static int run(int argc, char** argv);\r
-                               \r
-                               /*! \brief Process::main() - This virtual pure function is the main function of the process.\r
-                                * You must override this function for each new class of process that you create.\r
-                                *\r
-                                * \param argc                  The number of parameters of the main function.\r
-                                * \param argv                  The list of the parameter of the main function.\r
-                                *\r
-                                * \return                              The exit code of the main function.\r
-                                */\r
-                               virtual int main(int argc, char** argv);\r
-\r
-                       // Operators.\r
-                                       \r
-                               /*\r
-                                       // Override the operator new().\r
-                                       void* operator new(size_t size);\r
-                                       \r
-                                       // Override the operator delete().\r
-                                       void operator delete(void* p);\r
-                                */\r
-                               \r
-                       private:\r
-                               \r
-                               // Attributes.\r
-                               \r
-                               m_process_t nativeProcess;      // pointer to the native msg process.\r
-                       \r
-               };\r
-       \r
-       } //namepace Msg\r
-\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_PROCESS_HPP\r
-\r
+/*
+ * Process.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_PROCESS_HPP
+#define MSG_PROCESS_HPP
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+       #error Process.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <msg/datatypes.h>
+
+#include <ApplicationHandler.hpp>
+#include <Object.hpp>
+
+#include <MsgException.hpp>
+#include <NullPointerException.hpp>
+#include <HostNotFoundException.hpp>
+#include <ProcessNotFoundException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <BadAllocException.hpp>
+#include <LogicException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class ApplicationHandler;
+               class Host;
+               class Task;
+
+               // SimGrid::Msg::Process class declaration.
+               class SIMGRIDX_EXPORT Process : public Object
+               {
+                       friend class ApplicationHandler::ProcessFactory;
+                       
+                       MSG_DECLARE_DYNAMIC(Process);
+
+                       public:
+
+                               // Disable the default constructor.
+                               Process();
+                       
+                       
+                               /*! \brief  Constructs a process from the name of the host and its name.
+                                *
+                                * \param hostName              The host name of the process to create.
+                                * \param name                  The name of the process to create.
+                                *
+                                * \exception                   If the constructor failed, it throws one of the exceptions described
+                                *                                              below:
+                                *                                              
+                                *                                              [NullPointerException]          if the name of the process is NULL or if the
+                                *                                                                                                      name of the host is NULL.
+                                *                                              [HostNotFoundException]         if the host is not found.
+                                */     
+                               Process(const char* hostName, const char* name)
+                               throw(NullPointerException, HostNotFoundException, BadAllocException);
+                       
+                               /*! \brief Constructs a process from a reference to an host object and its name.
+                                *
+                                * \param rHost                 A reference to the host object representing the native
+                                *                                              MSG host where to create the process.
+                                * \param name                  The name of the process to create.
+                                *
+                                * \exception                   If the constructor failed, it throws the exception described
+                                *                                              below:
+                                *
+                                *                                              [NullPointerException]          if the name of process is NULL.
+                                */ 
+                               Process(const Host& rHost, const char* name)
+                               throw(NullPointerException);
+                               
+                               /*! brief Construct a proces from reference to an host object and the name of the process.
+                                * This constuctor takes also the list of the arguments of the process.
+                                *
+                                * \param host                  A reference to the host where to create the process.
+                                * \param name                  The name of the process to create.
+                                * \param argc                  The number of the arguments of the process to create.
+                                * \param argv                  The list of arguments of the process to create.
+                                *
+                                * \exception                   If the constructor failed, it throws one of the exceptions described
+                                *                                              below:
+                                *
+                                *                                              [NullPointerException]          if the name of the host is NULL or
+                                *                                                                                                      if the name of the process is NULL.
+                                *                                              [InvalidArgumentException]  if the value of the parameter argv is
+                                *                                                                                                      negative.
+                                *                                              [LogicException]                        if the parameter argv is NULL and the 
+                                *                                                                                                      parameter argc is different than zero
+                                *                                                                                                      if the parameter argv is not NULL and 
+                                *                                                                                                      the parameter argc is zero.
+                                */
+                               Process(const Host& rHost, const char* name, int argc, char** argv)
+                               throw(NullPointerException, InvalidArgumentException, LogicException);
+                               
+                               /*! brief Constructs a proces from the name of a host and the name of the process.
+                                * This constuctor takes also the list of the arguments of the process.
+                                *
+                                * \param hostName              The name of the host where to create the process.
+                                * \param name                  The name of the process to create.
+                                * \param argc                  The number of the arguments of the process to create.
+                                * \param argv                  The list of arguments of the process to create.
+                                *
+                                * \exception                   If the constructor failed, it throws one of the exceptions described
+                                *                                              below:
+                                *                                              
+                                *                                              [NullPointerException]          if the name of the process or if the name
+                                *                                                                                                      of the host is NULL.
+                                *                                              [InvalidArgumentException]  if the value of the parameter argv is
+                                *                                                                                                      negative.
+                                *                                              [LogicException]                        if the parameter argv is NULL and the 
+                                *                                                                                                      parameter argc is different than zero
+                                *                                                                                                      if the parameter argv is not NULL and 
+                                *                                                                                                      the parameter argc is zero.
+                                *                                              [HostNotFoundException]         if the specified host is no found.
+                                */
+                               Process(const char* hostName, const char* name, int argc, char** argv)
+                               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException);
+                       
+                               /*! \brief Process::killAll() - kill all the running processes of the simulation.
+                                *
+                                * \param resetPID              Should we reset the PID numbers. A negative number means no reset
+                        *                                              and a positive number will be used to set the PID of the next newly
+                        *                                              created process.
+                        *
+                        * \return                              The static method returns the PID of the next created process.
+                        */                     
+                               static int killAll(int resetPID);
+                       
+                               /*! \brief Process::suspend() - Suspend an MSG process.
+                                * 
+                                * \excetpion                   If this method failed, it throws one the exception described below:
+                                *
+                                *                                              [MsgException]  if an internal exception occurs during the operation.
+                                */
+                               void suspend(void)
+                               throw(MsgException);
+                               
+                               
+                       
+                               /*! \brief Process::resume() - Resume the MSG process.
+                                *
+                                * \exception                   If this method failed, it throws the exception described below:
+                                *
+                                *                                              [MsgException] if an internal exception occurs during the operation.
+                                */
+                               void resume(void) 
+                               throw(MsgException);
+                       
+                               /*! \brief Process::isSuspend() - Tests if a process is suspended.
+                                *
+                                * \return                              This method returns 1 is the process is suspended.
+                                *                                              Otherwise the method returns 0.
+                                */
+                               int isSuspended(void);
+                       
+                               /*! \brief Process::getHost() - Retrieves the host of a process object.
+                                *
+                                * \return                              The method returns a reference to the
+                                *                                              host of the process.
+                                *
+                                */
+                               Host& getHost(void); 
+                       
+                               /*! \brief Process::fromPID() - Retrieves a process from its PID.
+                                *
+                                * \param PID                   The PID of the process to retrieve.
+                                *
+                                * \return                              If successful the method returns a reference to
+                                *                                              to process. Otherwise, the method throws one of
+                                *                                              the exceptions described below:
+                                *
+                                * \exception                   [ProcessNotFoundException]      if the process is not found (no process with this PID).
+                                *
+                                *                                              [InvalidArgumentException]      if the parameter PID is less than 1.
+                                *
+                                *                                              [MsgException]                          if a native error occurs during the operation.
+                                */
+                               static Process& fromPID(int PID)
+                               throw(ProcessNotFoundException, InvalidArgumentException, MsgException); 
+                       
+                               /*! \brief Process::getPID() - Gets the PID of a process object.
+                                *
+                                * \return                              This method returns the PID of a process object.
+                                */
+                               int getPID(void);
+                               
+                               /*! \brief Process::getPPID() - Gets the parent PID of a process object.
+                                *
+                                * \return                              This method returns the parent PID of a process object.
+                                */
+                               int getPPID(void);
+                               
+                               /*! \brief Process::getName() - Gets the name of a process object.
+                                *
+                                * \return                              This method returns the name of a process object.
+                                */
+                               const char* getName(void) const;
+                       
+                               /*! \brief Process::currentProcess() - Retrieves the current process.
+                                *
+                                * \return                              This method returns a reference to the current process. Otherwise
+                                *                                              the method throws the excepction described below:
+                                *
+                                * \exception                   [MsgException]  if an internal exception occurs.
+                                */
+                               static Process& currentProcess(void)
+                               throw (MsgException);
+                       
+                               /*! \brief Process::currentProcessPID() - Retrieves the PID of the current process.
+                                *
+                                * \return                              This method returns the PID of the current process.
+                                */
+                               static int currentProcessPID(void);
+                               
+                               /*! \brief Process::currentProcessPPID() - Retrieves the parent PID of the current process.
+                                *
+                                * \return                              This method returns the parent PID of the current process.
+                                */
+                               static int currentProcessPPID(void);
+                       
+                               /*! \brief Process::migrate() - Migrate a process object to an another host.
+                                *
+                                * \param rHost                 A reference to the host to migrate the process to.
+                                *
+                                * \return                              If successful the method migrate the process to the specified
+                                *                                              host. Otherwise the method throws the exception described
+                                *                                              below:
+                                *
+                                * \exception                   [MsgException]  if an internal exception occurs.
+                                */
+                               void migrate(const Host& rHost)
+                               throw(MsgException);
+                       
+                               /*! \brief Process::sleep() - Makes the current process sleep until time seconds have elapsed. 
+                                *
+                                * \param seconds                       The number of seconds to sleep.
+                                *
+                                * \execption                           If this method failed, it throws one of the exceptions described
+                                *                                                      below: 
+                                *
+                                *                                                      [InvalidArgumentException]      if the parameter seconds is
+                                *                                                      less or equals to zero.
+                                *
+                                *                                                      [MsgException] if an internal exception occurs.
+                                */
+                               static void sleep(double seconds)
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::putTask() - This method puts a task on a given channel of a given host.
+                                *
+                                * \exception                   If this method failed, it throws one of the exceptions described
+                                *                                              below:
+                                *
+                                *                                              [InvalidArgumentException] if the channel number is negative.
+                                *
+                                *                                              [MsgException]                          if an internal exception occurs.
+                                */
+                               void putTask(const Host& rHost, int channel, Task* task)
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::putTask() - This method puts a task on a given channel of a given host (waiting at most given time).
+                                *
+                                * \exception                   If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                              [MsgException]                          if an internal error occurs.
+                                *
+                                *                                              [InvalidArgumentException]      if the value of the channel specified as
+                                *                                                                                                      parameter is negative or if the timeout value
+                                *                                                                                                      is less than zero and différent of -1.
+                                *
+                                * \remark                              Set the timeout with -1.0 to disable it.
+                                */
+                               void putTask(const Host& rHost, int channel, Task* task, double timeout) 
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::getTask() - Retrieves a task from a channel number (waiting at most given time).
+                                *
+                                * \param channel               The number of the channel where to get the task.
+                                *
+                                * \return                              If successful the method returns a reference to 
+                                *                                              the getted task. Otherwise the method throws one
+                                *                                              of the exceptions described below:
+                                *
+                                * \exception                   [InvalidArgumentException]      if the channel number is negative.
+                                *
+                                *                                              [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* getTask(int channel) 
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::taskGet() - Retrieves a task from a channel number (waiting at most given time).
+                                *
+                                * \param channel               The number of the channel where to get the task.
+                                * \param timeout               The timeout value.
+                                *
+                                * \return                              If successful the method returns a reference to 
+                                *                                              the getted task. Otherwise the method throws one
+                                *                                              of the exceptions described below:
+                                *
+                                * \exception                   [InvalidArgumentException]      if the channel number is negative
+                                *                                                                                                      or if the timeout value is less than
+                                *                                                                                                      zero and different of -1.0.
+                                *                                              [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* getTask(int channel, double timeout) 
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host.
+                                *
+                                * \param channel               The number of the channel where to get the task.
+                                * \param host                  The host of the channel to get the task.
+                                *
+                                * \return                              If successful the method returns a reference to 
+                                *                                              the getted task. Otherwise the method throws one
+                                *                                              of the exceptions described below.
+                                *
+                                * \exception                   [InvalidArgumentException]      if the channel number is negative.
+                                *                                              [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* getTask(int channel, const Host& rHost) 
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::taskGet() - Retrieves a task from a channel number and a host (waiting at most given time).
+                                *
+                                * \param channel               The number of the channel where to get the task.
+                                * \param timeout               The timeout value.
+                                * \param rHost                 The host owning the channel.
+                                *
+                                * \return                              If successful the method returns a reference to 
+                                *                                              the getted task. Otherwise the method throws one
+                                *                                              of the exceptions described below:
+                                *
+                                * \exception                   [InvalidArgumentException]      if the channel number is negative or
+                                *                                                                                                      if the timeout value is negative and different
+                                *                                                                                                      of -1.0.
+                                *                                              [MsgException]                          if an internal exception occurs.
+                                *
+                                * \remark                              Set the timeout with -1.0 to disable it.
+                                */
+                               Task* getTask(int channel, double timeout, const Host& rHost)
+                               throw(InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias
+                                * (waiting at most given time).
+                                *
+                                * \param alias                         The alias of the mailbox where to send the task.
+                                * \param rTask                         A reference to the task object to send.
+                                * \param timeout                       The timeout value.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias specified as parameter is NULL.
+                                *      
+                                *                                                      [InvalidArgumentException]      if the timeout value is negative and different than
+                                *                                                                                                              -1.0
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                *
+                                * \remark                                      Set the timeout with -1.0 to disable it.
+                                */
+                               void sendTask(const char* alias, Task* task, double timeout) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias.
+                                *
+                                * \param alias                         The alias of the mailbox where to send the task.
+                                * \param rTask                         A reference to the task object to send.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                *
+                                */
+                               void sendTask(const char* alias, Task* task) 
+                               throw(NullPointerException, MsgException);
+                       
+                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias.
+                                *
+                                * \param rTask                         A reference to the task object to send.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *                                                      
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                *
+                                */
+                               void sendTask(Task* task) 
+                               throw(BadAllocException, MsgException);
+                       
+                               /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the default alias
+                                * (waiting at most given time).
+                                *
+                                * \param rTask                         A reference to the task object to send.
+                                * \param timeout                       The timeout value.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [InvalidArgumentException]      if the timeout value is negative and different than -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                *
+                                * \remark                                      set the timeout value with -1.0 to disable it.
+                                */
+                               void sendTask(Task* task, double timeout) 
+                               throw(BadAllocException, InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as
+                                * parameter.
+                                *
+                                * \param alias                         The alias of the mailbox where to retrieve the task.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below:
+                                *
+                                * \exception                           [NullPointerException]  if the parameter alias is NULL.
+                                *
+                                *                                                      [MsgException]                  if an internal exception occurs.
+                                */
+                               Task* receiveTask(const char* alias) 
+                               throw(NullPointerException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below:
+                                *
+                                * \exception                           [BadAllocException]             if there is not enough memory to build the alias.                       
+                                *                                                      [MsgException]                  if an internal exception occurs.
+                                */
+                               Task* receiveTask(void) 
+                               throw(BadAllocException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as
+                                * parameter(waiting at most given time).
+                                *
+                                * \param alias                         The alias of the mailbox where to retrieve the task.
+                                * \param timeout                       The timeout value.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below.
+                                *
+                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.
+                                *
+                                *                                                      [NullPointerException]          if the parameter alias is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* receiveTask(const char* alias, double timeout) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the default alias
+                                * (waiting at most given time).
+                                *
+                                * \param timeout                       The timeout value.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different than -1.0.
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the alias.
+                                *                      
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* receiveTask(double timeout) 
+                               throw(InvalidArgumentException, BadAllocException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias specified as
+                                * parameter located on a given host (waiting at most given time).
+                                *
+                                * \param alias                         The alias of the mailbox where to retrieve the task.
+                                * \param timeout                       The timeout value.
+                                * \param rHost                         A reference to the host object owning the mailbox.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the timeout value is negative or different of -1.0.
+                                *
+                                *                                                      [NullPointerException]          if the parameter alias is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* receiveTask(const char* alias, double timeout, const Host& rHost) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias
+                                *  and located on a given host (waiting at most given time).
+                                *
+                                * \param timeout                       The timeout value.
+                                * \param rHost                         A reference to the host object owning the mailbox.
+                                *
+                                * \return                                      If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                                      throws one of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the timeout value is negative and different than -1.0.
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               Task* receiveTask(double timeout, const Host& rHost) 
+                               throw(BadAllocException, InvalidArgumentException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by the alias
+                                *  specified as parameter and located on a given host.
+                                *
+                                * \param alias                 The alias using to identify the mailbox from which to get the task.
+                                * \param rHost                 A reference to the host object owning the mailbox.
+                                *
+                                * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                              throws one of the exceptions described below:
+                                *
+                                * \exception                   [NullPointerException]                  if the parameter alias is NULL.
+                                *
+                                *                                              [MsgException]                                  if an internal exception occurs.
+                                */
+                               Task* receiveTask(const char* alias, const Host& rHost) 
+                               throw(NullPointerException, MsgException);
+                       
+                               /*! \brief Process::receiveTask() - Retrieves a task from the mailbox identified by default alias
+                                *  and located on a given host.
+                                *
+                                * \param rHost                 A reference to the host object owning the mailbox.
+                                *
+                                * \return                              If succcessful, the method returns a task of the mailbox. Otherwise, the method
+                                *                                              throws one of the exceptions described below:
+                                *
+                                * \exception                   [BadAllocException]                             if there is not enough memory to build the alias.
+                                *
+                                *                                              [MsgException]                                  if an internal exception occurs.
+                                */
+                               Task* receiveTask(const Host& rHost) 
+                               throw(BadAllocException, MsgException);
+                       
+                               
+                       private:
+                       
+                               /* Process::create() - Creates a process on a given host.
+                                *
+                                * param rHost                  A reference to a host object where to create the process.
+                                * param name                   The name of the process to create.
+                                * param argc                   The number of argument to pass to the main function of the process.
+                                * param argv                   The list of the arguments of the main function of the process.
+                                *
+                                * exception                    If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                              [HostNotFoundException] if the host specified as parameter doesn't exist.
+                                */
+                               void create(const Host& rHost, const char* name, int argc, char** argv) 
+                               throw(InvalidArgumentException);
+                               
+                               /* Process::fromNativeProcess() - Retrieves the process wrapper associated with a native process.
+                                *
+                                * \param nativeProcess The native process to get the wrapper.
+                                *
+                                * \return                              The wrapper associated with the native process specified as parameter.
+                                */
+                               static Process* fromNativeProcess(m_process_t nativeProcess);
+                       
+                       
+                       public:
+                       
+                               /* Process::run() - used to set the field code of the context of the process.
+                                */ 
+                               static int run(int argc, char** argv);
+                               
+                               /*! \brief Process::main() - This virtual pure function is the main function of the process.
+                                * You must override this function for each new class of process that you create.
+                                *
+                                * \param argc                  The number of parameters of the main function.
+                                * \param argv                  The list of the parameter of the main function.
+                                *
+                                * \return                              The exit code of the main function.
+                                */
+                               virtual int main(int argc, char** argv);
+
+                       // Operators.
+                                       
+                               /*
+                                       // Override the operator new().
+                                       void* operator new(size_t size);
+                                       
+                                       // Override the operator delete().
+                                       void operator delete(void* p);
+                                */
+                               
+                       private:
+                               
+                               // Attributes.
+                               
+                               m_process_t nativeProcess;      // pointer to the native msg process.
+                       
+               };
+       
+       } //namepace Msg
+
+} // namespace SimGrid
+
+#endif // !MSG_PROCESS_HPP
+
index 2da654a..1215b2a 100644 (file)
@@ -1,77 +1,81 @@
-/*\r
- * ProcessNotFoundException.cxx\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
- /* ProcessNotFoundException member functions implementation.\r
-  */  \r
-\r
-#include <ProcessNotFoundException.hpp>\r
-\r
-#include <string.h>\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-                       ProcessNotFoundException::ProcessNotFoundException()\r
-                       {\r
-                               this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
-                               strcpy(this->reason, "Host not found : unknown");\r
-                       }\r
-               \r
-               \r
-                       ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)\r
-                       {\r
-                               const char* reason = rProcessNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               strcpy(this->reason, reason);\r
-                               \r
-                       }\r
-               \r
-               \r
-                       ProcessNotFoundException::ProcessNotFoundException(int PID)\r
-                       {\r
-                               char buff[7] = {0};\r
-                               _itoa(PID, buff, 10);\r
-                               this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));\r
-                               sprintf(this->reason, "Host not found : %s", buff);\r
-                       }\r
-               \r
-               \r
-                       ProcessNotFoundException::~ProcessNotFoundException()\r
-                       {\r
-                               if(this->reason)\r
-                                       free(this->reason);\r
-                       }\r
-                               \r
-                       const char* ProcessNotFoundException::toString(void) const\r
-                       {\r
-                               return (const char*)(this->reason);     \r
-                       }\r
-               \r
-               \r
-                       const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)\r
-                       {\r
-                               const char* reason = rProcessNotFoundException.toString();\r
-                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
-                               \r
-                               return *this;\r
-                       }\r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * ProcessNotFoundException.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* ProcessNotFoundException member functions implementation.
+  */  
+
+#include <ProcessNotFoundException.hpp>
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+                       ProcessNotFoundException::ProcessNotFoundException()
+                       {
+                               this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));
+                               strcpy(this->reason, "Host not found : unknown");
+                       }
+               
+               
+                       ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)
+                       {
+                               const char* reason = rProcessNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               strcpy(this->reason, reason);
+                               
+                       }
+               
+               
+                       ProcessNotFoundException::ProcessNotFoundException(int PID)
+                       {
+                               char buff[7] = {0};
+                               #ifdef WIN32
+                               _itoa(PID, buff, 10);
+                               #else
+                               sprintf(buff,"%d",PID);
+                               #endif
+                               this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));
+                               sprintf(this->reason, "Host not found : %s", buff);
+                       }
+               
+               
+                       ProcessNotFoundException::~ProcessNotFoundException()
+                       {
+                               if(this->reason)
+                                       free(this->reason);
+                       }
+                               
+                       const char* ProcessNotFoundException::toString(void) const
+                       {
+                               return (const char*)(this->reason);     
+                       }
+               
+               
+                       const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)
+                       {
+                               const char* reason = rProcessNotFoundException.toString();
+                               this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));
+                               
+                               return *this;
+                       }
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+
index 9e29e00..bdf5675 100644 (file)
@@ -1,68 +1,68 @@
-/*\r
- * ProcessNotFoundException.hpp\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_PROCESSNOTFOUNDEXCEPTION_HPP\r
-#define MSG_PROCESSNOTFOUNDEXCEPTION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error ProcessNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <Exception.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               \r
-               class SIMGRIDX_EXPORT ProcessNotFoundException : public Exception\r
-               {\r
-                       public:\r
-                       \r
-                       // Default constructor.\r
-                               ProcessNotFoundException();\r
-                       \r
-                       // Copy constructor.\r
-                               ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException);\r
-                       \r
-                       // This constructor takes PID of the process.\r
-                               ProcessNotFoundException(int PID);\r
-                       \r
-                       // Destructor.\r
-                               virtual ~ProcessNotFoundException();\r
-                               \r
-                       // Operations.\r
-                                       \r
-                                       // Returns the reason of the exception :\r
-                                       // the message "Process not found `PID'"\r
-                                       const char* toString(void) const;\r
-                       \r
-                       // Operators.\r
-                               \r
-                               // Assignement.\r
-                               const ProcessNotFoundException& operator = (const ProcessNotFoundException& rProcessNotFoundException);\r
-                               \r
-                       private :\r
-                       \r
-                       // Attributes.\r
-                               \r
-                               // A buffer used to build the message returned by the methode toString().\r
-                               char* reason;\r
-               };\r
-               \r
-               \r
-       } // namespace Msg      \r
-\r
-}// namespace SimGrid\r
-\r
-\r
-#endif // !MSG_PROCESSNOTFOUNDEXCEPTION_HPP\r
+/*
+ * ProcessNotFoundException.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_PROCESSNOTFOUNDEXCEPTION_HPP
+#define MSG_PROCESSNOTFOUNDEXCEPTION_HPP
+
+#ifndef __cplusplus
+       #error ProcessNotFoundException.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <Exception.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               
+               class SIMGRIDX_EXPORT ProcessNotFoundException : public Exception
+               {
+                       public:
+                       
+                       // Default constructor.
+                               ProcessNotFoundException();
+                       
+                       // Copy constructor.
+                               ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException);
+                       
+                       // This constructor takes PID of the process.
+                               ProcessNotFoundException(int PID);
+                       
+                       // Destructor.
+                               virtual ~ProcessNotFoundException();
+                               
+                       // Operations.
+                                       
+                                       // Returns the reason of the exception :
+                                       // the message "Process not found `PID'"
+                                       const char* toString(void) const;
+                       
+                       // Operators.
+                               
+                               // Assignement.
+                               const ProcessNotFoundException& operator = (const ProcessNotFoundException& rProcessNotFoundException);
+                               
+                       private :
+                       
+                       // Attributes.
+                               
+                               // A buffer used to build the message returned by the methode toString().
+                               char* reason;
+               };
+               
+               
+       } // namespace Msg      
+
+}// namespace SimGrid
+
+
+#endif // !MSG_PROCESSNOTFOUNDEXCEPTION_HPP
index 0697760..713baed 100644 (file)
-/*\r
- * Simulation.cxx\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
- /* Simulation member functions implementation.\r
-  */  \r
-  \r
-\r
-#include <Application.hpp>\r
-#include <Environment.hpp>\r
-\r
-#include <Msg.hpp>\r
-\r
-#include <Simulation.hpp>\r
-\r
-\r
-#include <msg/msg.h> \r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               int Simulation::execute(int argc, char** argv)\r
-               {\r
-                       if(argc < 3) \r
-                       {\r
-                     info("Usage: Msg platform_file deployment_file");\r
-                     return 1;\r
-                   }\r
-                   \r
-                        // initialize the MSG simulator. Must be done before anything else (even logging).\r
-               init(argc, argv);\r
-                       \r
-                       // the environment to load\r
-                       Environment env;\r
-                       \r
-                       // the application to deploy\r
-                       Application app;\r
-\r
-                       \r
-                       // try to load the environment described by the xml file (argv[1])\r
-                       try\r
-                       {\r
-                               env.load(argv[1]);\r
-                       }\r
-                       catch(FileNotFoundException e)\r
-                       {\r
-                               info(e.toString());\r
-                               finalize();\r
-                               return 1;\r
-                       }\r
-                               \r
-                       // try to deploy the application described by the xml file deployment (argv[2])\r
-                       try\r
-                       {\r
-                               app.deploy(argv[2]);\r
-                       }\r
-                       catch(FileNotFoundException e)\r
-                       {\r
-                               info(e.toString());\r
-                               finalize();\r
-                               return 1;\r
-                       }\r
-                       \r
-                       //try to run the simulation the given application on the given environment\r
-                       try\r
-                       {\r
-                               run();\r
-                       }\r
-                       catch(MsgException e)\r
-                       {\r
-                               info(e.toString());\r
-                               finalize();\r
-                               return 1;\r
-                       }\r
-                       \r
-                       // finalize the MSG simulator\r
-                       try\r
-                       {\r
-                               finalize();\r
-                       }\r
-                       catch(MsgException e)\r
-                       {\r
-                               info(e.toString());\r
-                               return 1;\r
-                       }\r
-                       \r
-                       return 0;\r
-               }\r
-               \r
-               void Simulation::run(void)\r
-               throw (MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_main())\r
-                               throw MsgException("MSG_main() failed");\r
-               }\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-\r
+/*
+ * Simulation.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Simulation member functions implementation.
+  */  
+  
+
+#include <Application.hpp>
+#include <Environment.hpp>
+
+#include <Msg.hpp>
+
+#include <Simulation.hpp>
+
+
+#include <msg/msg.h> 
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               int Simulation::execute(int argc, char** argv)
+               {
+                       if(argc < 3) 
+                       {
+                     info("Usage: Msg platform_file deployment_file");
+                     return 1;
+                   }
+                   
+                        // initialize the MSG simulator. Must be done before anything else (even logging).
+               init(argc, argv);
+                       
+                       // the environment to load
+                       Environment env;
+                       
+                       // the application to deploy
+                       Application app;
+
+                       
+                       // try to load the environment described by the xml file (argv[1])
+                       try
+                       {
+                               env.load(argv[1]);
+                       }
+                       catch(FileNotFoundException e)
+                       {
+                               info(e.toString());
+                               finalize();
+                               return 1;
+                       }
+                               
+                       // try to deploy the application described by the xml file deployment (argv[2])
+                       try
+                       {
+                               app.deploy(argv[2]);
+                       }
+                       catch(FileNotFoundException e)
+                       {
+                               info(e.toString());
+                               finalize();
+                               return 1;
+                       }
+                       
+                       //try to run the simulation the given application on the given environment
+                       try
+                       {
+                               run();
+                       }
+                       catch(MsgException e)
+                       {
+                               info(e.toString());
+                               finalize();
+                               return 1;
+                       }
+                       
+                       // finalize the MSG simulator
+                       try
+                       {
+                               finalize();
+                       }
+                       catch(MsgException e)
+                       {
+                               info(e.toString());
+                               return 1;
+                       }
+                       
+                       return 0;
+               }
+               
+               void Simulation::run(void)
+               throw (MsgException)
+               {
+                       if(MSG_OK != MSG_main())
+                               throw MsgException("MSG_main() failed");
+               }
+       } // namespace Msg
+} // namespace SimGrid
+
+
index 631cc30..c2eeefb 100644 (file)
@@ -1,61 +1,61 @@
-/*\r
- * Simulation.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_SIMULATION_HPP\r
-#define MSG_SIMULATION_HPP\r
-\r
-#ifndef __cplusplus\r
-       #error Sumulation.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <MsgException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class MsgException;\r
-               class FileNotFoundException;\r
-\r
-               // Simulation class declaration.\r
-               class SIMGRIDX_EXPORT Simulation\r
-               {\r
-                       public :\r
-                       \r
-                               Simulation(){};\r
-                               \r
-                               Simulation(const Simulation& rSimulation);\r
-                               \r
-                               virtual ~Simulation(){};\r
-                               \r
-                       // Operations.\r
-                       \r
-                               int execute(int argc, char** argv);\r
-                               \r
-                       private:\r
-                               \r
-                               void run(void)\r
-                               throw (MsgException);\r
-                               \r
-                               \r
-                       // Operators.\r
-                               const Simulation& operator = (const Simulation& rSimulation);\r
-               };\r
-               \r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-#endif // !MSG_SIMULATION_HPP\r
-\r
+/*
+ * Simulation.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_SIMULATION_HPP
+#define MSG_SIMULATION_HPP
+
+#ifndef __cplusplus
+       #error Sumulation.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <MsgException.hpp>
+#include <FileNotFoundException.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class MsgException;
+               class FileNotFoundException;
+
+               // Simulation class declaration.
+               class SIMGRIDX_EXPORT Simulation
+               {
+                       public :
+                       
+                               Simulation(){};
+                               
+                               Simulation(const Simulation& rSimulation);
+                               
+                               virtual ~Simulation(){};
+                               
+                       // Operations.
+                       
+                               int execute(int argc, char** argv);
+                               
+                       private:
+                               
+                               void run(void)
+                               throw (MsgException);
+                               
+                               
+                       // Operators.
+                               const Simulation& operator = (const Simulation& rSimulation);
+               };
+               
+       } // namespace Msg
+} // namespace SimGrid
+
+#endif // !MSG_SIMULATION_HPP
+
index c64c6c1..f8b8952 100644 (file)
-#include <StringHelper.hpp>\r
-\r
-#include <BadAllocException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <OutOfBoundsException.hpp>\r
-\r
-#ifndef BUFF_MAX\r
-#define BUFF_MAX ((size_t)260)\r
-#endif // BUFF_MAX\r
-\r
-\r
-// namespace SimGrid::Msg\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               #define DEFAULT_STRING_HELPER_CAPACITY ((int)128)\r
-               \r
-\r
-               void StringHelper::init(void)\r
-               {\r
-                       capacity = DEFAULT_STRING_HELPER_CAPACITY;\r
-\r
-                       if(!(content = (char*) calloc(capacity + 1, sizeof(char))))\r
-                               throw BadAllocException();\r
-\r
-                       len = 0;\r
-               }\r
-                               \r
-       // Default constructor\r
-               StringHelper::StringHelper()\r
-               {\r
-                       init();\r
-               }\r
-\r
-               StringHelper::StringHelper(char c)\r
-               {\r
-                       init();\r
-                       append(c);\r
-\r
-               }\r
-               \r
-               StringHelper::StringHelper(char c, int n)\r
-               {\r
-                       init();\r
-                       append(c, n);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const char* cstr)\r
-               {\r
-                       init();\r
-                       append(cstr);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const char* cstr, int n)\r
-               {\r
-                       init();\r
-                       append(cstr, n);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const char* cstr, int pos, int n)\r
-               {\r
-                       init();\r
-                       append(cstr, pos, n);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const string& rstr)\r
-               {\r
-                       init();\r
-                       append(rstr);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const string& rstr, int n)\r
-               {\r
-                       init();\r
-                       append(rstr, n);\r
-               }\r
-               \r
-               StringHelper::StringHelper(const string& rstr, int pos, int n)\r
-               {\r
-                       init();\r
-                       append(rstr, pos, n);\r
-               }\r
-               \r
-               StringHelper::StringHelper(short si)\r
-               {\r
-                       init();\r
-                       append(si);\r
-               }\r
-               \r
-               StringHelper::StringHelper(int i)\r
-               {\r
-                       init();\r
-                       append(i);\r
-               }\r
-               \r
-               StringHelper::StringHelper(long l)\r
-               {\r
-                       init();\r
-                       append(l);\r
-               }\r
-               \r
-               StringHelper::StringHelper(float f)\r
-               {\r
-                       init();\r
-                       append(f);\r
-               }\r
-               \r
-               StringHelper::StringHelper(double d)\r
-               {\r
-                       init();\r
-                       append(d);\r
-               }\r
-\r
-               StringHelper::StringHelper(double d, const char* format)\r
-               {\r
-                       char toAppend[BUFF_MAX + 1] = {0};\r
-                       \r
-                       sprintf(toAppend,format,d);\r
-\r
-                       init();\r
-\r
-                       append(toAppend);\r
-               }\r
-               \r
-               StringHelper::StringHelper(unsigned short usi)\r
-               {\r
-                       init();\r
-                       append(usi);\r
-               }\r
-               \r
-               StringHelper::StringHelper(unsigned int ui)\r
-               {\r
-                       init();\r
-                       append(ui);\r
-               }\r
-               \r
-               StringHelper::StringHelper(unsigned long ul)\r
-               {\r
-                       init();\r
-                       append(ul);\r
-               }\r
-       \r
-       // Copy constructor\r
-               StringHelper::StringHelper(const StringHelper& rStringHelper)\r
-               {\r
-                       if(this != &rStringHelper && rStringHelper.size())\r
-                       {\r
-                               clear();\r
-                               append(rStringHelper.cstr());\r
-                       }\r
-               }\r
-\r
-       // Destructor\r
-               StringHelper::~StringHelper()\r
-               {\r
-                       if(content)\r
-                               free(content);\r
-               }\r
-\r
-       // Operations\r
-\r
-               void StringHelper::clear(void)\r
-               {\r
-                       if(len)\r
-                               memset(content, 0, len);\r
-\r
-                       len = 0;\r
-               }\r
-\r
-               bool StringHelper::empty(void)\r
-               {\r
-                       return len == 0;\r
-               }\r
-       \r
-               StringHelper& StringHelper::append(unsigned char c)\r
-               {\r
-                       if(capacity < len + 1)\r
-                       {\r
-                               int new_capacity = (capacity << 1) ;\r
-\r
-                               if(!(content = (char*) realloc(content, new_capacity)))\r
-                                       throw BadAllocException();\r
-\r
-                               capacity = new_capacity;\r
-                       }\r
-                       \r
-\r
-                       content[len] = c;\r
-                       len++;\r
-\r
-                       content[len] = '\0';\r
-\r
-                       return *this;\r
-               }\r
-\r
-               StringHelper& StringHelper::append(unsigned char c, int n)\r
-               {\r
-                       if(n <=0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       char* toAppend = (char*) calloc(n + 1, sizeof(char));\r
-\r
-                       if(!toAppend)\r
-                               throw BadAllocException();\r
-\r
-                       memset(toAppend, c, n); \r
-\r
-                       append(toAppend);\r
-\r
-                       free(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-\r
-       \r
-               StringHelper& StringHelper::append(char c)\r
-               {\r
-                       if(capacity < len + 1)\r
-                       {\r
-                               int new_capacity = (capacity << 1) ;\r
-\r
-                               if(!(content = (char*) realloc(content, new_capacity)))\r
-                                       throw BadAllocException();\r
-\r
-                               capacity = new_capacity;\r
-                       }\r
-                       \r
-\r
-                       content[len] = c;\r
-                       len++;\r
-\r
-                       content[len] = '\0';\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(char c, int n)\r
-               {\r
-                       if(n <=0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       char* toAppend = (char*) calloc(n + 1, sizeof(char));\r
-\r
-                       if(!toAppend)\r
-                               throw BadAllocException();\r
-\r
-                       memset(toAppend, c, n); \r
-\r
-                       append(toAppend);\r
-\r
-                       free(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const char* cstr)\r
-               {\r
-                       if(!cstr)\r
-                               throw NullPointerException("cstr");\r
-                       \r
-                       int l =  (int) strlen(cstr);\r
-\r
-                       if(capacity < len + l)\r
-                       {\r
-                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;\r
-\r
-                               if(!(content = (char*) realloc(content, new_capacity)))\r
-                                       throw BadAllocException();\r
-\r
-                               strcat(content, cstr);\r
-\r
-                               capacity = new_capacity;\r
-                       }\r
-                       else\r
-                       {\r
-                               strcat(content, cstr);\r
-                       }\r
-\r
-                       len += l;\r
-                       content[len] = '\0';\r
-\r
-                       return *this;\r
-                       \r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const char* cstr, int n)\r
-               {\r
-                       if(!cstr)\r
-                               throw NullPointerException("cstr");\r
-\r
-                       if(n <= 0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       \r
-                       int l =  ((int) strlen(cstr)) * n;\r
-\r
-                       if(capacity < len + l)\r
-                       {\r
-                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;\r
-\r
-                               if(!(content = (char*) realloc(content, new_capacity)))\r
-                                       throw BadAllocException();\r
-                               \r
-                               for(int i = 0; i < n; i++)\r
-                                       strcat(content, cstr);\r
-\r
-                               capacity = new_capacity;\r
-                       }\r
-                       else\r
-                       {\r
-                               for(int i = 0; i < n; i++)\r
-                                       strcat(content, cstr);\r
-                       }\r
-\r
-                       len += l;\r
-                       content[len] = '\0';\r
-\r
-                       return *this;\r
-\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const char* cstr, int pos, int n)\r
-               {\r
-                       if(!cstr)\r
-                               throw NullPointerException("cstr");\r
-\r
-                       if(n <= 0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       if(pos < 0 || pos >= (int)strlen(cstr) )\r
-                               throw OutOfBoundsException(pos);\r
-\r
-                       if(pos + n >= (int)strlen(cstr))\r
-                               throw OutOfBoundsException(pos, n);\r
-\r
-\r
-                       char* toAppend = (char*) calloc(n + 1, sizeof(char));\r
-                       \r
-                       strncpy(toAppend, cstr + pos, n);\r
-\r
-                       append(toAppend);\r
-\r
-                       free(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const string& rstr)\r
-               {\r
-                       append(rstr.c_str());\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const string& rstr, int n)\r
-               {\r
-                       if(rstr.empty())\r
-                               throw NullPointerException("rstr");\r
-\r
-                       if(n <= 0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       \r
-                       int l =  ((int) rstr.size()) * n;\r
-\r
-                       if(capacity < len + l)\r
-                       {\r
-                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;\r
-\r
-                               if(!(content = (char*) realloc(content, new_capacity)))\r
-                                       throw BadAllocException();\r
-                               \r
-                               for(int i = 0; i < n; i++)\r
-                                       strcat(content, rstr.c_str());\r
-\r
-                               capacity = new_capacity;\r
-                       }\r
-                       else\r
-                       {\r
-                               for(int i = 0; i < n; i++)\r
-                                       strcat(content, rstr.c_str());\r
-                       }\r
-\r
-                       len += l;\r
-                       content[len] = '\0';\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(const string& rstr, int pos, int n)\r
-               {\r
-                       if(rstr.empty())\r
-                               throw InvalidArgumentException("rstr");\r
-\r
-                       if(n <= 0)\r
-                               throw InvalidArgumentException("n");\r
-\r
-                       if(pos < 0 || pos >= (int) rstr.size() )\r
-                               throw OutOfBoundsException(pos);\r
-\r
-                       if(pos + n >=  (int) rstr.size())\r
-                               throw OutOfBoundsException(pos, n);\r
-\r
-\r
-                       char* toAppend = (char*) calloc(n + 1, sizeof(char));\r
-                       \r
-                       strncpy(toAppend, rstr.c_str() + pos, n);\r
-\r
-                       append(toAppend);\r
-\r
-                       free(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(short si)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%hd",si);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(int i)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%d",i);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(long l)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%ld",l);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(float f)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%f",f);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(double d)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%lf",d);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-\r
-               StringHelper& StringHelper::append(double d, const char* format)\r
-               {\r
-                       char toAppend[BUFF_MAX + 1] = {0};\r
-\r
-                       sprintf(toAppend, format, d);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(unsigned short usi)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%hu",usi);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(unsigned int ui)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%u",ui);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::append(unsigned long ul)\r
-               {\r
-                       char toAppend[26] = {0};\r
-\r
-                       sprintf(toAppend, "%lu",ul);\r
-\r
-                       append(toAppend);\r
-\r
-                       return *this;\r
-               }\r
-                       \r
-               const char& StringHelper::at(int pos) const\r
-               {\r
-                       if(pos < 0 || pos >= len)\r
-                               throw OutOfBoundsException(pos);\r
-                       \r
-                       return content[pos];\r
-               }\r
-               \r
-               char& StringHelper::at(int pos)\r
-               {\r
-                       if(pos < 0 || pos >= len)\r
-                               throw OutOfBoundsException(pos);\r
-                       \r
-                       return content[pos];\r
-               }\r
-               \r
-               const char* StringHelper::cstr(void) const\r
-               {\r
-                       return (const char*)content;\r
-               }\r
-               \r
-               string& StringHelper::toString(void)\r
-               {\r
-                       string* s = new string();\r
-                       s->append(content);\r
-                       return *s;\r
-               }\r
-               \r
-               int StringHelper::size(void) const\r
-               {\r
-                       return len;\r
-               }\r
-               \r
-       //  Operators\r
-               \r
-               // Assignement\r
-               StringHelper& StringHelper::operator = (const StringHelper& rStringHelper)\r
-               {\r
-\r
-                       if(this !=&rStringHelper && rStringHelper.size())\r
-                       {\r
-                               clear();\r
-                               append(rStringHelper.cstr());\r
-                       }\r
-\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (const char* cstr)\r
-               {\r
-                       clear();\r
-                       append(cstr);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (const string& str)\r
-               {\r
-                       clear();\r
-                       append(str);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (short n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (int n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (long n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (float n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (double n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (unsigned short n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (unsigned int n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator = (unsigned long n)\r
-               {\r
-                       clear();\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               char& StringHelper::operator[](int pos)\r
-               {\r
-                       if(pos < 0 || pos >= len)\r
-                               throw OutOfBoundsException(pos);\r
-                       \r
-                       return content[pos];    \r
-               }\r
-               \r
-               char StringHelper::operator[](int pos) const\r
-               {\r
-                       if(pos < 0 || pos >= len)\r
-                               throw OutOfBoundsException(pos);\r
-                       \r
-                       return content[pos];\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (short n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (int n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (long n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (float n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (double n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (unsigned short n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (unsigned int n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (unsigned long n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (const StringHelper& rStringHelper)\r
-               {\r
-                       append(rStringHelper.content);\r
-                       return *this;\r
-               }\r
-\r
-               StringHelper& StringHelper::operator += (const string& rstr)\r
-               {\r
-                       append(rstr.c_str());\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (const char* cstr)\r
-               {\r
-                       append(cstr);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator += (char c)\r
-               {\r
-                       append(c);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (short n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (int n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (long n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (float n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (double n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (unsigned short n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (unsigned int n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (unsigned long n)\r
-               {\r
-                       append(n);\r
-                       return *this;\r
-               }\r
-               \r
-               \r
-               StringHelper& StringHelper::operator + (const StringHelper& rStringHelper)\r
-               {\r
-                       append(rStringHelper.content);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (const string& rstr)\r
-               {\r
-                       append(rstr.c_str());\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (const char* cstr)\r
-               {\r
-                       append(cstr);\r
-                       return *this;\r
-               }\r
-               \r
-               StringHelper& StringHelper::operator + (char c)\r
-               {\r
-                       append(c);\r
-                       return *this;\r
-               }\r
-\r
-               StringHelper::operator char *()\r
-               {\r
-                       return content;\r
-               }\r
-\r
-               StringHelper::operator const char *()\r
-               {\r
-                       return content;\r
-               }\r
-\r
-               ostream& operator<<(ostream& stream, const StringHelper& s)\r
-               {\r
-                       stream << s.cstr();\r
-                       return stream;\r
-               }\r
-\r
-               istream& operator<<(istream& stream, StringHelper& s)\r
-               {\r
-                       char buff[256] = {0};\r
-\r
-                       stream >> buff;\r
-\r
-                       s.append(buff);\r
-\r
-                       return stream;\r
-               }\r
-                               \r
-       } // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+#include <StringHelper.hpp>
+
+#include <BadAllocException.hpp>
+#include <NullPointerException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <OutOfBoundsException.hpp>
+
+#ifndef BUFF_MAX
+#define BUFF_MAX ((size_t)260)
+#endif // BUFF_MAX
+
+
+// namespace SimGrid::Msg
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               #define DEFAULT_STRING_HELPER_CAPACITY ((int)128)
+               
+
+               void StringHelper::init(void)
+               {
+                       capacity = DEFAULT_STRING_HELPER_CAPACITY;
+
+                       if(!(content = (char*) calloc(capacity + 1, sizeof(char))))
+                               throw BadAllocException();
+
+                       len = 0;
+               }
+                               
+       // Default constructor
+               StringHelper::StringHelper()
+               {
+                       init();
+               }
+
+               StringHelper::StringHelper(char c)
+               {
+                       init();
+                       append(c);
+
+               }
+               
+               StringHelper::StringHelper(char c, int n)
+               {
+                       init();
+                       append(c, n);
+               }
+               
+               StringHelper::StringHelper(const char* cstr)
+               {
+                       init();
+                       append(cstr);
+               }
+               
+               StringHelper::StringHelper(const char* cstr, int n)
+               {
+                       init();
+                       append(cstr, n);
+               }
+               
+               StringHelper::StringHelper(const char* cstr, int pos, int n)
+               {
+                       init();
+                       append(cstr, pos, n);
+               }
+               
+               StringHelper::StringHelper(const string& rstr)
+               {
+                       init();
+                       append(rstr);
+               }
+               
+               StringHelper::StringHelper(const string& rstr, int n)
+               {
+                       init();
+                       append(rstr, n);
+               }
+               
+               StringHelper::StringHelper(const string& rstr, int pos, int n)
+               {
+                       init();
+                       append(rstr, pos, n);
+               }
+               
+               StringHelper::StringHelper(short si)
+               {
+                       init();
+                       append(si);
+               }
+               
+               StringHelper::StringHelper(int i)
+               {
+                       init();
+                       append(i);
+               }
+               
+               StringHelper::StringHelper(long l)
+               {
+                       init();
+                       append(l);
+               }
+               
+               StringHelper::StringHelper(float f)
+               {
+                       init();
+                       append(f);
+               }
+               
+               StringHelper::StringHelper(double d)
+               {
+                       init();
+                       append(d);
+               }
+
+               StringHelper::StringHelper(double d, const char* format)
+               {
+                       char toAppend[BUFF_MAX + 1] = {0};
+                       
+                       sprintf(toAppend,format,d);
+
+                       init();
+
+                       append(toAppend);
+               }
+               
+               StringHelper::StringHelper(unsigned short usi)
+               {
+                       init();
+                       append(usi);
+               }
+               
+               StringHelper::StringHelper(unsigned int ui)
+               {
+                       init();
+                       append(ui);
+               }
+               
+               StringHelper::StringHelper(unsigned long ul)
+               {
+                       init();
+                       append(ul);
+               }
+       
+       // Copy constructor
+               StringHelper::StringHelper(const StringHelper& rStringHelper)
+               {
+                       if(this != &rStringHelper && rStringHelper.size())
+                       {
+                               clear();
+                               append(rStringHelper.cstr());
+                       }
+               }
+
+       // Destructor
+               StringHelper::~StringHelper()
+               {
+                       if(content)
+                               free(content);
+               }
+
+       // Operations
+
+               void StringHelper::clear(void)
+               {
+                       if(len)
+                               memset(content, 0, len);
+
+                       len = 0;
+               }
+
+               bool StringHelper::empty(void)
+               {
+                       return len == 0;
+               }
+       
+               StringHelper& StringHelper::append(unsigned char c)
+               {
+                       if(capacity < len + 1)
+                       {
+                               int new_capacity = (capacity << 1) ;
+
+                               if(!(content = (char*) realloc(content, new_capacity)))
+                                       throw BadAllocException();
+
+                               capacity = new_capacity;
+                       }
+                       
+
+                       content[len] = c;
+                       len++;
+
+                       content[len] = '\0';
+
+                       return *this;
+               }
+
+               StringHelper& StringHelper::append(unsigned char c, int n)
+               {
+                       if(n <=0)
+                               throw InvalidArgumentException("n");
+
+                       char* toAppend = (char*) calloc(n + 1, sizeof(char));
+
+                       if(!toAppend)
+                               throw BadAllocException();
+
+                       memset(toAppend, c, n); 
+
+                       append(toAppend);
+
+                       free(toAppend);
+
+                       return *this;
+               }
+
+       
+               StringHelper& StringHelper::append(char c)
+               {
+                       if(capacity < len + 1)
+                       {
+                               int new_capacity = (capacity << 1) ;
+
+                               if(!(content = (char*) realloc(content, new_capacity)))
+                                       throw BadAllocException();
+
+                               capacity = new_capacity;
+                       }
+                       
+
+                       content[len] = c;
+                       len++;
+
+                       content[len] = '\0';
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(char c, int n)
+               {
+                       if(n <=0)
+                               throw InvalidArgumentException("n");
+
+                       char* toAppend = (char*) calloc(n + 1, sizeof(char));
+
+                       if(!toAppend)
+                               throw BadAllocException();
+
+                       memset(toAppend, c, n); 
+
+                       append(toAppend);
+
+                       free(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(const char* cstr)
+               {
+                       if(!cstr)
+                               throw NullPointerException("cstr");
+                       
+                       int l =  (int) strlen(cstr);
+
+                       if(capacity < len + l)
+                       {
+                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;
+
+                               if(!(content = (char*) realloc(content, new_capacity)))
+                                       throw BadAllocException();
+
+                               strcat(content, cstr);
+
+                               capacity = new_capacity;
+                       }
+                       else
+                       {
+                               strcat(content, cstr);
+                       }
+
+                       len += l;
+                       content[len] = '\0';
+
+                       return *this;
+                       
+               }
+               
+               StringHelper& StringHelper::append(const char* cstr, int n)
+               {
+                       if(!cstr)
+                               throw NullPointerException("cstr");
+
+                       if(n <= 0)
+                               throw InvalidArgumentException("n");
+
+                       
+                       int l =  ((int) strlen(cstr)) * n;
+
+                       if(capacity < len + l)
+                       {
+                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;
+
+                               if(!(content = (char*) realloc(content, new_capacity)))
+                                       throw BadAllocException();
+                               
+                               for(int i = 0; i < n; i++)
+                                       strcat(content, cstr);
+
+                               capacity = new_capacity;
+                       }
+                       else
+                       {
+                               for(int i = 0; i < n; i++)
+                                       strcat(content, cstr);
+                       }
+
+                       len += l;
+                       content[len] = '\0';
+
+                       return *this;
+
+               }
+               
+               StringHelper& StringHelper::append(const char* cstr, int pos, int n)
+               {
+                       if(!cstr)
+                               throw NullPointerException("cstr");
+
+                       if(n <= 0)
+                               throw InvalidArgumentException("n");
+
+                       if(pos < 0 || pos >= (int)strlen(cstr) )
+                               throw OutOfBoundsException(pos);
+
+                       if(pos + n >= (int)strlen(cstr))
+                               throw OutOfBoundsException(pos, n);
+
+
+                       char* toAppend = (char*) calloc(n + 1, sizeof(char));
+                       
+                       strncpy(toAppend, cstr + pos, n);
+
+                       append(toAppend);
+
+                       free(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(const string& rstr)
+               {
+                       append(rstr.c_str());
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(const string& rstr, int n)
+               {
+                       if(rstr.empty())
+                               throw NullPointerException("rstr");
+
+                       if(n <= 0)
+                               throw InvalidArgumentException("n");
+
+                       
+                       int l =  ((int) rstr.size()) * n;
+
+                       if(capacity < len + l)
+                       {
+                               int new_capacity = (capacity << 1) < (len + l) ? (len + l) << 1 : capacity << 1;
+
+                               if(!(content = (char*) realloc(content, new_capacity)))
+                                       throw BadAllocException();
+                               
+                               for(int i = 0; i < n; i++)
+                                       strcat(content, rstr.c_str());
+
+                               capacity = new_capacity;
+                       }
+                       else
+                       {
+                               for(int i = 0; i < n; i++)
+                                       strcat(content, rstr.c_str());
+                       }
+
+                       len += l;
+                       content[len] = '\0';
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(const string& rstr, int pos, int n)
+               {
+                       if(rstr.empty())
+                               throw InvalidArgumentException("rstr");
+
+                       if(n <= 0)
+                               throw InvalidArgumentException("n");
+
+                       if(pos < 0 || pos >= (int) rstr.size() )
+                               throw OutOfBoundsException(pos);
+
+                       if(pos + n >=  (int) rstr.size())
+                               throw OutOfBoundsException(pos, n);
+
+
+                       char* toAppend = (char*) calloc(n + 1, sizeof(char));
+                       
+                       strncpy(toAppend, rstr.c_str() + pos, n);
+
+                       append(toAppend);
+
+                       free(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(short si)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%hd",si);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(int i)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%d",i);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(long l)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%ld",l);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(float f)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%f",f);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(double d)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%e",d);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+
+               StringHelper& StringHelper::append(double d, const char* format)
+               {
+                       char toAppend[BUFF_MAX + 1] = {0};
+
+                       sprintf(toAppend, format, d);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(unsigned short usi)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%hu",usi);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(unsigned int ui)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%u",ui);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::append(unsigned long ul)
+               {
+                       char toAppend[26] = {0};
+
+                       sprintf(toAppend, "%lu",ul);
+
+                       append(toAppend);
+
+                       return *this;
+               }
+                       
+               const char& StringHelper::at(int pos) const
+               {
+                       if(pos < 0 || pos >= len)
+                               throw OutOfBoundsException(pos);
+                       
+                       return content[pos];
+               }
+               
+               char& StringHelper::at(int pos)
+               {
+                       if(pos < 0 || pos >= len)
+                               throw OutOfBoundsException(pos);
+                       
+                       return content[pos];
+               }
+               
+               const char* StringHelper::cstr(void) const
+               {
+                       return (const char*)content;
+               }
+               
+               string& StringHelper::toString(void)
+               {
+                       string* s = new string();
+                       s->append(content);
+                       return *s;
+               }
+               
+               int StringHelper::size(void) const
+               {
+                       return len;
+               }
+               
+       //  Operators
+               
+               // Assignement
+               StringHelper& StringHelper::operator = (const StringHelper& rStringHelper)
+               {
+
+                       if(this !=&rStringHelper && rStringHelper.size())
+                       {
+                               clear();
+                               append(rStringHelper.cstr());
+                       }
+
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (const char* cstr)
+               {
+                       clear();
+                       append(cstr);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (const string& str)
+               {
+                       clear();
+                       append(str);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (short n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (int n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (long n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (float n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (double n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (unsigned short n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (unsigned int n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator = (unsigned long n)
+               {
+                       clear();
+                       append(n);
+                       return *this;
+               }
+               
+               char& StringHelper::operator[](int pos)
+               {
+                       if(pos < 0 || pos >= len)
+                               throw OutOfBoundsException(pos);
+                       
+                       return content[pos];    
+               }
+               
+               char StringHelper::operator[](int pos) const
+               {
+                       if(pos < 0 || pos >= len)
+                               throw OutOfBoundsException(pos);
+                       
+                       return content[pos];
+               }
+               
+               StringHelper& StringHelper::operator += (short n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (int n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (long n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (float n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (double n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (unsigned short n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (unsigned int n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (unsigned long n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (const StringHelper& rStringHelper)
+               {
+                       append(rStringHelper.content);
+                       return *this;
+               }
+
+               StringHelper& StringHelper::operator += (const string& rstr)
+               {
+                       append(rstr.c_str());
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (const char* cstr)
+               {
+                       append(cstr);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator += (char c)
+               {
+                       append(c);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (short n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (int n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (long n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (float n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (double n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (unsigned short n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (unsigned int n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (unsigned long n)
+               {
+                       append(n);
+                       return *this;
+               }
+               
+               
+               StringHelper& StringHelper::operator + (const StringHelper& rStringHelper)
+               {
+                       append(rStringHelper.content);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (const string& rstr)
+               {
+                       append(rstr.c_str());
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (const char* cstr)
+               {
+                       append(cstr);
+                       return *this;
+               }
+               
+               StringHelper& StringHelper::operator + (char c)
+               {
+                       append(c);
+                       return *this;
+               }
+
+               StringHelper::operator char *()
+               {
+                       return content;
+               }
+
+               StringHelper::operator const char *()
+               {
+                       return content;
+               }
+
+               ostream& operator<<(ostream& stream, const StringHelper& s)
+               {
+                       stream << s.cstr();
+                       return stream;
+               }
+
+               istream& operator<<(istream& stream, StringHelper& s)
+               {
+                       char buff[256] = {0};
+
+                       stream >> buff;
+
+                       s.append(buff);
+
+                       return stream;
+               }
+                               
+       } // namespace Msg
+} // namespace SimGrid
+
index a1675d3..ebf3a8b 100644 (file)
-/*\r
- * StringHelper.hpp\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 STRING_HELPER_HPP\r
-#define STRING_HELPER_HPP\r
-\r
- #ifndef __cplusplus\r
-       #error StringHelper.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <string>\r
-using std::string;\r
-\r
-#include<iostream>\r
-using std::ostream;\r
-using std::istream;\r
-\r
-#include <Config.hpp>\r
-\r
-// namespace SimGrid::Msg\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class SIMGRIDX_EXPORT StringHelper\r
-               {\r
-                       public:\r
-                               \r
-                               // Default constructor\r
-                                       StringHelper();\r
-\r
-                                       StringHelper(unsigned char c);\r
-                               \r
-                                       StringHelper(unsigned char c, int n);\r
-                               \r
-                                       StringHelper(char c);\r
-                               \r
-                                       StringHelper(char c, int n);\r
-                               \r
-                                       StringHelper(const char* cstr);\r
-                                       \r
-                                       StringHelper(const char* cstr, int n);\r
-                                       \r
-                                       StringHelper(const char* cstr, int pos, int n);\r
-                                       \r
-                                       StringHelper(const string& rstr);\r
-                                       \r
-                                       StringHelper(const string& rstr, int n);\r
-                                       \r
-                                       StringHelper(const string& rstr, int pos, int n);\r
-                                       \r
-                                       StringHelper(short si);\r
-                                       \r
-                                       StringHelper(int i);\r
-                                       \r
-                                       StringHelper(long l);\r
-                                       \r
-                                       StringHelper(float f);\r
-                                       \r
-                                       StringHelper(double d);\r
-\r
-                                       StringHelper(double d, const char* format);\r
-                                       \r
-                                       StringHelper(unsigned short usi);\r
-                                       \r
-                                       StringHelper(unsigned int ui);\r
-                                       \r
-                                       StringHelper(unsigned long ul);\r
-                               \r
-                               // Copy constructor\r
-                                       StringHelper(const StringHelper& rStringHelper);\r
-                               \r
-                               // Destructor\r
-                                       ~StringHelper();\r
-\r
-                               // Operations\r
-                               \r
-                                       StringHelper& append(unsigned char c);\r
-                               \r
-                                       StringHelper& append(unsigned char c, int n);\r
-                               \r
-                                       StringHelper& append(char c);\r
-                               \r
-                                       StringHelper& append(char c, int n);\r
-                               \r
-                                       StringHelper& append(const char* cstr);\r
-                                       \r
-                                       StringHelper& append(const char* cstr, int n);\r
-                                       \r
-                                       StringHelper& append(const char* cstr, int pos, int n);\r
-                                       \r
-                                       StringHelper& append(const string& rstr);\r
-                                       \r
-                                       StringHelper& append(const string& rstr, int n);\r
-                                       \r
-                                       StringHelper& append(const string& rstr, int pos, int n);\r
-                                       \r
-                                       StringHelper& append(short si);\r
-                                       \r
-                                       StringHelper& append(int i);\r
-                                       \r
-                                       StringHelper& append(long l);\r
-                                       \r
-                                       StringHelper& append(float f);\r
-                                       \r
-                                       StringHelper& append(double d);\r
-                                       \r
-                                       StringHelper& append(double d, const char* format);\r
-                                       \r
-                                       StringHelper& append(unsigned short usi);\r
-                                       \r
-                                       StringHelper& append(unsigned int ui);\r
-                                       \r
-                                       StringHelper& append(unsigned long ul);\r
-                                       \r
-                               const char& at(int pos) const;\r
-                               \r
-                               char& at(int pos);\r
-                                       \r
-                                       const char* cstr(void) const;\r
-                                       \r
-                                       string& toString(void);\r
-                                       \r
-                                       int size(void) const;\r
-\r
-                                       void clear(void);\r
-\r
-                                       bool empty(void);\r
-                                       \r
-                               //  Operators\r
-                                       \r
-                                       // Assignement\r
-                                       StringHelper& operator = (const StringHelper& rStringHelper);\r
-                                       \r
-                                       StringHelper& operator = (const char* cstr);\r
-                                       \r
-                                       StringHelper& operator = (const string& str);\r
-                                       \r
-                                       StringHelper& operator = (short n);\r
-                                       \r
-                                       StringHelper& operator = (int n);\r
-                                       \r
-                                       StringHelper& operator = (long n);\r
-                                       \r
-                                       StringHelper& operator = (float n);\r
-                                       \r
-                                       StringHelper& operator = (double n);\r
-                                       \r
-                                       StringHelper& operator = (unsigned short n);\r
-                                       \r
-                                       StringHelper& operator = (unsigned int n);\r
-                                       \r
-                                       StringHelper& operator = (unsigned long n);\r
-                                       \r
-                                       char& operator[](int pos);\r
-                                       \r
-                                       char operator[](int pos) const;\r
-                                       \r
-                                       StringHelper& operator += (short n);\r
-                                       \r
-                                       StringHelper& operator += (int n);\r
-                                       \r
-                                       StringHelper& operator += (long n);\r
-                                       \r
-                                       StringHelper& operator += (float n);\r
-                                       \r
-                                       StringHelper& operator += (double n);\r
-                                       \r
-                                       StringHelper& operator += (unsigned short n);\r
-                                       \r
-                                       StringHelper& operator += (unsigned int n);\r
-                                       \r
-                                       StringHelper& operator += (unsigned long n);\r
-                                       \r
-                                       StringHelper& operator += (const StringHelper& rStringHelper);\r
-                                       \r
-                                       StringHelper& operator += (const string& rstr);\r
-                                       \r
-                               StringHelper& operator += (const char* cstr);\r
-                               \r
-                               StringHelper& operator += (char c);\r
-                               \r
-                                       StringHelper& operator + (short n);\r
-                                       \r
-                                       StringHelper& operator + (int n);\r
-                                       \r
-                                       StringHelper& operator + (long n);\r
-                                       \r
-                                       StringHelper& operator + (float n);\r
-                                       \r
-                                       StringHelper& operator + (double n);\r
-                                       \r
-                                       StringHelper& operator + (unsigned short n);\r
-                                       \r
-                                       StringHelper& operator + (unsigned int n);\r
-                                       \r
-                                       StringHelper& operator + (unsigned long n);\r
-                                       \r
-                                       StringHelper& operator + (const StringHelper& rStringHelper);\r
-                                       \r
-                                       StringHelper& operator + (const string& rstr);\r
-                                       \r
-                               StringHelper& operator + (const char* cstr);\r
-                               \r
-                               StringHelper& operator + (char c);\r
-\r
-                                       operator char *();\r
-\r
-                                       operator const char *();\r
-\r
-                                       friend SIMGRIDX_EXPORT ostream& operator<<(ostream& stream, const StringHelper& s);\r
-\r
-                                       friend SIMGRIDX_EXPORT istream& operator<<(istream& stream, StringHelper& s);\r
-                               \r
-                               private:\r
-\r
-                                       // Methods\r
-                                       void init(void);\r
-                                       \r
-                                       // Attributes\r
-                                       \r
-                                       char* content;\r
-                                       int capacity;\r
-                                       int len;\r
-               };\r
-               \r
-               typedef class StringHelper* StringHelperPtr;\r
-\r
-               #define TEXT_(___x)     StringHelper((___x))\r
-\r
-\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-\r
-#endif // !STRING_HELPER_HPP
\ No newline at end of file
+/*
+ * StringHelper.hpp
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef STRING_HELPER_HPP
+#define STRING_HELPER_HPP
+
+ #ifndef __cplusplus
+       #error StringHelper.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <string>
+using std::string;
+
+#include<iostream>
+using std::ostream;
+using std::istream;
+
+#include <Config.hpp>
+
+// namespace SimGrid::Msg
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class SIMGRIDX_EXPORT StringHelper
+               {
+                       public:
+                               
+                               // Default constructor
+                                       StringHelper();
+
+                                       StringHelper(unsigned char c);
+                               
+                                       StringHelper(unsigned char c, int n);
+                               
+                                       StringHelper(char c);
+                               
+                                       StringHelper(char c, int n);
+                               
+                                       StringHelper(const char* cstr);
+                                       
+                                       StringHelper(const char* cstr, int n);
+                                       
+                                       StringHelper(const char* cstr, int pos, int n);
+                                       
+                                       StringHelper(const string& rstr);
+                                       
+                                       StringHelper(const string& rstr, int n);
+                                       
+                                       StringHelper(const string& rstr, int pos, int n);
+                                       
+                                       StringHelper(short si);
+                                       
+                                       StringHelper(int i);
+                                       
+                                       StringHelper(long l);
+                                       
+                                       StringHelper(float f);
+                                       
+                                       StringHelper(double d);
+
+                                       StringHelper(double d, const char* format);
+                                       
+                                       StringHelper(unsigned short usi);
+                                       
+                                       StringHelper(unsigned int ui);
+                                       
+                                       StringHelper(unsigned long ul);
+                               
+                               // Copy constructor
+                                       StringHelper(const StringHelper& rStringHelper);
+                               
+                               // Destructor
+                                       ~StringHelper();
+
+                               // Operations
+                               
+                                       StringHelper& append(unsigned char c);
+                               
+                                       StringHelper& append(unsigned char c, int n);
+                               
+                                       StringHelper& append(char c);
+                               
+                                       StringHelper& append(char c, int n);
+                               
+                                       StringHelper& append(const char* cstr);
+                                       
+                                       StringHelper& append(const char* cstr, int n);
+                                       
+                                       StringHelper& append(const char* cstr, int pos, int n);
+                                       
+                                       StringHelper& append(const string& rstr);
+                                       
+                                       StringHelper& append(const string& rstr, int n);
+                                       
+                                       StringHelper& append(const string& rstr, int pos, int n);
+                                       
+                                       StringHelper& append(short si);
+                                       
+                                       StringHelper& append(int i);
+                                       
+                                       StringHelper& append(long l);
+                                       
+                                       StringHelper& append(float f);
+                                       
+                                       StringHelper& append(double d);
+                                       
+                                       StringHelper& append(double d, const char* format);
+                                       
+                                       StringHelper& append(unsigned short usi);
+                                       
+                                       StringHelper& append(unsigned int ui);
+                                       
+                                       StringHelper& append(unsigned long ul);
+                                       
+                               const char& at(int pos) const;
+                               
+                               char& at(int pos);
+                                       
+                                       const char* cstr(void) const;
+                                       
+                                       string& toString(void);
+                                       
+                                       int size(void) const;
+
+                                       void clear(void);
+
+                                       bool empty(void);
+                                       
+                               //  Operators
+                                       
+                                       // Assignement
+                                       StringHelper& operator = (const StringHelper& rStringHelper);
+                                       
+                                       StringHelper& operator = (const char* cstr);
+                                       
+                                       StringHelper& operator = (const string& str);
+                                       
+                                       StringHelper& operator = (short n);
+                                       
+                                       StringHelper& operator = (int n);
+                                       
+                                       StringHelper& operator = (long n);
+                                       
+                                       StringHelper& operator = (float n);
+                                       
+                                       StringHelper& operator = (double n);
+                                       
+                                       StringHelper& operator = (unsigned short n);
+                                       
+                                       StringHelper& operator = (unsigned int n);
+                                       
+                                       StringHelper& operator = (unsigned long n);
+                                       
+                                       char& operator[](int pos);
+                                       
+                                       char operator[](int pos) const;
+                                       
+                                       StringHelper& operator += (short n);
+                                       
+                                       StringHelper& operator += (int n);
+                                       
+                                       StringHelper& operator += (long n);
+                                       
+                                       StringHelper& operator += (float n);
+                                       
+                                       StringHelper& operator += (double n);
+                                       
+                                       StringHelper& operator += (unsigned short n);
+                                       
+                                       StringHelper& operator += (unsigned int n);
+                                       
+                                       StringHelper& operator += (unsigned long n);
+                                       
+                                       StringHelper& operator += (const StringHelper& rStringHelper);
+                                       
+                                       StringHelper& operator += (const string& rstr);
+                                       
+                               StringHelper& operator += (const char* cstr);
+                               
+                               StringHelper& operator += (char c);
+                               
+                                       StringHelper& operator + (short n);
+                                       
+                                       StringHelper& operator + (int n);
+                                       
+                                       StringHelper& operator + (long n);
+                                       
+                                       StringHelper& operator + (float n);
+                                       
+                                       StringHelper& operator + (double n);
+                                       
+                                       StringHelper& operator + (unsigned short n);
+                                       
+                                       StringHelper& operator + (unsigned int n);
+                                       
+                                       StringHelper& operator + (unsigned long n);
+                                       
+                                       StringHelper& operator + (const StringHelper& rStringHelper);
+                                       
+                                       StringHelper& operator + (const string& rstr);
+                                       
+                               StringHelper& operator + (const char* cstr);
+                               
+                               StringHelper& operator + (char c);
+
+                                       operator char *();
+
+                                       operator const char *();
+
+                                       friend SIMGRIDX_EXPORT ostream& operator<<(ostream& stream, const StringHelper& s);
+
+                                       friend SIMGRIDX_EXPORT istream& operator<<(istream& stream, StringHelper& s);
+                               
+                               private:
+
+                                       // Methods
+                                       void init(void);
+                                       
+                                       // Attributes
+                                       
+                                       char* content;
+                                       int capacity;
+                                       int len;
+               };
+               
+               typedef class StringHelper* StringHelperPtr;
+
+               #define TEXT_(___x)     StringHelper((___x))
+
+
+       } // namespace Msg
+} // namespace SimGrid
+
+
+#endif // !STRING_HELPER_HPP
+
index 93e1c68..3c3dcca 100644 (file)
-/*\r
- * Task.cxx\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
- /* Task member functions implementation.\r
-  */  \r
-\r
-#include <Process.hpp>\r
-#include <Host.hpp>\r
-\r
-#include <Task.hpp>\r
-\r
-#include <stdlib.h>\r
-#include <stdio.h>\r
-\r
-#include <msg/msg.h>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-\r
-               MSG_IMPLEMENT_DYNAMIC(Task, Object);\r
-       \r
-               Task::Task()\r
-               {\r
-                       nativeTask = NULL;\r
-               }\r
-               \r
-               \r
-               Task::Task(const Task& rTask)\r
-               {\r
-                       this->nativeTask = rTask.nativeTask;\r
-               }\r
-               \r
-               \r
-               Task::~Task()\r
-               throw(MsgException)\r
-               {\r
-                       if(NULL != nativeTask)\r
-                               if(MSG_OK != MSG_task_destroy(nativeTask))\r
-                                       throw MsgException("MSG_task_destroy() failed");\r
-               }\r
-               \r
-               \r
-               Task::Task(const char* name, double computeDuration, double messageSize)\r
-               throw(InvalidArgumentException, NullPointerException)\r
-               {\r
-\r
-                       if(computeDuration < 0) \r
-                               throw InvalidArgumentException("computeDuration");\r
-                       \r
-                       if(messageSize < 0) \r
-                               throw InvalidArgumentException("messageSize");\r
-                       \r
-                       if(!name) \r
-                               throw NullPointerException("name");\r
-                       \r
-                       // create the task\r
-                       nativeTask = MSG_task_create(name, computeDuration, messageSize, NULL);\r
-                       \r
-                       nativeTask->data = (void*)this;\r
-               }\r
-               \r
-               Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)\r
-               throw(NullPointerException, InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!name) \r
-                               throw NullPointerException("name");\r
-                       \r
-                       if(!hosts) \r
-                               throw NullPointerException("hosts");\r
-                       \r
-                       if(!computeDurations) \r
-                               throw NullPointerException("computeDurations");\r
-                               \r
-                       if(!messageSizes) \r
-                               throw NullPointerException("messageSizes");\r
-                               \r
-                       if(!hostCount)\r
-                               throw InvalidArgumentException("hostCount (must not be zero)");\r
-                               \r
-                       \r
-                       m_host_t* nativeHosts;\r
-                       double* durations;\r
-                       double* sizes;\r
-                       \r
-                       \r
-                       nativeHosts = xbt_new0(m_host_t, hostCount);\r
-                       durations = xbt_new0(double,hostCount);\r
-                       sizes = xbt_new0(double, hostCount * hostCount);\r
-                       \r
-                       \r
-                       for(int index = 0; index < hostCount; index++) \r
-                       {\r
-                               \r
-                               nativeHosts[index] = hosts[index].nativeHost;\r
-                               durations[index] = computeDurations[index];\r
-                       }\r
-                       \r
-                       for(int index = 0; index < hostCount*hostCount; index++) \r
-                               sizes[index] = messageSizes[index];\r
-                       \r
-                       \r
-                       nativeTask = MSG_parallel_task_create(name, hostCount, nativeHosts, durations, sizes,NULL);\r
-                       \r
-                       \r
-                       \r
-                       this->nativeTask->data = (void*)this;\r
-                       \r
-               }\r
-               \r
-               const char* Task::getName(void) const\r
-               {\r
-                       return nativeTask->name;\r
-               }\r
-               \r
-               Process& Task::getSender(void) const\r
-               {\r
-                       m_process_t nativeProcess = MSG_task_get_sender(nativeTask);\r
-                       \r
-                       return (*((Process*)(nativeProcess->data)));\r
-               }\r
-               \r
-               Host& Task::getSource(void) const \r
-               {\r
-                       m_host_t nativeHost = MSG_task_get_source(nativeTask);\r
-                       \r
-                       return (*((Host*)(nativeHost->data)));  \r
-               }\r
-               \r
-               double Task::getComputeDuration(void) const\r
-               {\r
-                       return MSG_task_get_compute_duration(nativeTask);\r
-               }\r
-               \r
-               double Task::getRemainingDuration(void) const\r
-               {\r
-                       return MSG_task_get_remaining_computation(nativeTask);\r
-               }\r
-               \r
-               void Task::setPriority(double priority)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(priority < 0.0)\r
-                               throw InvalidArgumentException("priority");\r
-                               \r
-                       MSG_task_set_priority(nativeTask, priority);\r
-               }\r
-\r
-               Task* Task::get(int channel) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, NULL)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return ((Task*)(nativeTask->data));\r
-               }\r
-               \r
-               Task* Task::get(int channel, const Host& rHost) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::get(int channel, double timeout, const Host& rHost) \r
-               throw(InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                       \r
-                       if(timeout < 0 && timeout !=-1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different thant -1.0)");      \r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_get_ext() failed");\r
-                       \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               int Task::probe(int channel)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       return MSG_task_Iprobe(channel);\r
-               }\r
-               \r
-               int Task::probe(int channel, const Host& rHost)\r
-               throw(InvalidArgumentException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(channel < 0)\r
-                               throw InvalidArgumentException("channel (must not be negative)");\r
-                               \r
-                       return MSG_task_probe_from_host(channel,rHost.nativeHost);\r
-               }\r
-               \r
-               void Task::execute(void) \r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_task_execute(nativeTask))\r
-                               throw MsgException("MSG_task_execute() failed");\r
-               }\r
-               \r
-               void Task::cancel(void) \r
-               throw(MsgException)\r
-               {\r
-                       if(MSG_OK != MSG_task_cancel(nativeTask))\r
-                               throw MsgException("MSG_task_cancel() failed");\r
-               }\r
-               \r
-               void Task::send(void) \r
-               throw(BadAllocException, MsgException)\r
-               {       \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, -1.0);\r
-               \r
-                       free(alias);\r
-               \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::send(const char* alias) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-               \r
-                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, -1.0))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::send(double timeout) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(timeout < 0  && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");\r
-                                               \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-               \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, timeout);\r
-               \r
-                       free(alias);\r
-               \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }       \r
-               \r
-               void Task::send(const char* alias, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       if(timeout < 0  && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");\r
-                                               \r
-                               \r
-                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, timeout))\r
-                               throw MsgException("MSG_task_send_with_timeout() failed");\r
-               }\r
-               \r
-               void Task::sendBounded(double maxRate) \r
-               throw(BadAllocException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(maxRate < 0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");\r
-                                       \r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       MSG_error_t rv = MSG_task_send_bounded(nativeTask, alias, maxRate);\r
-                       \r
-                       free(alias);    \r
-                       \r
-                       if(MSG_OK != rv)\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-                               \r
-               }\r
-               \r
-               void Task::sendBounded(const char* alias, double maxRate) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(maxRate < 0 && maxRate != -1.0)\r
-                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");\r
-                                                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(MSG_OK != MSG_task_send_bounded(nativeTask, alias, maxRate))\r
-                               throw MsgException("MSG_task_send_bounded() failed");\r
-               }\r
-\r
-               Task* Task::receive(void) \r
-               throw(BadAllocException, MsgException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);  \r
-               \r
-                       free(alias);\r
-                       \r
-                       if(MSG_OK != rv) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-\r
-               Task* Task::receive(const char* alias) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::receive(const char* alias, double timeout) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               Task* Task::receive(const char* alias, const Host& rHost) \r
-               throw(NullPointerException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }       \r
-               \r
-               Task* Task::receive(const char* alias, double timeout, const Host& rHost) \r
-               throw(NullPointerException, InvalidArgumentException, MsgException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                       \r
-                       if(timeout < 0 && timeout != -1.0)\r
-                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");\r
-                               \r
-                       m_task_t nativeTask = NULL;\r
-                       \r
-                       \r
-                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) \r
-                               throw MsgException("MSG_task_receive_ext() failed");\r
-               \r
-                       return (Task*)(nativeTask->data);\r
-               }\r
-               \r
-               int Task::listen(void) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                               \r
-                       int rv = MSG_task_listen(alias);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }       \r
-               \r
-               int Task::listen(const char* alias) \r
-               throw(NullPointerException)\r
-               {\r
-                       // check the parameters\r
-                       \r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen(alias);\r
-               }\r
-               \r
-               int Task::listenFrom(void) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                               \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       int rv = MSG_task_listen_from(alias);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }       \r
-               \r
-               int Task::listenFrom(const char* alias) \r
-               throw(NullPointerException)\r
-               {\r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen_from(alias);\r
-                       \r
-               }\r
-               \r
-               int Task::listenFromHost(const Host& rHost) \r
-               throw(BadAllocException)\r
-               {\r
-                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));\r
-                       \r
-                       if(!alias)\r
-                               throw BadAllocException("alias");\r
-                       \r
-                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());\r
-                       \r
-                       int rv = MSG_task_listen_from_host(alias, rHost.nativeHost);\r
-                       \r
-                       free(alias);\r
-                       \r
-                       return rv;\r
-               }\r
-                       \r
-               int Task::listenFromHost(const char* alias, const Host& rHost) \r
-               throw(NullPointerException)\r
-               {\r
-                       // check the parameters\r
-                       if(!alias)\r
-                               throw NullPointerException("alias");\r
-                               \r
-                       return MSG_task_listen_from_host(alias, rHost.nativeHost);\r
-               }       \r
-\r
-               const Task& Task::operator = (const Task& rTask)\r
-               {\r
-                       this->nativeTask = rTask.nativeTask;\r
-                       return *this;\r
-               }\r
-       } // namespace Msg                                                                                                                                                                                              \r
-} // namespace SimGrid\r
-\r
+/*
+ * Task.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Task member functions implementation.
+  */  
+
+#include <Process.hpp>
+#include <Host.hpp>
+
+#include <Task.hpp>
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <msg/msg.h>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+
+               MSG_IMPLEMENT_DYNAMIC(Task, Object)
+       
+               Task::Task()
+               {
+                       nativeTask = NULL;
+               }
+               
+               
+               Task::Task(const Task& rTask)
+               {
+                       this->nativeTask = rTask.nativeTask;
+               }
+               
+               
+               Task::~Task()
+               throw(MsgException)
+               {
+                       if(NULL != nativeTask)
+                               if(MSG_OK != MSG_task_destroy(nativeTask))
+                                       throw MsgException("MSG_task_destroy() failed");
+               }
+               
+               
+               Task::Task(const char* name, double computeDuration, double messageSize)
+               throw(InvalidArgumentException, NullPointerException)
+               {
+
+                       if(computeDuration < 0) 
+                               throw InvalidArgumentException("computeDuration");
+                       
+                       if(messageSize < 0) 
+                               throw InvalidArgumentException("messageSize");
+                       
+                       if(!name) 
+                               throw NullPointerException("name");
+                       
+                       // create the task
+                       nativeTask = MSG_task_create(name, computeDuration, messageSize, NULL);
+                       
+                       nativeTask->data = (void*)this;
+               }
+               
+               Task::Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)
+               throw(NullPointerException, InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(!name) 
+                               throw NullPointerException("name");
+                       
+                       if(!hosts) 
+                               throw NullPointerException("hosts");
+                       
+                       if(!computeDurations) 
+                               throw NullPointerException("computeDurations");
+                               
+                       if(!messageSizes) 
+                               throw NullPointerException("messageSizes");
+                               
+                       if(!hostCount)
+                               throw InvalidArgumentException("hostCount (must not be zero)");
+                               
+                       
+                       m_host_t* nativeHosts;
+                       double* durations;
+                       double* sizes;
+                       
+                       
+                       nativeHosts = xbt_new0(m_host_t, hostCount);
+                       durations = xbt_new0(double,hostCount);
+                       sizes = xbt_new0(double, hostCount * hostCount);
+                       
+                       
+                       for(int index = 0; index < hostCount; index++) 
+                       {
+                               
+                               nativeHosts[index] = hosts[index].nativeHost;
+                               durations[index] = computeDurations[index];
+                       }
+                       
+                       for(int index = 0; index < hostCount*hostCount; index++) 
+                               sizes[index] = messageSizes[index];
+                       
+                       
+                       nativeTask = MSG_parallel_task_create(name, hostCount, nativeHosts, durations, sizes,NULL);
+                       
+                       
+                       
+                       this->nativeTask->data = (void*)this;
+                       
+               }
+               
+               const char* Task::getName(void) const
+               {
+                       return nativeTask->name;
+               }
+               
+               Process& Task::getSender(void) const
+               {
+                       m_process_t nativeProcess = MSG_task_get_sender(nativeTask);
+                       
+                       return (*((Process*)(nativeProcess->data)));
+               }
+               
+               Host& Task::getSource(void) const 
+               {
+                       m_host_t nativeHost = MSG_task_get_source(nativeTask);
+                       
+                       return (*((Host*)(nativeHost->data)));  
+               }
+               
+               double Task::getComputeDuration(void) const
+               {
+                       return MSG_task_get_compute_duration(nativeTask);
+               }
+               
+               double Task::getRemainingDuration(void) const
+               {
+                       return MSG_task_get_remaining_computation(nativeTask);
+               }
+               
+               void Task::setPriority(double priority)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(priority < 0.0)
+                               throw InvalidArgumentException("priority");
+                               
+                       MSG_task_set_priority(nativeTask, priority);
+               }
+
+               Task* Task::get(int channel) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, NULL)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return ((Task*)(nativeTask->data));
+               }
+               
+               Task* Task::get(int channel, const Host& rHost) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::get(int channel, double timeout, const Host& rHost) 
+               throw(InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                       
+                       if(timeout < 0 && timeout !=-1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different thant -1.0)");      
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_get_ext(&nativeTask, channel , timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_get_ext() failed");
+                       
+                       return (Task*)(nativeTask->data);
+               }
+               
+               int Task::probe(int channel)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       return MSG_task_Iprobe(channel);
+               }
+               
+               int Task::probe(int channel, const Host& rHost)
+               throw(InvalidArgumentException)
+               {
+                       // check the parameters
+                       
+                       if(channel < 0)
+                               throw InvalidArgumentException("channel (must not be negative)");
+                               
+                       return MSG_task_probe_from_host(channel,rHost.nativeHost);
+               }
+               
+               void Task::execute(void) 
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_task_execute(nativeTask))
+                               throw MsgException("MSG_task_execute() failed");
+               }
+               
+               void Task::cancel(void) 
+               throw(MsgException)
+               {
+                       if(MSG_OK != MSG_task_cancel(nativeTask))
+                               throw MsgException("MSG_task_cancel() failed");
+               }
+               
+               void Task::send(void) 
+               throw(BadAllocException, MsgException)
+               {       
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, -1.0);
+               
+                       free(alias);
+               
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::send(const char* alias) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+               
+                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, -1.0))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::send(double timeout) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(timeout < 0  && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");
+                                               
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+               
+                       MSG_error_t rv = MSG_task_send_with_timeout(nativeTask, alias, timeout);
+               
+                       free(alias);
+               
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }       
+               
+               void Task::send(const char* alias, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       if(timeout < 0  && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and different than -1.0");
+                                               
+                               
+                       if(MSG_OK != MSG_task_send_with_timeout(nativeTask, alias, timeout))
+                               throw MsgException("MSG_task_send_with_timeout() failed");
+               }
+               
+               void Task::sendBounded(double maxRate) 
+               throw(BadAllocException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(maxRate < 0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");
+                                       
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       MSG_error_t rv = MSG_task_send_bounded(nativeTask, alias, maxRate);
+                       
+                       free(alias);    
+                       
+                       if(MSG_OK != rv)
+                               throw MsgException("MSG_task_send_bounded() failed");
+                               
+               }
+               
+               void Task::sendBounded(const char* alias, double maxRate) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(maxRate < 0 && maxRate != -1.0)
+                               throw InvalidArgumentException("maxRate (must not be negative and different than -1.0");
+                                                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(MSG_OK != MSG_task_send_bounded(nativeTask, alias, maxRate))
+                               throw MsgException("MSG_task_send_bounded() failed");
+               }
+
+               Task* Task::receive(void) 
+               throw(BadAllocException, MsgException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       MSG_error_t rv = MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL);  
+               
+                       free(alias);
+                       
+                       if(MSG_OK != rv) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+
+               Task* Task::receive(const char* alias) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::receive(const char* alias, double timeout) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, NULL)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               Task* Task::receive(const char* alias, const Host& rHost) 
+               throw(NullPointerException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       m_task_t nativeTask = NULL;
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, -1.0, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }       
+               
+               Task* Task::receive(const char* alias, double timeout, const Host& rHost) 
+               throw(NullPointerException, InvalidArgumentException, MsgException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                       
+                       if(timeout < 0 && timeout != -1.0)
+                               throw InvalidArgumentException("timeout (must not be negative and differnt than -1.0)");
+                               
+                       m_task_t nativeTask = NULL;
+                       
+                       
+                       if(MSG_OK != MSG_task_receive_ext(&nativeTask, alias, timeout, rHost.nativeHost)) 
+                               throw MsgException("MSG_task_receive_ext() failed");
+               
+                       return (Task*)(nativeTask->data);
+               }
+               
+               int Task::listen(void) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                               
+                       int rv = MSG_task_listen(alias);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }       
+               
+               int Task::listen(const char* alias) 
+               throw(NullPointerException)
+               {
+                       // check the parameters
+                       
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen(alias);
+               }
+               
+               int Task::listenFrom(void) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                               
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       int rv = MSG_task_listen_from(alias);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }       
+               
+               int Task::listenFrom(const char* alias) 
+               throw(NullPointerException)
+               {
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen_from(alias);
+                       
+               }
+               
+               int Task::listenFromHost(const Host& rHost) 
+               throw(BadAllocException)
+               {
+                       char* alias = (char*)calloc(strlen(Process::currentProcess().getName()) + strlen(Host::currentHost().getName()) + 2, sizeof(char));
+                       
+                       if(!alias)
+                               throw BadAllocException("alias");
+                       
+                       sprintf(alias,"%s:%s", Host::currentHost().getName(), Process::currentProcess().getName());
+                       
+                       int rv = MSG_task_listen_from_host(alias, rHost.nativeHost);
+                       
+                       free(alias);
+                       
+                       return rv;
+               }
+                       
+               int Task::listenFromHost(const char* alias, const Host& rHost) 
+               throw(NullPointerException)
+               {
+                       // check the parameters
+                       if(!alias)
+                               throw NullPointerException("alias");
+                               
+                       return MSG_task_listen_from_host(alias, rHost.nativeHost);
+               }       
+
+               const Task& Task::operator = (const Task& rTask)
+               {
+                       this->nativeTask = rTask.nativeTask;
+                       return *this;
+               }
+       } // namespace Msg                                                                                                                                                                                              
+} // namespace SimGrid
+
index e78d9dd..e8bfd38 100644 (file)
-/*\r
- * Task.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_TASK_HPP\r
-#define MSG_TASK_HPP\r
-\r
-// Compilation C++ recquise\r
-#ifndef __cplusplus\r
-       #error Task.hpp requires C++ compilation (use a .cxx suffix)\r
-#endif\r
-\r
-#include <msg/datatypes.h>\r
-\r
-#include <MsgException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <MsgException.hpp>\r
-#include <BadAllocException.hpp>\r
-\r
-#include <Object.hpp>\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-               class Process;\r
-               class Host;\r
-\r
-               // SimGrid::Msg::Task wrapper class declaration.\r
-               class SIMGRIDX_EXPORT Task : public Object\r
-               {\r
-                       MSG_DECLARE_DYNAMIC(Task);\r
-\r
-                       friend class Process;\r
-                       friend class Host;\r
-\r
-                       protected:\r
-                               // Default constructor.\r
-                               Task();\r
-                               \r
-                       public:\r
-                               /*! \brief Copy constructor.\r
-                                */\r
-                               Task(const Task& rTask);\r
-                               \r
-                               /*! \brief Destructor.\r
-                                *\r
-                                * \exception                           If the destructor failed, it throw the exception described below:\r
-                                *\r
-                                *                                                      [MsgException]                          if a native exception occurs.\r
-                                */\r
-                               virtual ~Task()\r
-                               throw(MsgException);\r
-                               \r
-                               /*! \brief Constructs an new task with the specified processing amount and amount\r
-                                * of data needed.\r
-                                *\r
-                                * \param name                          Task's name\r
-                                * \param computeDuration       A value of the processing amount (in flop) needed to process the task. \r
-                                *                                                      If 0, then it cannot be executed with the execute() method.\r
-                                *                                                      This value has to be >= 0.\r
-                                * \param messageSize           A value of amount of data (in bytes) needed to transfert this task.\r
-                                *                                                      If 0, then it cannot be transfered with the get() and put() methods.\r
-                                *                                                      This value has to be >= 0.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the parameter computeDuration or messageSize\r
-                                *                                                                                                              is negative.\r
-                                *                                                      [NullPointerException]          if the parameter name is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if a internal exception occurs.\r
-                                */\r
-                               Task(const char* name, double computeDuration, double messageSize)\r
-                               throw (InvalidArgumentException, NullPointerException);\r
-                               \r
-                               /*! \Constructs an new parallel task with the specified processing amount and amount for each host\r
-                            * implied.\r
-                            *\r
-                            * \param name                              The name of the parallel task.\r
-                            * \param hosts                             The list of hosts implied by the parallel task.\r
-                            * \param computeDurations  The amount of operations to be performed by each host of \a hosts.\r
-                            * \param messageSizes              A matrix describing the amount of data to exchange between hosts.\r
-                            * \hostCount                               The number of hosts implied in the parallel task.\r
-                            * \r
-                            * \exception                               If this method fails, it throws one of the exceptions described below:\r
-                            *\r
-                            *                                                  [NullPointerException]          if the parameter name is NULL or\r
-                            *                                                                                                          if the parameter computeDurations is NULL or\r
-                            *                                                                                                          if the parameter messageSizes is NULL\r
-                            *\r
-                            *                                                  [InvalidArgumentException]      if the parameter hostCount is negative or zero.                                                 \r
-                            */\r
-                               Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)\r
-                               throw(NullPointerException, InvalidArgumentException);\r
-                       \r
-                       \r
-                               /*! \brief Task::getName() - Gets the names of the task.\r
-                                *\r
-                                * \return                                      The name of the task.\r
-                                */\r
-                               const char* getName(void) const;\r
-                       \r
-                               /*! \brief Task::getSender() - Gets the sender of the task.\r
-                                *\r
-                                * \return                                      A reference to the sender of the task.\r
-                                */\r
-                               Process& getSender(void) const;\r
-                               \r
-                               /*! \brief Task::getSource() - Gets the source of the task.\r
-                                * \r
-                                * \return                                      A reference to the source of the task.\r
-                                */\r
-                               Host& getSource(void) const;\r
-                               \r
-                               /*! \brief Task::getComputeDuration() - Get the computing amount of the task.\r
-                                *\r
-                                * \return                                      The computing amount of the task.\r
-                                */\r
-                       \r
-                               double getComputeDuration(void) const;\r
-                               \r
-                               /*! \brief Task::getRemainingDuration() - Gets the remaining computation.\r
-                                *\r
-                                * \return                                      The remining computation of the task.\r
-                                */\r
-                               double getRemainingDuration(void) const;\r
-                       \r
-                               /*! \brief Task::setPrirority() -  Sets the priority of the computation of the task.\r
-                        * The priority doesn't affect the transfert rate. For example a\r
-                        * priority of 2 will make the task receive two times more cpu than\r
-                        * the other ones.\r
-                        *\r
-                        * \param priority                      The new priority of the task.\r
-                        *\r
-                        * execption                            If this method fails, it throws the exception described below:\r
-                        *\r
-                        *                                                      [InvalidArgumentException]      if the parameter priority is negative.\r
-                        */\r
-                               void setPriority(double priority)\r
-                               throw(InvalidArgumentException);\r
-                               \r
-                               /*! \brief Task::get() - Gets a task from the specified channel of the host of the current process.\r
-                                *\r
-                                * \param channel                       The channel number to get the task.\r
-                                *\r
-                                * \return                                      If successful the method returns the task. Otherwise the method throws one\r
-                                *                                                      of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the channel parameter is negative.\r
-                                *                                      \r
-                                *                                                      [MsgException]                          if an internal excpetion occurs.\r
-                                */\r
-                               static Task* get(int channel) \r
-                               throw(InvalidArgumentException, MsgException);\r
-\r
-                               /*! \brief      Task::get() - Gets a task from the given channel number of the given host.      \r
-                                *\r
-                                * \param channel                       The channel number.\r
-                                * \param rHost                         A reference of the host owning the channel.\r
-                                *\r
-                                * \return                                      If successful, the method returns the task. Otherwise the method\r
-                                *                                                      throw one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the channel number is negative.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               static Task* get(int channel, const Host& rHost) \r
-                               throw(InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::get() - Gets a task from the specified channel of the specified host\r
-                                *  (waiting at most given time).\r
-                                *\r
-                                * \param channel                       The channel number.\r
-                                * \param timeout                       The timeout value.\r
-                                * \param rHost                         A reference to the host owning the channel.\r
-                                *\r
-                                * \return                                      If successful, the method returns the task. Otherwise the method returns\r
-                                *                                                      one of the exceptions described below:\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the channel number is negative or\r
-                                *                                                                                                              if the timeout value is negative and \r
-                                *                                                                                                              different than -1.0.\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               static Task* get(int channel, double timeout, const Host& rHost) \r
-                               throw(InvalidArgumentException, MsgException);  \r
-                               \r
-                               /*! \brief Task::probe() - Probes whether there is a waiting task on the given channel of local host.\r
-                                *\r
-                                * \param channel                       The channel number.\r
-                                *\r
-                                * \return                                      If there is a waiting task on the channel the method returns 1. Otherwise\r
-                                *                                                      the method returns 0.\r
-                                *\r
-                                * \exception                           If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the parameter channel is negative.\r
-                                */\r
-                               static int probe(int channel)\r
-                               throw(InvalidArgumentException);\r
-                               \r
-                               /*! \brief Task::probe() - Counts tasks waiting on the given channel of local host and sent by given host.\r
-                                *\r
-                                * \param channel                       The channel id.\r
-                                * \param rHost                         A reference to the host that has sent the task.\r
-                                *\r
-                                * \return                                      The number of tasks.\r
-                                *\r
-                                * \exception                           [InvalidArgumentException]      if the parameter channel is negative.\r
-                                */\r
-                               static int probe(int channel, const Host& rHost)\r
-                               throw(InvalidArgumentException);\r
-                               \r
-                               /*! \brief Task::execute() - This method executes a task on the location on which the\r
-                                * process is running.\r
-                                *\r
-                                * \exception                           If this method fails, it returns the exception described below:\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void execute(void) \r
-                               throw(MsgException);\r
-                               \r
-                               /*! \brief Task::cancel() - This method cancels a task.\r
-                                *\r
-                                * \exception                           If this method fails, it returns the exception described below:\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void cancel(void) \r
-                               throw(MsgException);\r
-                       \r
-                               /*! \brief Task::send() - Send the task on the mailbox identified by the default alias.\r
-                                *\r
-                                * \exception                           If this method failed, it returns one of the exceptions described\r
-                                *                                                      below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void send(void) \r
-                               throw(BadAllocException, MsgException);\r
-                               \r
-                               /*! \brief Task::send() - Send the task on the mailbox identified by the given alias.\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to send the task.\r
-                                *\r
-                                * \exception                           If this method failed, it returns one of the exceptions described\r
-                                *                                                      below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if there parameter alias is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */ \r
-                               void send(const char* alias) \r
-                               throw(NullPointerException, MsgException);\r
-                               \r
-                               /*! \brief Task::send() - Send the task on the mailbox identified by the default alias\r
-                                * (waiting at most given time).\r
-                                *\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \exception                           If this method failed, it returns one of the exceptions described\r
-                                *                                                      below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negative or different -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void send(double timeout) \r
-                               throw(BadAllocException, InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::send() - Send the task on the mailbox identified by a given alias\r
-                                * (waiting at most given time).\r
-                                *\r
-                                * \param alias                         The alias of the mailbox where to send the task.\r
-                                * \param timeout                       The timeout value.\r
-                                *\r
-                                * \exception                           If this method failed, it returns one of the exceptions described\r
-                                *                                                      below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if alias parameter is NULL.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negative or different -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void send(const char* alias, double timeout) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the default alias.\r
-                                * (capping the emision rate to maxrate).\r
-                                *\r
-                                * \param maxRate                       The maximum rate value.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the parameter maxRate is negative and different\r
-                                *                                                                                                              than -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void sendBounded(double maxRate) \r
-                               throw(BadAllocException, InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the given alias.\r
-                                * (capping the emision rate to maxrate).\r
-                                *\r
-                                *\ param alias                         The alias of the mailbox where to send the task.\r
-                                * \param maxRate                       The maximum rate value.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the parameter maxRate is negative and different\r
-                                *                                                                                                              than -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               void sendBounded(const char* alias, double maxRate) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                               \r
-                               \r
-                               /*! \brief Task::receive() - Receives a task from the mailbox identified by the default alias (located\r
-                                * on the local host).\r
-                                *\r
-                                * \return                                      A reference to the task.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exception described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               /*static Task& receive(void) \r
-                               throw(BadAllocException, MsgException);*/\r
-\r
-                               static Task* receive(void) \r
-                               throw(BadAllocException, MsgException);\r
-                               \r
-                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
-                                * on the local host).\r
-                                *\r
-                                * \alias                                       The alias of the mailbox.\r
-                                *\r
-                                * \return                                      A reference to the task.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exception described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               /*static Task& receive(const char* alias) \r
-                               throw(NullPointerException, MsgException);*/\r
-                               static Task* receive(const char* alias) \r
-                               throw(NullPointerException, MsgException);\r
-                               \r
-                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located\r
-                                * on the local host and waiting at most given time).\r
-                                *\r
-                                * \alias                                       The alias of the mailbox.\r
-                                * \timeout                                     The timeout value.\r
-                                *\r
-                                * \return                                      A reference to the task.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exception described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negatif and different than\r
-                                *                                                                                                              -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               static Task* receive(const char* alias, double timeout) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located\r
-                                * on the given host.\r
-                                *\r
-                                * \alias                                       The alias of the mailbox.\r
-                                * \rHost                                       The location of the mailbox.\r
-                                *\r
-                                * \return                                      A reference to the task.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exception described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               static Task* receive(const char* alias, const Host& rHost) \r
-                               throw(NullPointerException, MsgException);\r
-                               \r
-                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located\r
-                                * on the given host (and waiting at most given time).\r
-                                *\r
-                                * \alias                                       The alias of the mailbox.\r
-                                * \timeout                                     The timeout value.\r
-                                * \rHost                                       The location of the mailbox.\r
-                                *\r
-                                * \return                                      A reference to the task.\r
-                                *\r
-                                * \exception                           If this method failed, it throws one of the exception described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                *\r
-                                *                                                      [InvalidArgumentException]      if the timeout value is negatif and different than\r
-                                *                                                                                                              -1.0.\r
-                                *\r
-                                *                                                      [MsgException]                          if an internal exception occurs.\r
-                                */\r
-                               static Task* receive(const char* alias, double timeout, const Host& rHost) \r
-                               throw(NullPointerException, InvalidArgumentException, MsgException);\r
-                               \r
-                               /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
-                                * identified by the default alias of local host.\r
-                                *\r
-                                * \return                                      If there is a waiting task on the mailbox the method returns true.\r
-                                *                                                      Otherwise the method returns false.\r
-                                *\r
-                                * \exception                           If this method fails, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.\r
-                                */\r
-                               static int listen(void) \r
-                               throw(BadAllocException);\r
-                               \r
-                               /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox \r
-                                * identified by the given alias of local host.\r
-                                *\r
-                                * \param alias                         The alias of the mailbox.\r
-                                *\r
-                                * \return                                      If there is a waiting task on the mailbox the method returns 1.\r
-                                *                                                      Otherwise the method returns 0.\r
-                                *\r
-                                * \exception                           If this method fails, it throws one of the exceptions described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the parameter alias is NULL.\r
-                                */\r
-                               static int listen(const char* alias) \r
-                               throw(NullPointerException);\r
-                               \r
-                               /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox \r
-                                * identified by the default alias, and who sent it.\r
-                                *\r
-                                * \return                                      If there is a pending communication on the mailbox, the method returns\r
-                                *                                                      the PID of it sender. Otherwise the method returns -1.\r
-                                *\r
-                                * \exception                           If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default\r
-                                *                                                                                                              alias.\r
-                                */\r
-                               static int listenFrom(void) \r
-                               throw(BadAllocException);\r
-                               \r
-                               /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox \r
-                                * identified by the specified alias, and who sent it.\r
-                                *\r
-                                * \alias                                       The alias of the mailbox.\r
-                                *\r
-                                * \return                                      If there is a pending communication on the mailbox, the method returns\r
-                                *                                                      the PID of it sender. Otherwise the method returns -1.\r
-                                *\r
-                                * \exception                           If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                                      [NullPointerException]          if the alias parameter is NULL.\r
-                                */\r
-                               static int listenFrom(const char* alias) \r
-                               throw(NullPointerException);\r
-                               \r
-                               /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox \r
-                                * identified by the default alias and located on the host of the current process, and who sent it.\r
-                                *\r
-                                * \param rHost                         The location of the mailbox.\r
-                                *\r
-                                * \return                                      If there is a pending communication on the mailbox, the method returns\r
-                                *                                                      the PID of it sender. Otherwise the method returns -1.\r
-                                *\r
-                                * \exception                           If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default\r
-                                *                                                                                                              alias.\r
-                                */\r
-                               static int listenFromHost(const Host& rHost) \r
-                               throw(BadAllocException);\r
-                               \r
-                               /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox \r
-                                * identified by the default alias and located on the host of the current process, and who sent it.\r
-                                *\r
-                                * \param rHost                         The location of the mailbox.\r
-                                *\r
-                                * \return                                      If there is a pending communication on the mailbox, the method returns\r
-                                *                                                      the PID of it sender. Otherwise the method returns -1.\r
-                                *\r
-                                * \exception                           If this method fails, it throws the exception described below:\r
-                                *\r
-                                *                                                      [BadAllocException]                     if there is not enough memory to build the default\r
-                                *                                                                                                              alias.\r
-                                */\r
-                               static int listenFromHost(const char* alias, const Host& rHost) \r
-                               throw(NullPointerException);\r
-\r
-                               virtual const Task& operator= (const Task& rTask);\r
-                       \r
-                       protected:\r
-                               \r
-                               // Attributes.\r
-                               \r
-                               m_task_t nativeTask;    // the native MSG task.\r
-               };\r
-       \r
-       } // namespace Msg \r
-} // namespace SimGrid\r
-\r
-typedef Task* TaskPtr;\r
-\r
-#endif // §MSG_TASK_HPP\r
-\r
+/*
+ * Task.hpp
+ *
+ * This file contains the declaration of the wrapper class of the native MSG task type.
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */  
+#ifndef MSG_TASK_HPP
+#define MSG_TASK_HPP
+
+// Compilation C++ recquise
+#ifndef __cplusplus
+       #error Task.hpp requires C++ compilation (use a .cxx suffix)
+#endif
+
+#include <msg/datatypes.h>
+
+#include <MsgException.hpp>
+#include <InvalidArgumentException.hpp>
+#include <NullPointerException.hpp>
+#include <MsgException.hpp>
+#include <BadAllocException.hpp>
+
+#include <Object.hpp>
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+               class Process;
+               class Host;
+
+               // SimGrid::Msg::Task wrapper class declaration.
+               class SIMGRIDX_EXPORT Task : public Object
+               {
+                       MSG_DECLARE_DYNAMIC(Task);
+
+                       friend class Process;
+                       friend class Host;
+
+                       protected:
+                               // Default constructor.
+                               Task();
+                               
+                       public:
+                               /*! \brief Copy constructor.
+                                */
+                               Task(const Task& rTask);
+                               
+                               /*! \brief Destructor.
+                                *
+                                * \exception                           If the destructor failed, it throw the exception described below:
+                                *
+                                *                                                      [MsgException]                          if a native exception occurs.
+                                */
+                               virtual ~Task()
+                               throw(MsgException);
+                               
+                               /*! \brief Constructs an new task with the specified processing amount and amount
+                                * of data needed.
+                                *
+                                * \param name                          Task's name
+                                * \param computeDuration       A value of the processing amount (in flop) needed to process the task. 
+                                *                                                      If 0, then it cannot be executed with the execute() method.
+                                *                                                      This value has to be >= 0.
+                                * \param messageSize           A value of amount of data (in bytes) needed to transfert this task.
+                                *                                                      If 0, then it cannot be transfered with the get() and put() methods.
+                                *                                                      This value has to be >= 0.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [InvalidArgumentException]      if the parameter computeDuration or messageSize
+                                *                                                                                                              is negative.
+                                *                                                      [NullPointerException]          if the parameter name is NULL.
+                                *
+                                *                                                      [MsgException]                          if a internal exception occurs.
+                                */
+                               Task(const char* name, double computeDuration, double messageSize)
+                               throw (InvalidArgumentException, NullPointerException);
+                               
+                               /*! \Constructs an new parallel task with the specified processing amount and amount for each host
+                            * implied.
+                            *
+                            * \param name                              The name of the parallel task.
+                            * \param hosts                             The list of hosts implied by the parallel task.
+                            * \param computeDurations  The amount of operations to be performed by each host of \a hosts.
+                            * \param messageSizes              A matrix describing the amount of data to exchange between hosts.
+                            * \hostCount                               The number of hosts implied in the parallel task.
+                            * 
+                            * \exception                               If this method fails, it throws one of the exceptions described below:
+                            *
+                            *                                                  [NullPointerException]          if the parameter name is NULL or
+                            *                                                                                                          if the parameter computeDurations is NULL or
+                            *                                                                                                          if the parameter messageSizes is NULL
+                            *
+                            *                                                  [InvalidArgumentException]      if the parameter hostCount is negative or zero.                                                 
+                            */
+                               Task(const char* name, Host* hosts, double* computeDurations, double* messageSizes, int hostCount)
+                               throw(NullPointerException, InvalidArgumentException);
+                       
+                       
+                               /*! \brief Task::getName() - Gets the names of the task.
+                                *
+                                * \return                                      The name of the task.
+                                */
+                               const char* getName(void) const;
+                       
+                               /*! \brief Task::getSender() - Gets the sender of the task.
+                                *
+                                * \return                                      A reference to the sender of the task.
+                                */
+                               Process& getSender(void) const;
+                               
+                               /*! \brief Task::getSource() - Gets the source of the task.
+                                * 
+                                * \return                                      A reference to the source of the task.
+                                */
+                               Host& getSource(void) const;
+                               
+                               /*! \brief Task::getComputeDuration() - Get the computing amount of the task.
+                                *
+                                * \return                                      The computing amount of the task.
+                                */
+                       
+                               double getComputeDuration(void) const;
+                               
+                               /*! \brief Task::getRemainingDuration() - Gets the remaining computation.
+                                *
+                                * \return                                      The remining computation of the task.
+                                */
+                               double getRemainingDuration(void) const;
+                       
+                               /*! \brief Task::setPrirority() -  Sets the priority of the computation of the task.
+                        * The priority doesn't affect the transfert rate. For example a
+                        * priority of 2 will make the task receive two times more cpu than
+                        * the other ones.
+                        *
+                        * \param priority                      The new priority of the task.
+                        *
+                        * execption                            If this method fails, it throws the exception described below:
+                        *
+                        *                                                      [InvalidArgumentException]      if the parameter priority is negative.
+                        */
+                               void setPriority(double priority)
+                               throw(InvalidArgumentException);
+                               
+                               /*! \brief Task::get() - Gets a task from the specified channel of the host of the current process.
+                                *
+                                * \param channel                       The channel number to get the task.
+                                *
+                                * \return                                      If successful the method returns the task. Otherwise the method throws one
+                                *                                                      of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the channel parameter is negative.
+                                *                                      
+                                *                                                      [MsgException]                          if an internal excpetion occurs.
+                                */
+                               static Task* get(int channel) 
+                               throw(InvalidArgumentException, MsgException);
+
+                               /*! \brief      Task::get() - Gets a task from the given channel number of the given host.      
+                                *
+                                * \param channel                       The channel number.
+                                * \param rHost                         A reference of the host owning the channel.
+                                *
+                                * \return                                      If successful, the method returns the task. Otherwise the method
+                                *                                                      throw one of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the channel number is negative.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               static Task* get(int channel, const Host& rHost) 
+                               throw(InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::get() - Gets a task from the specified channel of the specified host
+                                *  (waiting at most given time).
+                                *
+                                * \param channel                       The channel number.
+                                * \param timeout                       The timeout value.
+                                * \param rHost                         A reference to the host owning the channel.
+                                *
+                                * \return                                      If successful, the method returns the task. Otherwise the method returns
+                                *                                                      one of the exceptions described below:
+                                *
+                                * \exception                           [InvalidArgumentException]      if the channel number is negative or
+                                *                                                                                                              if the timeout value is negative and 
+                                *                                                                                                              different than -1.0.
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               static Task* get(int channel, double timeout, const Host& rHost) 
+                               throw(InvalidArgumentException, MsgException);  
+                               
+                               /*! \brief Task::probe() - Probes whether there is a waiting task on the given channel of local host.
+                                *
+                                * \param channel                       The channel number.
+                                *
+                                * \return                                      If there is a waiting task on the channel the method returns 1. Otherwise
+                                *                                                      the method returns 0.
+                                *
+                                * \exception                           If this method fails, it throws the exception described below:
+                                *
+                                *                                                      [InvalidArgumentException]      if the parameter channel is negative.
+                                */
+                               static int probe(int channel)
+                               throw(InvalidArgumentException);
+                               
+                               /*! \brief Task::probe() - Counts tasks waiting on the given channel of local host and sent by given host.
+                                *
+                                * \param channel                       The channel id.
+                                * \param rHost                         A reference to the host that has sent the task.
+                                *
+                                * \return                                      The number of tasks.
+                                *
+                                * \exception                           [InvalidArgumentException]      if the parameter channel is negative.
+                                */
+                               static int probe(int channel, const Host& rHost)
+                               throw(InvalidArgumentException);
+                               
+                               /*! \brief Task::execute() - This method executes a task on the location on which the
+                                * process is running.
+                                *
+                                * \exception                           If this method fails, it returns the exception described below:
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void execute(void) 
+                               throw(MsgException);
+                               
+                               /*! \brief Task::cancel() - This method cancels a task.
+                                *
+                                * \exception                           If this method fails, it returns the exception described below:
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void cancel(void) 
+                               throw(MsgException);
+                       
+                               /*! \brief Task::send() - Send the task on the mailbox identified by the default alias.
+                                *
+                                * \exception                           If this method failed, it returns one of the exceptions described
+                                *                                                      below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void send(void) 
+                               throw(BadAllocException, MsgException);
+                               
+                               /*! \brief Task::send() - Send the task on the mailbox identified by the given alias.
+                                *
+                                * \param alias                         The alias of the mailbox where to send the task.
+                                *
+                                * \exception                           If this method failed, it returns one of the exceptions described
+                                *                                                      below:
+                                *
+                                *                                                      [NullPointerException]          if there parameter alias is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */ 
+                               void send(const char* alias) 
+                               throw(NullPointerException, MsgException);
+                               
+                               /*! \brief Task::send() - Send the task on the mailbox identified by the default alias
+                                * (waiting at most given time).
+                                *
+                                * \param timeout                       The timeout value.
+                                *
+                                * \exception                           If this method failed, it returns one of the exceptions described
+                                *                                                      below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [InvalidArgumentException]      if the timeout value is negative or different -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void send(double timeout) 
+                               throw(BadAllocException, InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::send() - Send the task on the mailbox identified by a given alias
+                                * (waiting at most given time).
+                                *
+                                * \param alias                         The alias of the mailbox where to send the task.
+                                * \param timeout                       The timeout value.
+                                *
+                                * \exception                           If this method failed, it returns one of the exceptions described
+                                *                                                      below:
+                                *
+                                *                                                      [NullPointerException]          if alias parameter is NULL.
+                                *
+                                *                                                      [InvalidArgumentException]      if the timeout value is negative or different -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void send(const char* alias, double timeout) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the default alias.
+                                * (capping the emision rate to maxrate).
+                                *
+                                * \param maxRate                       The maximum rate value.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [InvalidArgumentException]      if the parameter maxRate is negative and different
+                                *                                                                                                              than -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void sendBounded(double maxRate) 
+                               throw(BadAllocException, InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::sendBounded() - Sends the task on the mailbox identified by the given alias.
+                                * (capping the emision rate to maxrate).
+                                *
+                                *\ param alias                         The alias of the mailbox where to send the task.
+                                * \param maxRate                       The maximum rate value.
+                                *
+                                * \exception                           If this method failed, it throws one of the exceptions described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [InvalidArgumentException]      if the parameter maxRate is negative and different
+                                *                                                                                                              than -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               void sendBounded(const char* alias, double maxRate) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                               
+                               
+                               /*! \brief Task::receive() - Receives a task from the mailbox identified by the default alias (located
+                                * on the local host).
+                                *
+                                * \return                                      A reference to the task.
+                                *
+                                * \exception                           If this method failed, it throws one of the exception described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               /*static Task& receive(void) 
+                               throw(BadAllocException, MsgException);*/
+
+                               static Task* receive(void) 
+                               throw(BadAllocException, MsgException);
+                               
+                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located
+                                * on the local host).
+                                *
+                                * \alias                                       The alias of the mailbox.
+                                *
+                                * \return                                      A reference to the task.
+                                *
+                                * \exception                           If this method failed, it throws one of the exception described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               /*static Task& receive(const char* alias) 
+                               throw(NullPointerException, MsgException);*/
+                               static Task* receive(const char* alias) 
+                               throw(NullPointerException, MsgException);
+                               
+                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias (located
+                                * on the local host and waiting at most given time).
+                                *
+                                * \alias                                       The alias of the mailbox.
+                                * \timeout                                     The timeout value.
+                                *
+                                * \return                                      A reference to the task.
+                                *
+                                * \exception                           If this method failed, it throws one of the exception described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [InvalidArgumentException]      if the timeout value is negatif and different than
+                                *                                                                                                              -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               static Task* receive(const char* alias, double timeout) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located
+                                * on the given host.
+                                *
+                                * \alias                                       The alias of the mailbox.
+                                * \rHost                                       The location of the mailbox.
+                                *
+                                * \return                                      A reference to the task.
+                                *
+                                * \exception                           If this method failed, it throws one of the exception described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               static Task* receive(const char* alias, const Host& rHost) 
+                               throw(NullPointerException, MsgException);
+                               
+                               /*! \brief Task::receive() - Receives a task from the mailbox identified by a given alias located
+                                * on the given host (and waiting at most given time).
+                                *
+                                * \alias                                       The alias of the mailbox.
+                                * \timeout                                     The timeout value.
+                                * \rHost                                       The location of the mailbox.
+                                *
+                                * \return                                      A reference to the task.
+                                *
+                                * \exception                           If this method failed, it throws one of the exception described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                *
+                                *                                                      [InvalidArgumentException]      if the timeout value is negatif and different than
+                                *                                                                                                              -1.0.
+                                *
+                                *                                                      [MsgException]                          if an internal exception occurs.
+                                */
+                               static Task* receive(const char* alias, double timeout, const Host& rHost) 
+                               throw(NullPointerException, InvalidArgumentException, MsgException);
+                               
+                               /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox 
+                                * identified by the default alias of local host.
+                                *
+                                * \return                                      If there is a waiting task on the mailbox the method returns true.
+                                *                                                      Otherwise the method returns false.
+                                *
+                                * \exception                           If this method fails, it throws one of the exceptions described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default alias.
+                                */
+                               static int listen(void) 
+                               throw(BadAllocException);
+                               
+                               /*! \brief Task::listen() - Listen whether there is a waiting task on the mailbox 
+                                * identified by the given alias of local host.
+                                *
+                                * \param alias                         The alias of the mailbox.
+                                *
+                                * \return                                      If there is a waiting task on the mailbox the method returns 1.
+                                *                                                      Otherwise the method returns 0.
+                                *
+                                * \exception                           If this method fails, it throws one of the exceptions described below:
+                                *
+                                *                                                      [NullPointerException]          if the parameter alias is NULL.
+                                */
+                               static int listen(const char* alias) 
+                               throw(NullPointerException);
+                               
+                               /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox 
+                                * identified by the default alias, and who sent it.
+                                *
+                                * \return                                      If there is a pending communication on the mailbox, the method returns
+                                *                                                      the PID of it sender. Otherwise the method returns -1.
+                                *
+                                * \exception                           If this method fails, it throws the exception described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default
+                                *                                                                                                              alias.
+                                */
+                               static int listenFrom(void) 
+                               throw(BadAllocException);
+                               
+                               /*! \brief Task::listenFrom() - Tests whether there is a pending communication on the mailbox 
+                                * identified by the specified alias, and who sent it.
+                                *
+                                * \alias                                       The alias of the mailbox.
+                                *
+                                * \return                                      If there is a pending communication on the mailbox, the method returns
+                                *                                                      the PID of it sender. Otherwise the method returns -1.
+                                *
+                                * \exception                           If this method fails, it throws the exception described below:
+                                *
+                                *                                                      [NullPointerException]          if the alias parameter is NULL.
+                                */
+                               static int listenFrom(const char* alias) 
+                               throw(NullPointerException);
+                               
+                               /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox 
+                                * identified by the default alias and located on the host of the current process, and who sent it.
+                                *
+                                * \param rHost                         The location of the mailbox.
+                                *
+                                * \return                                      If there is a pending communication on the mailbox, the method returns
+                                *                                                      the PID of it sender. Otherwise the method returns -1.
+                                *
+                                * \exception                           If this method fails, it throws the exception described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default
+                                *                                                                                                              alias.
+                                */
+                               static int listenFromHost(const Host& rHost) 
+                               throw(BadAllocException);
+                               
+                               /*! \brief Task::listenFromHost() - Tests whether there is a pending communication on the mailbox 
+                                * identified by the default alias and located on the host of the current process, and who sent it.
+                                *
+                                * \param rHost                         The location of the mailbox.
+                                *
+                                * \return                                      If there is a pending communication on the mailbox, the method returns
+                                *                                                      the PID of it sender. Otherwise the method returns -1.
+                                *
+                                * \exception                           If this method fails, it throws the exception described below:
+                                *
+                                *                                                      [BadAllocException]                     if there is not enough memory to build the default
+                                *                                                                                                              alias.
+                                */
+                               static int listenFromHost(const char* alias, const Host& rHost) 
+                               throw(NullPointerException);
+
+                               virtual const Task& operator= (const Task& rTask);
+                       
+                       protected:
+                               
+                               // Attributes.
+                               
+                               m_task_t nativeTask;    // the native MSG task.
+               };
+       
+       } // namespace Msg 
+} // namespace SimGrid
+
+typedef Task* TaskPtr;
+
+#endif // §MSG_TASK_HPP
+