Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Some code refactoring
[simgrid.git] / src / cxx / Host.hpp
index e8b2854..0228097 100644 (file)
@@ -52,22 +52,34 @@ catch(HostNotFoundException e)
        #error Host.hpp requires C++ compilation (use a .cxx suffix)\r
 #endif\r
 \r
+#include <msg/datatypes.h>\r
+\r
 #include <InvalidArgumentException.hpp>\r
 #include <BadAllocException.hpp>\r
 #include <HostNotFoundException.hpp>\r
+#include <MsgException.hpp>\r
+#include <NullPointerException.hpp>\r
+\r
+\r
 \r
 // namespace SimGrid::Msg\r
 namespace SimGrid\r
 {\r
        namespace Msg\r
        {\r
+               class Task;\r
+               class Process;\r
+\r
                // Declaration of the class SimGrid::Msg::Host.\r
-               class Host\r
+               class SIMGRIDX_EXPORT Host // final class.\r
                {\r
+                       friend class Process;\r
+                       friend class Task;\r
+\r
                        // Desable the default constructor.\r
                        // The best way to get an host instance is to use the static method Host::getByName().\r
                        \r
-                       private :\r
+                       public :\r
                                \r
                        // Default constructor (desabled).\r
                                Host();\r
@@ -96,11 +108,11 @@ namespace SimGrid
                                 *\r
                                 * \exception           [HostNotFoundException]         if no host with the specified name\r
                                 *                                                                                              was found.\r
-                                *                                      [InvalidParameterException]     if the hostName parameter is invalid (NULL).\r
+                                *                                      [InvalidArgumentException]      if the hostName parameter is invalid (NULL).\r
                                 *                                      [BadAllocException]                     if there is not enough memory to allocate the host.\r
                                 */ \r
                                static Host& getByName(const char* hostName)\r
-                               throw(HostNotFoundException, InvalidParameterException, BadAllocException);\r
+                               throw(HostNotFoundException, NullPointerException, BadAllocException);\r
                                \r
                                /*! \brief Host::getNumber() - returns the number of the installed hosts.\r
                                 *\r
@@ -116,8 +128,7 @@ namespace SimGrid
                                 *\r
                                 * \see                         Process::currentProcess().\r
                                 */\r
-                               static Host& currentHost(void)\r
-                               throw(InvalidParameterException, 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
@@ -129,7 +140,7 @@ namespace SimGrid
                                 *                                      the parameter len is set with the number of hosts of the platform.\r
                                 *                                      Otherwise the method throw one of the exception described below.\r
                                 *\r
-                                * \exception           [InvalidParameterException]     if the parameter hosts is invalid or\r
+                                * \exception           [InvalidArgumentException]      if the parameter hosts is invalid or\r
                                 *                                                                                              if the parameter len is negative or\r
                                 *                                                                                              less than the number of hosts installed\r
                                 *                                                                                              on the current platform.\r
@@ -183,55 +194,225 @@ namespace SimGrid
                                 *      delete[] ar;\r
                                 *\r
                                 */ \r
-                               static void all(Host*** hosts /*in|out*/, int* len /*in|out*/);\r
-                               \r
+                               static void all(Host*** hosts /*in|out*/, int* len /*in|out*/)\r
+                               throw(InvalidArgumentException, BadAllocException) ;\r
                                \r
+                               /*! \brief Host::getName() - This method return the name of the Msg host object.\r
+                                *\r
+                                * \return                      The name of the host object.\r
+                                */\r
                                const char* getName(void) const;\r
                                \r
+                               /*! \brief Host::setData() - Set the user data of an host object.\r
+                                *\r
+                                * \param data          The user data to set.\r
+                                */\r
                                void setData(void* data);\r
                                \r
-                               // Getters/setters\r
-                               \r
+                               /*! \brief Host::getData() - Get the user data of a host object.\r
+                                *\r
+                                * \return                      The user data of the host object.\r
+                                */\r
                                void* getData(void) const;\r
                                \r
-                               int Host::getRunningTaskNumber(void) const;\r
-                               \r
-                               double getSpeed(void) const;\r
-                               \r
+                               /*! \brief Host::hasData() - Test if an host object has some data.\r
+                                *\r
+                                * \return                      This method returns true if the host object has some user data.\r
+                                *                                      Otherwise the method returns false.\r
+                                */\r
                                bool hasData(void) const;\r
                                \r
-                               bool isAvailble(void) const;\r
+                               /*! \brief Host::getRunningTaskNumber() - returns the number of tasks currently running on a host.\r
+                                *\r
+                                * \return                      The number of task currently running of the host object.\r
+                                *\r
+                                * \remark                      The external load is not taken in account.\r
+                                */\r
+                               int getRunningTaskNumber(void) const;\r
                                \r
-                               void put(int channel, const Task& rTask)\r
-                               throw(NativeException);\r
+                               /*! \brief Host::getSpeed() - returns the speed of the processor of a host,\r
+                                * regardless of the current load of the machine.\r
+                                *\r
+                                * \return                      The speed of the processor of the host in flops.\r
+                                */ \r
+                               double getSpeed(void) const;\r
                                \r
-                               void put(int channel, Task task, double timeout) \r
-                               throw(NativeException);\r
+                               /*! \brief Host::isAvailable - tests if an host is availabled.\r
+                                * \r
+                                * \return                      Is the host is availabled the method returns\r
+                                *                                      1. Otherwise the method returns 0.\r
+                                */ \r
+                               int isAvailable(void) const;\r
                                \r
-                               void Host::putBounded(int channel, const Task& rTask, double maxRate) \r
-                               throw(NativeException);\r
+                               /* ! \brief Host::put() - put a task on the given channel of a host .\r
+                                *\r
+                                * \param channel       The channel where to put the task.\r
+                                * \param rTask         A refercence to the task object containing the native task to\r
+                                *                                      put on the channel specified by the parameter channel.\r
+                                *\r
+                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
+                                *                                      the method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [MsgException]                          if an internal error occurs.\r
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
+                                *                                                                                              parameter is negative.\r
+                                */\r
+                               void put(int channel, Task* task) \r
+                               throw(MsgException, InvalidArgumentException);\r
                                \r
+                               /* ! \brief Host::put() - put a task on the given channel of a host object (waiting at most timeout seconds).\r
+                                *\r
+                                * \param channel       The channel where to put the task.\r
+                                * \param rTask         A refercence to the task object containing the native task to\r
+                                *                                      put on the channel specified by the parameter channel.\r
+                                * \param timeout       The timeout in seconds.\r
+                                *\r
+                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
+                                *                                      the method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [MsgException]                          if an internal error occurs.\r
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
+                                *                                                                                              parameter is negative or if the timeout value\r
+                                *                                                                                              is less than zero and diffĂ©rent of -1.\r
+                                *\r
+                                * \remark                      To specify no timeout set the timeout value with -1.0.\r
+                                */\r
+                               void put(int channel, Task* task, double timeout) \r
+                               throw(MsgException, InvalidArgumentException);\r
                                \r
-                               void send(const Task& rTask) \r
-                               throw(NativeException);\r
+                               /* ! \brief Host::putBounded() - put a task on the given channel of a host object (capping the emission rate to maxrate).\r
+                                *\r
+                                * \param channel       The channel where to put the task.\r
+                                * \param rTask         A refercence to the task object containing the native task to\r
+                                *                                      put on the channel specified by the parameter channel.\r
+                                * \param maxRate       The maximum rate.\r
+                                *\r
+                                * \return                      If successful the task is puted on the specified channel. Otherwise\r
+                                *                                      the method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [MsgException]                          if an internal error occurs.\r
+                                *                                      [InvalidArgumentException]      if the value of the channel specified as\r
+                                *                                                                                              parameter is negative or if the maxRate parameter value\r
+                                *                                                                                              is less than zero and diffĂ©rent of -1.0.\r
+                                *\r
+                                * \remark                      To specify no rate set the maxRate parameter value with -1.0.\r
+                                */\r
+                               void putBounded(int channel, Task* task, double maxRate) \r
+                               throw(MsgException, InvalidArgumentException);\r
                                \r
-                               void send(const char* alias, const Task& rTask) \r
-                               throw(NativeException);\r
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias.\r
+                                *\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [BadAllocException]                     if there is not enough memory to allocate\r
+                                *                                                                                              the default alias variable.\r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                */\r
+                               void send(Task* task) \r
+                               throw(MsgException, BadAllocException);\r
                                \r
-                               void send(const Task& rTask, double timeout) \r
-                               throw(NativeException);\r
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the specified alias parameter.\r
+                                *\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                * \param alias         The alias of the mailbox where to send the task.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [InvalidArgumentException]      if alias parameter is invalid (NULL).\r
+                                *                                      [BadAllocException]                     if there is not enough memory to allocate\r
+                                *                                                                                              the default alias variable.\r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                */\r
+                               void send(const char* alias, Task* task) \r
+                               throw(InvalidArgumentException, MsgException);\r
                                \r
-                               void send(const char* alias, const Task& rTask, double timeout) \r
-                               throw(NativeException);\r
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the default alias\r
+                                *  (waiting at most timeout seconds).\r
+                                *\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                * \param timeout       The timeout value to wait for.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [BadAllocException]                     if there is not enough memory to allocate\r
+                                *                                                                                              the default alias variable.\r
+                                *                                      [InvalidArgumentException]      if the timeout value is negative and different of\r
+                                *                                                                                              -1.0.                   \r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                *\r
+                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous \r
+                                *                                      version of this method.\r
+                                *\r
+                                */\r
+                               void send(Task* task, double timeout) \r
+                               throw(InvalidArgumentException, BadAllocException, MsgException);\r
                                \r
-                               void sendBounded(const Task& rTask, double maxRate) \r
-                               throw(NativeException);\r
+                               /* ! brief Host::send() - sends the given task to mailbox identified by the parameter alias\r
+                                *  (waiting at most timeout seconds).\r
+                                *\r
+                                * \param alias         The alias of the mailbox to send the task.\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                * \param timeout       The timeout value to wait for.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [InvalidArgumentException]      if the timeout value is negative and different of\r
+                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       \r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                *\r
+                                * \remark                      To specify no timeout set the timeout value with -1.0 or use the previous \r
+                                *                                      version of this method.\r
+                                *\r
+                                */\r
+                               void send(const char* alias, Task* task, double timeout) \r
+                               throw(InvalidArgumentException, MsgException);\r
                                \r
-                               void sendBounded(const char* alias, const Task& rTask, double maxRate) \r
-                               throw(NativeException);\r
+                               /* ! brief Host::sendBounded() - sends the given task to mailbox associated to the default alias\r
+                                *  (capping the emission rate to maxRate).\r
+                                *\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                * \param maxRate       The maximum rate value.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of\r
+                                *                                                                                              -1.0.                   \r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                *                                      [BadAllocException]                     if there is not enough memory to allocate\r
+                                *                                                                                              the default alias variable.\r
+                                *\r
+                                * \remark                      To specify no rate set its value with -1.0.\r
+                                *\r
+                                */\r
+                               void sendBounded(Task* task, double maxRate) \r
+                               throw(InvalidArgumentException, BadAllocException, MsgException);\r
                                \r
-                        \r
-                       \r
+                               /* ! brief Host::sendBounded() - sends the given task to mailbox identified by the parameter alias\r
+                                *  (capping the emission rate to maxRate).\r
+                                *\r
+                                * \param alias         The alias of the mailbox where to send the task.\r
+                                * \param rTask         A reference to the task object containing the native msg task to send.\r
+                                * \param maxRate       The maximum rate value.\r
+                                *\r
+                                * \return                      If successful the task is sended to the default mailbox. Otherwise the\r
+                                *                                      method throws one of the exceptions described below.\r
+                                *\r
+                                * \exception           [InvalidArgumentException]      if the maximum rate value is negative and different of\r
+                                *                                                                                              -1.0 or if the alias parameter is invalid (NULL).                       \r
+                                *                                      [MsgException]                          if an internal error occurs.\r
+                                *\r
+                                * \remark                      To specify no rate set its value with -1.0.\r
+                                *\r
+                                */\r
+                               void sendBounded(const char* alias, Task* task, double maxRate) \r
+                               throw(InvalidArgumentException, MsgException);\r
                        \r
                        protected:\r
                        // Attributes.\r
@@ -241,7 +422,7 @@ namespace SimGrid
                                 * It is set automaticatly during the call of the static \r
                                 * method Host::getByName().\r
                                 *\r
-                                * @see                         Host::getByName().\r
+                                * \see                         Host::getByName().\r
                                 */ \r
                                m_host_t nativeHost;\r
                        \r
@@ -256,4 +437,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