Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
The default alias name is now build from the name of the host of the process and...
[simgrid.git] / src / cxx / Process.hpp
index 10816ec..5bc46e5 100644 (file)
        #error Process.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
+#include <msg/datatypes.h>\r
+\r
+#include <ApplicationHandler.hpp>\r
+#include <Object.hpp>\r
+\r
+#include <MsgException.hpp>\r
+#include <NullPointerException.hpp>\r
+#include <HostNotFoundException.hpp>\r
+#include <ProcessNotFoundException.hpp>\r
+#include <InvalidArgumentException.hpp>\r
+#include <BadAllocException.hpp>\r
+#include <LogicException.hpp>\r
 \r
 namespace SimGrid\r
 {\r
        namespace Msg\r
        {\r
+               class ApplicationHandler;\r
+               class Host;\r
+               class Task;\r
+\r
                // SimGrid::Msg::Process class declaration.\r
-               class Process\r
+               class SIMGRIDX_EXPORT Process : public Object\r
                {\r
-                       friend ApplicationHandler;\r
-                       \r
-                       private;\r
+                       friend class ApplicationHandler::ProcessFactory;\r
                        \r
+                       MSG_DECLARE_DYNAMIC(Process);\r
+\r
+                       public:\r
+\r
                                // Disable the default constructor.\r
                                Process();\r
                        \r
-                       public:\r
                        \r
                                /*! \brief  Constructs a process from the name of the host and its name.\r
                                 *\r
@@ -48,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
@@ -109,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
@@ -143,10 +160,10 @@ namespace SimGrid
                        \r
                                /*! \brief Process::isSuspend() - Tests if a process is suspended.\r
                                 *\r
-                                * \return                              This method returns true is the process is suspended.\r
-                                *                                              Otherwise the method returns false.\r
+                                * \return                              This method returns 1 is the process is suspended.\r
+                                *                                              Otherwise the method returns 0.\r
                                 */\r
-                               bool isSuspended(void);\r
+                               int isSuspended(void);\r
                        \r
                                /*! \brief Process::getHost() - Retrieves the host of a process object.\r
                                 *\r
@@ -250,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
@@ -265,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
@@ -280,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
@@ -297,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
@@ -312,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
@@ -332,8 +349,8 @@ 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
-                               throw(InvalidArgumentException MsgException);\r
+                               Task* getTask(int channel, double timeout, const Host& rHost)\r
+                               throw(InvalidArgumentException, MsgException);\r
                        \r
                                /*! \brief Process::sendTask() - Sends the given task in the mailbox identified by the specified alias\r
                                 * (waiting at most given time).\r
@@ -352,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
@@ -367,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
@@ -381,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
@@ -400,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
@@ -415,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
@@ -426,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
@@ -444,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
@@ -461,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
@@ -480,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
@@ -498,7 +515,7 @@ namespace SimGrid
                                 *\r
                                 *                                                      [MsgException]                          if an internal exception occurs.\r
                                 */\r
-                               Task& Process::receiveTask(double timeout, const Host& rHost) \r
+                               TaskreceiveTask(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
@@ -514,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
@@ -529,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
@@ -547,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
@@ -555,7 +572,7 @@ namespace SimGrid
                                 *\r
                                 * \return                              The wrapper associated with the native process specified as parameter.\r
                                 */\r
-                               static Process& fromNativeProcess(m_process_t nativeProcess);\r
+                               static Process* fromNativeProcess(m_process_t nativeProcess);\r
                        \r
                        \r
                        public:\r
@@ -572,7 +589,17 @@ namespace SimGrid
                                 *\r
                                 * \return                              The exit code of the main function.\r
                                 */\r
-                               virtual int main(int argc, char** argv) = 0;\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
@@ -584,4 +611,7 @@ namespace SimGrid
        \r
        } //namepace Msg\r
 \r
-} namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
+#endif // !MSG_PROCESS_HPP\r
+\r