\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
return *this;\r
}\r
} // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
+\r
+\r
#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
} // namespace Msg\r
} // namespace SimGrid\r
\r
-#endif // !MSG_APPLICATION_HPP
\ No newline at end of file
+#endif // !MSG_APPLICATION_HPP\r
+\r
/* 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
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
}\r
\r
} // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
#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
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
} // namespace SimGrid\r
\r
#endif // !MSG_APPLICATION_HANDLER_HPP\r
-
\ No newline at end of file
+\r
+/*\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
#ifndef MSG_BADALLOCEXCEPTION_HPP\r
#define MSG_BADALLOCEXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error BadAllocException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_BADALLOCEXCEPTION_HPP\r
+\r
+/*\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
#ifndef MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
#define MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error ClassNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
+\r
+\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
} // 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
\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
}\r
\r
Environment::Environment(const char* file)\r
- throw(NullPointerException, InvalidArgumentException)\r
+ throw(NullPointerException, FileNotFoundException)\r
{\r
// check parameters\r
\r
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
}\r
\r
} // namespace Msg\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
#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
} // namespace SimGrid\r
\r
\r
-#endif // !MSG_ENVIRONMENT_HPP
\ No newline at end of file
+#endif // !MSG_ENVIRONMENT_HPP\r
+\r
+/*\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
#ifndef MSG_EXCEPTION_HPP\r
#define MSG_EXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error Exception.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Config.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_EXCEPTION_HPP\r
+\r
+/*\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
#ifndef MSG_FILENOTFOUND_HPP\r
#define MSG_FILENOTFOUND_HPP\r
\r
+#ifndef __cplusplus\r
+ #error FileNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_MSGEXCEPTION_HPP\r
+\r
*/\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
\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
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
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
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
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
\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
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
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
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
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
\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
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
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
\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
{\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
* [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
*\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
* 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
* [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
*\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
*\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
* 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
* 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
* 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
* 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
* \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
* \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
} // namespace Msg\r
} // namespace SimGrid\r
\r
-#endif // !MSG_HOST_HPP
\ No newline at end of file
+#endif // !MSG_HOST_HPP\r
+/*\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
#ifndef MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
#define MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error HostNotFoundException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_HOSTNOTFOUNDEXCEPTION_HPP\r
+\r
+\r
+/*\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
#ifndef MSG_INVALIDARGUMENTEXCEPTION_HPP\r
#define MSG_INVALIDARGUMENTEXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error InvalidArgumentException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
+\r
+/*\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
#ifndef MSG_LOGICEXCEPTION_HPP\r
#define MSG_LOGICEXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error LogicException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_INVALIDARGUMENTEXCEPTION_HPP\r
+\r
+\r
/* 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
{\r
if(MSG_OK != MSG_clean())\r
throw MsgException("MSG_clean() failed");\r
+ \r
}\r
\r
void info(const char* s)\r
return MSG_get_clock();\r
}\r
\r
+ void setMaxChannelNumber(int number)\r
+ throw(InvalidArgumentException, LogicException)\r
+ {\r
+ if(msg_global->max_channel > 0)\r
+ throw LogicException("Max channel number already setted");\r
+\r
+ if(number < 0)\r
+ throw InvalidArgumentException("number");\r
+\r
+ msg_global->max_channel = number;\r
+ }\r
+\r
+ int getMaxChannelNumber(void)\r
+ {\r
+ return msg_global->max_channel;\r
+ }\r
+\r
} // namespace Msg\r
\r
-} // namespace SimGrid
\ No newline at end of file
+} // namespace SimGrid\r
+\r
#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
* \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
+/*\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
\r
\r
#endif // !MSG_MSGEXCEPTION_HPP\r
+\r
+/*\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
#ifndef MSG_NULLPOINTEREXCEPTION_HPP\r
#define MSG_NULLPOINTEREXCEPTION_HPP\r
\r
+#ifndef __cplusplus\r
+ #error NullPointerException.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
#include <Exception.hpp>\r
\r
namespace SimGrid\r
\r
\r
#endif // !MSG_NULLPOINTEREXCEPTION_HPP\r
+\r
+/*\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
-\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
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
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
-#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
#include <msg/mailbox.h>\r
\r
\r
+\r
namespace SimGrid\r
{\r
namespace Msg\r
}\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
}\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
\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
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
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
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
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
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
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
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
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
\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
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
\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
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
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
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
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
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
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
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
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
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
\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
{\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
{\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
#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
// 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
* [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
* [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
*\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
*\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
*\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
* 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
* \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
*\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
*\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
* [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
* [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
*\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
*\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
* \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
*\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
* \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
*\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
*\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
*\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
*\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
* [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
* \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
\r
} // namespace SimGrid\r
\r
-#endif // !MSG_PROCESS_HPP
\ No newline at end of file
+#endif // !MSG_PROCESS_HPP\r
+\r
+/*\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
#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
/* 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
}\r
} // namespace Msg\r
} // namespace SimGrid\r
+\r
+\r
#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
} // namespace Msg\r
} // namespace SimGrid\r
\r
-#endif // !MSG_SIMULATION_HPP
\ No newline at end of file
+#endif // !MSG_SIMULATION_HPP\r
+\r
-#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
\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
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
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
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
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
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
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
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
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
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
\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
{\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
{\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
* \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
*\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
* 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
*\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
*\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
*\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
* 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
// Attributes.\r
\r
m_task_t nativeTask; // the native MSG task.\r
-\r
- Ref* ref;\r
};\r
\r
} // namespace Msg \r
\r
typedef Task* TaskPtr;\r
\r
-#endif // §MSG_TASK_HPP
\ No newline at end of file
+#endif // §MSG_TASK_HPP\r
+\r