Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Use pointers instead references.
authorcherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 8 Jul 2008 08:51:27 +0000 (08:51 +0000)
committercherierm <cherierm@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Tue, 8 Jul 2008 08:51:27 +0000 (08:51 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5856 48e7efb5-ca39-0410-a469-dd3cf9ba447f

39 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/Process.cxx
src/cxx/Process.hpp
src/cxx/ProcessNotFoundException.cxx
src/cxx/ProcessNotFoundException.hpp
src/cxx/Simulation.cxx
src/cxx/Simulation.hpp
src/cxx/Task.cxx
src/cxx/Task.hpp

index e326494..ea249e6 100644 (file)
  \r
  /* Application member functions implementation.\r
   */  \r
-  \r
-#include <Application.hpp>\r
-\r
 \r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\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
@@ -195,4 +190,7 @@ namespace SimGrid
                        return *this;\r
                }\r
        } // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
+\r
+\r
index 7efe7a2..c281870 100644 (file)
        #error Application.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
-#include <Config.hpp>\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
-               class NullPointerException;\r
-               class FileNotFoundException;\r
-               class LogicException;\r
-               class MsgException;\r
-\r
                // Application wrapper class declaration.\r
                class SIMGRIDX_EXPORT Application\r
                {\r
@@ -149,4 +147,5 @@ namespace SimGrid
        } // namespace Msg\r
 } // namespace SimGrid\r
 \r
-#endif // !MSG_APPLICATION_HPP
\ No newline at end of file
+#endif // !MSG_APPLICATION_HPP\r
+\r
index 9be8907..3b48213 100644 (file)
  /* ApplicationHandler member functions implementation.\r
   */  \r
 \r
-#include <ApplicationHandler.hpp>\r
 \r
 #include <Object.hpp>\r
-#include <ClassNotFoundException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <Host.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
@@ -107,7 +110,12 @@ namespace SimGrid
                        this->properties = NULL; // TODO instanciate the dictionary\r
                        this->hostName = NULL;\r
                        this->function = NULL;\r
-               }      \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
@@ -178,4 +186,5 @@ namespace SimGrid
                }\r
 \r
        } // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
index 6c3819b..df91691 100644 (file)
 #include <xbt/dict.h>\r
 #include <xbt/dynar.h>\r
 \r
-#include <Config.hpp>\r
+#include <ClassNotFoundException.hpp>\r
+#include <HostNotFoundException.hpp>\r
 \r
 namespace SimGrid\r
 {\r
        namespace Msg\r
        {\r
-\r
-               class ClassNotFoundException;\r
-               class HostNotFoundException;\r
                class Process;\r
 \r
                // Declaration of the class ApplicationHandler (Singleton).\r
                class SIMGRIDX_EXPORT ApplicationHandler\r
                {\r
-                       friend Process;\r
+                       //friend Process;\r
 \r
                public:\r
 \r
@@ -66,7 +64,7 @@ namespace SimGrid
                                        ProcessFactory(const ProcessFactory& rProcessFactory);\r
                                        \r
                                        // Destructor.\r
-                                       virtual ~ProcessFactory(){}\r
+                                       virtual ~ProcessFactory();\r
                                        \r
                                        // Set the identity of the current process.\r
                                        void setProcessIdentity(const char* hostName, const char* function);\r
@@ -134,4 +132,4 @@ namespace SimGrid
 } // namespace SimGrid\r
 \r
 #endif // !MSG_APPLICATION_HANDLER_HPP\r
-       
\ No newline at end of file
+\r
index d650141..265f5de 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index ac4039f..b5726ee 100644 (file)
 #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
@@ -62,3 +66,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_BADALLOCEXCEPTION_HPP\r
+\r
index e61bf53..236ba2a 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index 84b4317..bc90970 100644 (file)
 #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
@@ -62,3 +66,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
+\r
index 837946e..0fc1e6f 100644 (file)
@@ -1,15 +1,34 @@
+\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)\r
+               #if defined(WIN32) && !defined(__MINGW32__)\r
                        #if defined(SIMGRIDX_EXPORTS)\r
                                #define SIMGRIDX_EXPORT __declspec(dllexport)\r
                        #else\r
-                               #define SIMGRIDX_EXPORT \r
+                               #define SIMGRIDX_EXPORT __declspec(dllimport)\r
                        #endif\r
                #else\r
                        #define SIMGRIDX_EXPORT\r
@@ -17,4 +36,9 @@ namespace SimGrid
        } // namespace Msg\r
 } // namespace SimGrid\r
 \r
-#endif // MSG_CONFIG_HPP
\ No newline at end of file
+#ifndef WIN32\r
+#define _strdup strdup\r
+#endif\r
+\r
+#endif // MSG_CONFIG_HPP\r
+\r
index 806e868..71e0acf 100644 (file)
   \r
 #include <Environment.hpp>\r
 \r
-#include <NullPointerException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <LogicException.hpp>\r
-#include <MsgException.hpp>\r
-\r
 #include <stdlib.h>\r
 \r
 #include <sys/types.h>\r
@@ -49,7 +43,7 @@ namespace SimGrid
                }\r
                \r
                Environment::Environment(const char* file)\r
-               throw(NullPointerException, InvalidArgumentException)\r
+               throw(NullPointerException, FileNotFoundException)\r
                {\r
                        // check parameters\r
                        \r
@@ -59,7 +53,7 @@ namespace SimGrid
                        struct stat statBuf = {0};\r
                                \r
                        if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw InvalidArgumentException("file (file not found)");\r
+                               throw FileNotFoundException("file (file not found)");\r
                                \r
                        this->file = file;\r
                        this->loaded = false;\r
@@ -161,4 +155,5 @@ namespace SimGrid
                }\r
                                \r
        } // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
index fb2a17b..89f6e48 100644 (file)
        #error Environment.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
-#include <Config.hpp>\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
@@ -145,4 +149,5 @@ namespace SimGrid
 } // namespace SimGrid\r
 \r
 \r
-#endif // !MSG_ENVIRONMENT_HPP
\ No newline at end of file
+#endif // !MSG_ENVIRONMENT_HPP\r
+\r
index 5e54f88..94ae26e 100644 (file)
@@ -1,3 +1,19 @@
+/*\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
index c520ae6..1b1a8ee 100644 (file)
 #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
@@ -61,3 +65,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_EXCEPTION_HPP\r
+\r
index d995190..297d60c 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index 639accd..a7ddfbc 100644 (file)
 #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
@@ -62,3 +66,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_MSGEXCEPTION_HPP\r
+\r
index db4722b..18997ea 100644 (file)
  */\r
  \r
  /* Host class member functions implementation.\r
-  */  \r
-#include <Host.hpp>\r
-\r
-#include <InvalidArgumentException.hpp>\r
-#include <BadAllocException.hpp>\r
-#include <HostNotFoundException.hpp>\r
-#include <MsgException.hpp>\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
@@ -53,11 +49,11 @@ namespace SimGrid
                \r
                \r
                Host& Host::getByName(const char* hostName)\r
-               throw(HostNotFoundException, InvalidArgumentException, BadAllocException)\r
+               throw(HostNotFoundException, NullPointerException, BadAllocException)\r
                {\r
                        // check the parameters\r
                        if(!hostName)\r
-                               throw InvalidArgumentException("hostName");\r
+                               throw NullPointerException("hostName");\r
                                \r
                        m_host_t nativeHost = NULL;     // native host.\r
                        Host* host = NULL;                      // wrapper host.\r
@@ -193,17 +189,6 @@ namespace SimGrid
                        return SIMIX_host_get_state(nativeHost->simdata->smx_host);\r
                }\r
                \r
-               void Host::put(int channel, const Task& rTask) \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(rTask.nativeTask, nativeHost, channel , -1.0))\r
-                               throw MsgException("MSG_task_put_with_timeout() failed");\r
-               } \r
-\r
                void Host::put(int channel, Task* task) \r
                throw(MsgException, InvalidArgumentException)\r
                {\r
@@ -214,8 +199,8 @@ namespace SimGrid
                        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, const Task& rTask, double timeout) \r
+\r
+               void Host::put(int channel, Task* task, double timeout) \r
                throw(MsgException, InvalidArgumentException) \r
                {\r
                        // checks the parameters\r
@@ -226,11 +211,11 @@ namespace SimGrid
                                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(rTask.nativeTask, nativeHost, channel , timeout))\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, const Task& rTask, double maxRate) \r
+               void Host::putBounded(int channel, Task* task, double maxRate) \r
                throw(MsgException, InvalidArgumentException)\r
                {\r
                    // checks the parameters\r
@@ -240,12 +225,12 @@ namespace SimGrid
                        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(rTask.nativeTask, nativeHost, channel, maxRate))\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(const Task& rTask) \r
-               throw(MsgException)  \r
+               void Host::send(Task* task) \r
+               throw(MsgException, BadAllocException)  \r
                {       \r
                        MSG_error_t rv;\r
                        \r
@@ -256,7 +241,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
-                       rv = MSG_task_send_with_timeout(rTask.nativeTask, alias, -1.0);\r
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, -1.0);\r
                        \r
                        free(alias);\r
                        \r
@@ -264,18 +249,18 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                } \r
                \r
-               void Host::send(const char* alias, const Task& rTask) \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(rTask.nativeTask, alias, -1.0))\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(const Task& rTask, double timeout) \r
+               void Host::send(Task* task, double timeout) \r
                throw(InvalidArgumentException, BadAllocException, MsgException) \r
                {\r
                        // check the parameters\r
@@ -292,7 +277,7 @@ namespace SimGrid
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
                                \r
-                       rv = MSG_task_send_with_timeout(rTask.nativeTask, alias, timeout);\r
+                       rv = MSG_task_send_with_timeout(task->nativeTask, alias, timeout);\r
                        \r
                        free(alias);\r
                        \r
@@ -300,7 +285,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout() failed");\r
                }\r
                \r
-               void Host::send(const char* alias, const Task& rTask, double timeout) \r
+               void Host::send(const char* alias, Task* task, double timeout) \r
                throw(InvalidArgumentException, MsgException) \r
                {\r
                        // check the parameter\r
@@ -311,12 +296,12 @@ namespace SimGrid
                        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(rTask.nativeTask, alias, timeout))\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(const Task& rTask, double maxRate) \r
+               void Host::sendBounded(Task* task, double maxRate) \r
                throw(InvalidArgumentException, BadAllocException, MsgException) \r
                {\r
                        if(maxRate < 0 && maxRate != -1.0)\r
@@ -331,7 +316,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", this->getName(),Process::currentProcess().getName());\r
                                \r
-                       rv = MSG_task_send_bounded(rTask.nativeTask, alias, maxRate);\r
+                       rv = MSG_task_send_bounded(task->nativeTask, alias, maxRate);\r
                        \r
                        free(alias);\r
                        \r
@@ -339,7 +324,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_bounded() failed");\r
                }  \r
                \r
-               void Host::sendBounded(const char* alias, const Task& rTask, double maxRate) \r
+               void Host::sendBounded(const char* alias, Task* task, double maxRate) \r
                throw(InvalidArgumentException, MsgException) \r
                {\r
                        // check the parameters\r
@@ -349,9 +334,10 @@ namespace SimGrid
                        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(rTask.nativeTask, alias, maxRate))\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
\ No newline at end of file
+} // namespace SimGrid\r
+\r
index 881bebb..1c18f0d 100644 (file)
@@ -54,7 +54,11 @@ catch(HostNotFoundException e)
 \r
 #include <msg/datatypes.h>\r
 \r
-#include <Config.hpp>\r
+#include <InvalidArgumentException.hpp>\r
+#include <BadAllocException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <MsgException.hpp>\r
+\r
 \r
 \r
 // namespace SimGrid::Msg\r
@@ -62,19 +66,14 @@ namespace SimGrid
 {\r
        namespace Msg\r
        {\r
-               class InvalidArgumentException;\r
-               class BadAllocException;\r
-               class HostNotFoundException;\r
-               class MsgException;\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 Process;\r
-                       friend Task;\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
@@ -112,7 +111,7 @@ namespace SimGrid
                                 *                                      [BadAllocException]                     if there is not enough memory to allocate the host.\r
                                 */ \r
                                static Host& getByName(const char* hostName)\r
-                               throw(HostNotFoundException, InvalidArgumentException, BadAllocException);\r
+                               throw(HostNotFoundException, NullPointerException, BadAllocException);\r
                                \r
                                /*! \brief Host::getNumber() - returns the number of the installed hosts.\r
                                 *\r
@@ -128,8 +127,7 @@ namespace SimGrid
                                 *\r
                                 * \see                         Process::currentProcess().\r
                                 */\r
-                               static Host& currentHost(void)\r
-                               throw(InvalidArgumentException, BadAllocException);\r
+                               static Host& currentHost(void);\r
                                \r
                                /*! \brief Host::all() - This static method retrieves all of the hosts of the installed platform.\r
                                 *\r
@@ -195,7 +193,8 @@ namespace SimGrid
                                 *      delete[] ar;\r
                                 *\r
                                 */ \r
-                               static void all(Host*** hosts /*in|out*/, int* len /*in|out*/);\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
@@ -257,10 +256,7 @@ namespace SimGrid
                                 *                                      [InvalidArgumentException]      if the value of the channel specified as\r
                                 *                                                                                              parameter is negative.\r
                                 */\r
-                               void put(int channel, const Task& rTask)\r
-                               throw(MsgException, InvalidArgumentException);\r
-\r
-                               void Host::put(int channel, Task* task) \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
@@ -280,7 +276,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                      To specify no timeout set the timeout value with -1.0.\r
                                 */\r
-                               void put(int channel, const Task& rTask, double timeout) \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
@@ -300,7 +296,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                      To specify no rate set the maxRate parameter value with -1.0.\r
                                 */\r
-                               void putBounded(int channel, const Task& rTask, double maxRate) \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
@@ -314,8 +310,8 @@ namespace SimGrid
                                 *                                                                                              the default alias variable.\r
                                 *                                      [MsgException]                          if an internal error occurs.\r
                                 */\r
-                               void send(const Task& rTask) \r
-                               throw(BadAllocException, MsgException);\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
@@ -330,8 +326,8 @@ namespace SimGrid
                                 *                                                                                              the default alias variable.\r
                                 *                                      [MsgException]                          if an internal error occurs.\r
                                 */\r
-                               void send(const char* alias, const Task& rTask) \r
-                               throw(InvalidArgumentException, BadAllocException, MsgException);\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
@@ -352,8 +348,8 @@ namespace SimGrid
                                 *                                      version of this method.\r
                                 *\r
                                 */\r
-                               void send(const Task& rTask, double timeout) \r
-                               throw(MsgException);\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
@@ -373,7 +369,7 @@ namespace SimGrid
                                 *                                      version of this method.\r
                                 *\r
                                 */\r
-                               void send(const char* alias, const Task& rTask, double timeout) \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
@@ -394,7 +390,7 @@ namespace SimGrid
                                 * \remark                      To specify no rate set its value with -1.0.\r
                                 *\r
                                 */\r
-                               void sendBounded(const Task& rTask, double maxRate) \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
@@ -414,7 +410,7 @@ namespace SimGrid
                                 * \remark                      To specify no rate set its value with -1.0.\r
                                 *\r
                                 */\r
-                               void sendBounded(const char* alias, const Task& rTask, double maxRate) \r
+                               void sendBounded(const char* alias, Task* task, double maxRate) \r
                                throw(InvalidArgumentException, MsgException);\r
                        \r
                        protected:\r
@@ -440,4 +436,4 @@ namespace SimGrid
        } // namespace Msg\r
 } // namespace SimGrid\r
 \r
-#endif // !MSG_HOST_HPP
\ No newline at end of file
+#endif // !MSG_HOST_HPP\r
index 8f0c476..c2b9211 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index 17f4603..a810d04 100644 (file)
 #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
@@ -62,3 +66,5 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
+\r
+\r
index 2500b83..dc44244 100644 (file)
@@ -1,3 +1,19 @@
+/*\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
index 6c72f8e..fc4b201 100644 (file)
 #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
@@ -62,3 +66,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
+\r
index 3cd0390..e1594f2 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index a39d7b9..a357439 100644 (file)
 #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
@@ -62,3 +66,5 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
+\r
+\r
index 20521cd..443ac6b 100644 (file)
  /* Msg functions implementation.\r
   */  \r
 \r
-#include <MsgException.hpp>\r
+\r
 #include <Msg.hpp>\r
 \r
 #include <msg/msg.h>\r
+#include <msg/private.h>\r
 #include <stdio.h>\r
 \r
-// XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(SimGridX);\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
-                       MSG_set_channel_number(10); // FIXME: this should not be fixed statically \r
+\r
+                       if(getMaxChannelNumber() == 0)\r
+                               setMaxChannelNumber(SIMGRIDX_DEFAULT_CHANNEL_NUMBER);\r
                }       \r
                \r
                void finalize(void)\r
@@ -38,6 +43,7 @@ namespace SimGrid
                {\r
                        if(MSG_OK != MSG_clean())\r
                                throw MsgException("MSG_clean() failed");\r
+                       \r
                }\r
                \r
                void info(const char* s)\r
@@ -51,6 +57,24 @@ namespace SimGrid
                        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
\ No newline at end of file
+} // namespace SimGrid\r
+\r
index 3e26478..2ed2f96 100644 (file)
        #error Msg.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
-#include <Config.hpp>\r
+#include <MsgException.hpp>\r
+#include <InvalidArgumentException.hpp>\r
+#include <LogicException.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
@@ -53,8 +58,14 @@ namespace SimGrid
                 * \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
\ No newline at end of file
+#endif // !MSG_HPP\r
index cd18308..891588f 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index a8f576b..7d978f3 100644 (file)
@@ -62,3 +62,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_MSGEXCEPTION_HPP\r
+\r
index e672c66..79aac80 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index a7ce0ea..659e3ad 100644 (file)
 #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
@@ -62,3 +66,4 @@ namespace SimGrid
 \r
 \r
 #endif // !MSG_NULLPOINTEREXCEPTION_HPP\r
+\r
index 3d649a1..5d91680 100644 (file)
@@ -1,10 +1,28 @@
+/*\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
-DeclaringClasses* DeclaringClass::declaringClasses = NULL;\r
 \r
 \r
+DeclaringClasses* DeclaringClass::declaringClasses = NULL;\r
+\r
 namespace SimGrid\r
 {\r
        namespace Msg\r
index 660f4eb..d44ff2b 100644 (file)
@@ -1,4 +1,16 @@
-\r
+/*\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
@@ -27,7 +39,7 @@ namespace SimGrid
                public: \\r
                        static Class class##class_name; \\r
                        virtual Class* getClass() const; \\r
-                       static Object*  createObject(); \\r
+                       static Object*  createObject() \\r
 \r
                // The runtime class implementation.    \r
                #define MSG_IMPLEMENT_CLASS(class_name, base_class_name, pfn,class_init) \\r
@@ -227,6 +239,8 @@ namespace SimGrid
                        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
index bceac32..856ce5e 100644 (file)
@@ -1,12 +1,19 @@
-#include <Process.hpp>\r
+/*\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 <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
+#include <Process.hpp>\r
 \r
 \r
 #include <ApplicationHandler.hpp>\r
@@ -21,6 +28,7 @@
 #include <msg/mailbox.h>\r
 \r
 \r
+\r
 namespace SimGrid\r
 {\r
        namespace Msg\r
@@ -35,7 +43,7 @@ namespace SimGrid
                }\r
                \r
                Process::Process(const char* hostName, const char* name)\r
-               throw(InvalidArgumentException, HostNotFoundException)\r
+               throw(NullPointerException, HostNotFoundException, BadAllocException)\r
                {\r
                        // check the parameters\r
                        \r
@@ -81,7 +89,7 @@ namespace SimGrid
                }\r
                \r
                Process::Process(const char* hostName, const char* name, int argc, char** argv)\r
-               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException)\r
+               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException)\r
                {\r
                        // check the parameters\r
                        \r
@@ -223,7 +231,7 @@ namespace SimGrid
                        \r
                }\r
                \r
-               void Process::putTask(const Host& rHost, int channel, const Task& rTask)\r
+               void Process::putTask(const Host& rHost, int channel, Task* task)\r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -231,11 +239,11 @@ namespace SimGrid
                        if(channel < 0)\r
                                throw InvalidArgumentException("channel (must not be negative)");\r
                                \r
-                       if(MSG_OK != MSG_task_put_with_timeout(rTask.nativeTask, rHost.nativeHost, channel, -1.0))\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, const Task& rTask, double timeout) \r
+               void Process::putTask(const Host& rHost, int channel, Task* task, double timeout) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -245,11 +253,11 @@ namespace SimGrid
                        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(rTask.nativeTask, rHost.nativeHost, channel, timeout))\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
+               Task* Process::getTask(int channel) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -262,10 +270,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Process::getTask(int channel, double timeout) \r
+               Task* Process::getTask(int channel, double timeout) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -280,10 +288,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Process::getTask(int channel, const Host& rHost) \r
+               Task* Process::getTask(int channel, const Host& rHost) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -295,10 +303,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Process::getTask(int channel, double timeout, const Host& rHost)\r
+               Task* Process::getTask(int channel, double timeout, const Host& rHost)\r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -313,10 +321,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               void Process::sendTask(const char* alias, const Task& rTask, double timeout) \r
+               void Process::sendTask(const char* alias, Task* task, double timeout) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -327,12 +335,12 @@ namespace SimGrid
                        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(rTask.nativeTask, alias ,timeout))\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, const Task& rTask) \r
+               void Process::sendTask(const char* alias, Task* task) \r
                throw(NullPointerException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -340,11 +348,11 @@ namespace SimGrid
                        if(!alias)\r
                                throw NullPointerException("alias");\r
                                \r
-                       if(MSG_OK != MSG_task_send_with_timeout(rTask.nativeTask, alias ,-1.0))\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(const Task& rTask) \r
+               void Process::sendTask(Task* task) \r
                throw(BadAllocException, MsgException)\r
                {\r
                        char* alias = (char*)calloc( strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
@@ -354,7 +362,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
                        \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(rTask.nativeTask, alias ,-1.0);\r
+                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,-1.0);\r
                        \r
                        free(alias);\r
                        \r
@@ -362,7 +370,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout()");\r
                }\r
                \r
-               void Process::sendTask(const Task& rTask, double timeout) \r
+               void Process::sendTask(Task* task, double timeout) \r
                throw(BadAllocException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -377,7 +385,7 @@ namespace SimGrid
                                \r
                        sprintf(alias,"%s:%s", Host::currentHost().getName() ,nativeProcess->name);\r
                        \r
-                       MSG_error_t rv = MSG_task_send_with_timeout(rTask.nativeTask, alias ,timeout);\r
+                       MSG_error_t rv = MSG_task_send_with_timeout(task->nativeTask, alias ,timeout);\r
                        \r
                        free(alias);\r
                        \r
@@ -385,7 +393,7 @@ namespace SimGrid
                                throw MsgException("MSG_task_send_with_timeout()");     \r
                }\r
                \r
-               Task& Process::receiveTask(const char* alias) \r
+               Task* Process::receiveTask(const char* alias) \r
                throw(NullPointerException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -398,11 +406,11 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(void) \r
+               Task* Process::receiveTask(void) \r
                throw(BadAllocException, MsgException)\r
                {\r
                        \r
@@ -422,11 +430,11 @@ namespace SimGrid
                        if(MSG_OK !=  rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");    \r
                \r
-                       return (*((Task*)nativeTask->data));\r
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(const char* alias, double timeout) \r
+               Task* Process::receiveTask(const char* alias, double timeout) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -442,11 +450,11 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(double timeout) \r
+               Task* Process::receiveTask(double timeout) \r
                throw(InvalidArgumentException, BadAllocException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -471,11 +479,11 @@ namespace SimGrid
                        if(MSG_OK !=  rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");    \r
                \r
-                       return (*((Task*)nativeTask->data));\r
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(const char* alias, double timeout, const Host& rHost) \r
+               Task* Process::receiveTask(const char* alias, double timeout, const Host& rHost) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -491,11 +499,11 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(double timeout, const Host& rHost) \r
+               Task* Process::receiveTask(double timeout, const Host& rHost) \r
                throw(BadAllocException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -519,11 +527,11 @@ namespace SimGrid
                        if(MSG_OK !=  rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");\r
                \r
-                       return (*((Task*)nativeTask->data));\r
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                \r
-               Task& Process::receiveTask(const char* alias, const Host& rHost) \r
+               Task* Process::receiveTask(const char* alias, const Host& rHost) \r
                throw(NullPointerException, MsgException)\r
                {\r
                        \r
@@ -537,10 +545,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Process::receiveTask(const Host& rHost) \r
+               Task* Process::receiveTask(const Host& rHost) \r
                throw(BadAllocException, MsgException)\r
                {\r
                        char* alias = (char*)calloc(strlen(Host::currentHost().getName()) + strlen(nativeProcess->name) + 2, sizeof(char));\r
@@ -559,67 +567,8 @@ namespace SimGrid
                        if(MSG_OK !=  rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");\r
                \r
-                       return (*((Task*)nativeTask->data));\r
+                       return (Task*)(nativeTask->data);\r
                }\r
-               \r
-               /*void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
-               throw(HostNotFoundException)\r
-               {\r
-                       smx_process_t nativeCurrentProcess = NULL;\r
-                       \r
-                       // allocate the native process\r
-                       this->nativeProcess = xbt_new0(s_smx_process_t, 1);\r
-                       \r
-                       // allocate the simulation data of the native process\r
-                       smx_simdata_process_t simdata = xbt_new0(s_smx_simdata_process_t, 1);\r
-                       \r
-                       // try to retrieve the host where to createt the process from its name\r
-                       smx_host_t nativeHost = SIMIX_host_get_by_name(rHost.getName());\r
-                       \r
-                       if(!nativeHost)\r
-                               throw HostNotFoundException(rHost.getName());\r
-                       \r
-                       // realloc the list of the argument to add the pointer to this process instance at the end\r
-                       argv = (char**)realloc(argc + 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
-                       // Simulator Data\r
-                       simdata->smx_host = nativeHost;\r
-                       simdata->mutex = NULL;\r
-                       simdata->cond = NULL;\r
-                       simdata->argc = argc;\r
-                       simdata->argv = argv;\r
-                       \r
-                       // create the context of the process.\r
-                       simdata->context = xbt_context_new(name, Process::run, NULL, NULL, simix_global->cleanup_process_function, nativeProcess, simdata->argc, simdata->argv);\r
-                       \r
-                       // Process structure \r
-                       this->nativeProcess->name = xbt_strdup(name);\r
-                       this->nativeProcess->simdata = simdata;\r
-                       \r
-                       // Set process data\r
-                       this->nativeProcess->data = NULL;\r
-                       \r
-                       // Set process properties\r
-                       simdata->properties = NULL;\r
-                       \r
-                       xbt_swag_insert(this->nativeProcess, nativeHost->simdata->process_list);\r
-                       \r
-                       // fix current_process, about which xbt_context_start mocks around \r
-                       nativeCurrentProcess = simix_global->current_process;\r
-                       xbt_context_start(this->nativeProcess->simdata->context);\r
-                       simix_global->current_process = nativeCurrentProcess;\r
-                       \r
-                       xbt_swag_insert(this->nativeProcess, simix_global->process_list);\r
-                       DEBUG2("Inserting %s(%s) in the to_run list", this->nativeProcess->name, nativeHost->name);\r
-                       xbt_swag_insert(this->nativeProcess, simix_global->process_to_run);\r
-               }*/\r
 \r
                void Process::create(const Host& rHost, const char* name, int argc, char** argv)\r
                throw(InvalidArgumentException)\r
@@ -684,9 +633,7 @@ namespace SimGrid
                        \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
+                       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
@@ -698,7 +645,7 @@ namespace SimGrid
                {\r
                        \r
                        // the last argument of the process is the pointer to the process to run\r
-                       // for mor detail see Process::create() method\r
+                       // for more detail see Process::create() method\r
                        return ((Process*)argv[argc])->main(argc, argv);\r
                }\r
 \r
@@ -706,7 +653,18 @@ namespace SimGrid
                {\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
\ No newline at end of file
+} // namespace SimGrid\r
+\r
index bd45c70..5bc46e5 100644 (file)
 #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 NullPointerException;\r
-               class HostNotFoundException;\r
-               class ProcessNotFoundException;\r
-               class InvalidArgumentException;\r
-               class BadAllocException;\r
-               class LogicException;\r
-               class MsgException;\r
-\r
                class ApplicationHandler;\r
                class Host;\r
                class Task;\r
@@ -42,12 +42,12 @@ namespace SimGrid
                // SimGrid::Msg::Process class declaration.\r
                class SIMGRIDX_EXPORT Process : public Object\r
                {\r
-                       \r
-                       friend ApplicationHandler::ProcessFactory;\r
+                       friend class ApplicationHandler::ProcessFactory;\r
                        \r
                        MSG_DECLARE_DYNAMIC(Process);\r
 \r
                        public:\r
+\r
                                // Disable the default constructor.\r
                                Process();\r
                        \r
@@ -65,7 +65,7 @@ namespace SimGrid
                                 *                                              [HostNotFoundException]         if the host is not found.\r
                                 */     \r
                                Process(const char* hostName, const char* name)\r
-                               throw(NullPointerException, HostNotFoundException);\r
+                               throw(NullPointerException, HostNotFoundException, BadAllocException);\r
                        \r
                                /*! \brief Constructs a process from a reference to an host object and its name.\r
                                 *\r
@@ -126,7 +126,7 @@ namespace SimGrid
                                 *                                              [HostNotFoundException]         if the specified host is no found.\r
                                 */\r
                                Process(const char* hostName, const char* name, int argc, char** argv)\r
-                               throw(NullPointerException, HostNotFoundException);\r
+                               throw(NullPointerException, InvalidArgumentException, LogicException, HostNotFoundException, BadAllocException);\r
                        \r
                                /*! \brief Process::killAll() - kill all the running processes of the simulation.\r
                                 *\r
@@ -267,7 +267,7 @@ namespace SimGrid
                                 *\r
                                 *                                              [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               void putTask(const Host& rHost, int channel, const Task& rTask)\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
@@ -282,7 +282,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                              Set the timeout with -1.0 to disable it.\r
                                 */\r
-                               void putTask(const Host& rHost, int channel, const Task& rTask, double timeout) \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
@@ -297,7 +297,7 @@ namespace SimGrid
                                 *\r
                                 *                                              [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& getTask(int channel) \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
@@ -314,7 +314,7 @@ namespace SimGrid
                                 *                                                                                                      zero and different of -1.0.\r
                                 *                                              [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& getTask(int channel, double timeout) \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
@@ -329,7 +329,7 @@ namespace SimGrid
                                 * \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
+                               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
@@ -349,7 +349,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                              Set the timeout with -1.0 to disable it.\r
                                 */\r
-                               Task& getTask(int channel, double timeout, const Host& rHost)\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
@@ -369,7 +369,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                                      Set the timeout with -1.0 to disable it.\r
                                 */\r
-                               void sendTask(const char* alias, const Task& rTask, double timeout) \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
@@ -384,7 +384,7 @@ namespace SimGrid
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 *\r
                                 */\r
-                               void sendTask(const char* alias, const Task& rTask) \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
@@ -398,7 +398,7 @@ namespace SimGrid
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 *\r
                                 */\r
-                               void sendTask(const Task& rTask) \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
@@ -417,7 +417,7 @@ namespace SimGrid
                                 *\r
                                 * \remark                                      set the timeout value with -1.0 to disable it.\r
                                 */\r
-                               void sendTask(const Task& rTask, double timeout) \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
@@ -432,7 +432,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                  if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(const char* alias) \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
@@ -443,7 +443,7 @@ namespace SimGrid
                                 * \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
+                               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
@@ -461,7 +461,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(const char* alias, double timeout) \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
@@ -478,7 +478,7 @@ namespace SimGrid
                                 *                      \r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(double timeout) \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
@@ -497,7 +497,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(const char* alias, double timeout, const Host& rHost) \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
@@ -515,7 +515,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(double timeout, const Host& rHost) \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
@@ -531,7 +531,7 @@ namespace SimGrid
                                 *\r
                                 *                                              [MsgException]                                  if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(const char* alias, const Host& rHost) \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
@@ -546,7 +546,7 @@ namespace SimGrid
                                 *\r
                                 *                                              [MsgException]                                  if an internal exception occurs.\r
                                 */\r
-                               Task& receiveTask(const Host& rHost) \r
+                               Task* receiveTask(const Host& rHost) \r
                                throw(BadAllocException, MsgException);\r
                        \r
                                \r
@@ -564,7 +564,7 @@ namespace SimGrid
                                 *                                              [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(HostNotFoundException);\r
+                               throw(InvalidArgumentException);\r
                                \r
                                /* Process::fromNativeProcess() - Retrieves the process wrapper associated with a native process.\r
                                 *\r
@@ -590,6 +590,16 @@ namespace SimGrid
                                 * \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
@@ -603,4 +613,5 @@ namespace SimGrid
 \r
 } // namespace SimGrid\r
 \r
-#endif // !MSG_PROCESS_HPP
\ No newline at end of file
+#endif // !MSG_PROCESS_HPP\r
+\r
index bae42a3..2da654a 100644 (file)
@@ -1,3 +1,18 @@
+/*\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
index 6e8bc6e..9e29e00 100644 (file)
 #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
index 34ee0fd..0697760 100644 (file)
  /* Simulation member functions implementation.\r
   */  \r
   \r
-#include <Simulation.hpp>\r
 \r
 #include <Application.hpp>\r
 #include <Environment.hpp>\r
 \r
-#include <MsgException.hpp>\r
-#include <FileNotFoundException.hpp>\r
-\r
 #include <Msg.hpp>\r
 \r
+#include <Simulation.hpp>\r
+\r
+\r
 #include <msg/msg.h> \r
 \r
 namespace SimGrid\r
@@ -105,3 +104,5 @@ namespace SimGrid
                }\r
        } // namespace Msg\r
 } // namespace SimGrid\r
+\r
+\r
index de97d90..631cc30 100644 (file)
@@ -19,7 +19,8 @@
        #error Sumulation.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
-#include <Config.hpp>\r
+#include <MsgException.hpp>\r
+#include <FileNotFoundException.hpp>\r
 \r
 namespace SimGrid\r
 {\r
@@ -56,4 +57,5 @@ namespace SimGrid
        } // namespace Msg\r
 } // namespace SimGrid\r
 \r
-#endif // !MSG_SIMULATION_HPP
\ No newline at end of file
+#endif // !MSG_SIMULATION_HPP\r
+\r
index b0c2ccb..93e1c68 100644 (file)
@@ -1,14 +1,23 @@
-#include <Task.hpp>\r
-\r
-#include <MsgException.hpp>\r
-#include <InvalidArgumentException.hpp>\r
-#include <NullPointerException.hpp>\r
-#include <MsgException.hpp>\r
-#include <BadAllocException.hpp>\r
+/*\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
@@ -150,22 +159,6 @@ namespace SimGrid
                                \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) \r
                throw(InvalidArgumentException, MsgException)\r
@@ -183,7 +176,7 @@ namespace SimGrid
                        return ((Task*)(nativeTask->data));\r
                }\r
                \r
-               Task& Task::get(int channel, const Host& rHost) \r
+               Task* Task::get(int channel, const Host& rHost) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -197,10 +190,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::get(int channel, double timeout, const Host& rHost) \r
+               Task* Task::get(int channel, double timeout, const Host& rHost) \r
                throw(InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -217,7 +210,7 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                int Task::probe(int channel)\r
@@ -363,28 +356,6 @@ namespace SimGrid
                        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(void) \r
                throw(BadAllocException, MsgException)\r
@@ -405,24 +376,8 @@ namespace SimGrid
                        if(MSG_OK != rv) \r
                                throw MsgException("MSG_task_receive_ext() failed");\r
                \r
-                       return ((Task*)nativeTask->data);\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) \r
                throw(NullPointerException, MsgException)\r
@@ -437,10 +392,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::receive(const char* alias, double timeout) \r
+               Task* Task::receive(const char* alias, double timeout) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -456,10 +411,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
-               Task& Task::receive(const char* alias, const Host& rHost) \r
+               Task* Task::receive(const char* alias, const Host& rHost) \r
                throw(NullPointerException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -472,10 +427,10 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }       \r
                \r
-               Task& Task::receive(const char* alias, double timeout, const Host& rHost) \r
+               Task* Task::receive(const char* alias, double timeout, const Host& rHost) \r
                throw(NullPointerException, InvalidArgumentException, MsgException)\r
                {\r
                        // check the parameters\r
@@ -492,7 +447,7 @@ namespace SimGrid
                        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
+                       return (Task*)(nativeTask->data);\r
                }\r
                \r
                int Task::listen(void) \r
index a158f4f..e78d9dd 100644 (file)
 \r
 #include <msg/datatypes.h>\r
 \r
-#include <Config.hpp>\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
@@ -30,12 +34,6 @@ namespace SimGrid
 {\r
        namespace Msg\r
        {\r
-               class MsgException;\r
-               class InvalidArgumentException;\r
-               class NullPointerException;\r
-               class MsgException;\r
-               class BadAllocException;\r
-\r
                class Process;\r
                class Host;\r
 \r
@@ -44,39 +42,12 @@ namespace SimGrid
                {\r
                        MSG_DECLARE_DYNAMIC(Task);\r
 \r
-                       friend Process;\r
-                       friend Host;\r
+                       friend class Process;\r
+                       friend class Host;\r
 \r
                        protected:\r
                                // Default constructor.\r
                                Task();\r
-\r
-                       class Ref\r
-                       {\r
-                       public:\r
-                               Ref(Task* task)\r
-                               {\r
-                                       count = 1;\r
-                                       this->task = task;\r
-                               }\r
-\r
-                               virtual ~Ref(){}\r
-\r
-                               void operator++(void){\r
-                                       count++;\r
-                                       \r
-                               }\r
-\r
-                               void operator--(void){\r
-                                       if(--count <= 0)\r
-                                               delete p;\r
-                               }\r
-\r
-                       private:\r
-                               int count;\r
-                               Task* task;\r
-\r
-                       };\r
                                \r
                        public:\r
                                /*! \brief Copy constructor.\r
@@ -191,9 +162,6 @@ namespace SimGrid
                                 *                                      \r
                                 *                                                      [MsgException]                          if an internal excpetion occurs.\r
                                 */\r
-                               /*static Task& get(int channel) \r
-                               throw(InvalidArgumentException, MsgException);*/\r
-\r
                                static Task* get(int channel) \r
                                throw(InvalidArgumentException, MsgException);\r
 \r
@@ -209,7 +177,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               static Task& get(int channel, const Host& rHost) \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
@@ -227,7 +195,7 @@ namespace SimGrid
                                 *                                                                                                              different than -1.0.\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               static Task& get(int channel, double timeout, const Host& rHost) \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
@@ -424,7 +392,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               static Task& receive(const char* alias, double timeout) \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
@@ -441,7 +409,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               static Task& receive(const char* alias, const Host& rHost) \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
@@ -462,7 +430,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               static Task& receive(const char* alias, double timeout, const Host& rHost) \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
@@ -552,7 +520,7 @@ namespace SimGrid
                                 *                                                                                                              alias.\r
                                 */\r
                                static int listenFromHost(const char* alias, const Host& rHost) \r
-                               throw(NullPointerException, MsgException);\r
+                               throw(NullPointerException);\r
 \r
                                virtual const Task& operator= (const Task& rTask);\r
                        \r
@@ -561,8 +529,6 @@ namespace SimGrid
                                // Attributes.\r
                                \r
                                m_task_t nativeTask;    // the native MSG task.\r
-\r
-                               Ref* ref;\r
                };\r
        \r
        } // namespace Msg \r
@@ -570,4 +536,5 @@ namespace SimGrid
 \r
 typedef Task* TaskPtr;\r
 \r
-#endif // §MSG_TASK_HPP
\ No newline at end of file
+#endif // §MSG_TASK_HPP\r
+\r