--- /dev/null
+#include <ClassNotFoundException.hpp>\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ ClassNotFoundException::ClassNotFoundException()\r
+ {\r
+ this->reason = (char*) calloc(strlen("Class not found : unknown") + 1, sizeof(char));\r
+ strcpy(this->reason, "Class not found : unknown");\r
+ }\r
+ \r
+ \r
+ ClassNotFoundException::ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException)\r
+ {\r
+ const char* reason = rClassNotFoundException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ strcpy(this->reason, reason);\r
+ \r
+ }\r
+ \r
+ \r
+ ClassNotFoundException::ClassNotFoundException(const char* name)\r
+ {\r
+ this->reason = (char*) calloc(strlen("Class not found : ") + strlen(name) + 1, sizeof(char));\r
+ sprintf(this->reason, "Class not found : %s", name);\r
+ }\r
+ \r
+ \r
+ ClassNotFoundException::~ClassNotFoundException()\r
+ {\r
+ if(this->reason)\r
+ free(this->reason);\r
+ }\r
+ \r
+ const char* ClassNotFoundException::toString(void) const\r
+ {\r
+ return (const char*)(this->reason); \r
+ }\r
+ \r
+ \r
+ const ClassNotFoundException& ClassNotFoundException::operator = (const ClassNotFoundException& rClassNotFoundException)\r
+ {\r
+ const char* reason = rClassNotFoundException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ \r
+ return *this;\r
+ }\r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+\r
--- /dev/null
+/*\r
+ * ClassNotFoundException.hpp\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */ \r
+ \r
+#ifndef MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
+#define MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
+\r
+#include <Exception.hpp>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ class SIMGRIDX_EXPORT ClassNotFoundException : public Exception\r
+ {\r
+ public:\r
+ \r
+ // Default constructor.\r
+ ClassNotFoundException();\r
+ \r
+ // Copy constructor.\r
+ ClassNotFoundException(const ClassNotFoundException& rClassNotFoundException);\r
+ \r
+ // This constructor takes the name of the class not found.\r
+ ClassNotFoundException(const char* name);\r
+ \r
+ // Destructor.\r
+ virtual ~ClassNotFoundException();\r
+ \r
+ // Operations.\r
+ \r
+ // Returns the reason of the exception :\r
+ // the message "Host not found `host name'"\r
+ const char* toString(void) const;\r
+ \r
+ // Operators.\r
+ \r
+ // Assignement.\r
+ const ClassNotFoundException& operator = (const ClassNotFoundException& rClassNotFoundException);\r
+ \r
+ private :\r
+ \r
+ // Attributes.\r
+ \r
+ // A buffer used to build the message returned by the methode toString().\r
+ char* reason;\r
+ };\r
+ \r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+#endif // !MSG_CLASSNOTFOUNDEXCEPTION_HPP\r
--- /dev/null
+#ifndef MSG_CONFIG_HPP\r
+#define MSG_CONFIG_HPP\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ #if defined(WIN32)\r
+ #if defined(SIMGRIDX_EXPORTS)\r
+ #define SIMGRIDX_EXPORT __declspec(dllexport)\r
+ #else\r
+ #define SIMGRIDX_EXPORT \r
+ #endif\r
+ #else\r
+ #define SIMGRIDX_EXPORT\r
+ #endif \r
+ } // namespace Msg\r
+} // namespace SimGrid\r
+\r
+#endif // MSG_CONFIG_HPP
\ No newline at end of file
--- /dev/null
+#include <NullPointerException.hpp>\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ NullPointerException::NullPointerException()\r
+ {\r
+ this->reason = (char*) calloc(strlen("Null pointer : unknown") + 1, sizeof(char));\r
+ strcpy(this->reason, "Null pointer : unknown");\r
+ }\r
+ \r
+ \r
+ NullPointerException::NullPointerException(const NullPointerException& rNullPointerException)\r
+ {\r
+ const char* reason = rNullPointerException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ strcpy(this->reason, reason);\r
+ \r
+ }\r
+ \r
+ \r
+ NullPointerException::NullPointerException(const char* name)\r
+ {\r
+ this->reason = (char*) calloc(strlen("Null pointer : ") + strlen(name) + 1, sizeof(char));\r
+ sprintf(this->reason, "Null pointer : %s", name);\r
+ }\r
+ \r
+ \r
+ NullPointerException::~NullPointerException()\r
+ {\r
+ if(this->reason)\r
+ free(this->reason);\r
+ }\r
+ \r
+ const char* NullPointerException::toString(void) const\r
+ {\r
+ return (const char*)(this->reason); \r
+ }\r
+ \r
+ \r
+ const NullPointerException& NullPointerException::operator = (const NullPointerException& rNullPointerException)\r
+ {\r
+ const char* reason = rNullPointerException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ \r
+ return *this;\r
+ }\r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+\r
--- /dev/null
+/*\r
+ * NullPointerException.hpp\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */ \r
+ \r
+#ifndef MSG_NULLPOINTEREXCEPTION_HPP\r
+#define MSG_NULLPOINTEREXCEPTION_HPP\r
+\r
+#include <Exception.hpp>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ class SIMGRIDX_EXPORT NullPointerException : public Exception\r
+ {\r
+ public:\r
+ \r
+ // Default constructor.\r
+ NullPointerException();\r
+ \r
+ // Copy constructor.\r
+ NullPointerException(const NullPointerException& rNullPointerException);\r
+ \r
+ // This constructor takes the name of the invalid argument.\r
+ NullPointerException(const char* name);\r
+ \r
+ // Destructor.\r
+ virtual ~NullPointerException();\r
+ \r
+ // Operations.\r
+ \r
+ // Returns the reason of the exception :\r
+ // the message "Null pointer `pointer name'"\r
+ const char* toString(void) const;\r
+ \r
+ // Operators.\r
+ \r
+ // Assignement.\r
+ const NullPointerException& operator = (const NullPointerException& rNullPointerException);\r
+ \r
+ private :\r
+ \r
+ // Attributes.\r
+ \r
+ // A buffer used to build the message returned by the methode toString().\r
+ char* reason;\r
+ };\r
+ \r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+#endif // !MSG_NULLPOINTEREXCEPTION_HPP\r
--- /dev/null
+\r
+#ifndef MSG_OBJECT_H\r
+#define MSG_OBJECT_H\r
+\r
+// Compilation C++ recquise\r
+#ifndef __cplusplus\r
+ #error Object.hpp requires C++ compilation (use a .cxx suffix)\r
+#endif\r
+\r
+#include <stdlib.h>\r
+\r
+#include <ClassNotFoundException.hpp>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ //////////////////////////////////////////////////////////////////////////////\r
+ // Macros\r
+ \r
+ // Returns the runtime class of the class_name object.\r
+ #define MSG_GET_CLASS(class_name) \\r
+ ((Class*)(&class_name::class##class_name))\r
+ \r
+ // Declare the class class_name as dynamic\r
+ #define MSG_DECLARE_DYNAMIC(class_name) \\r
+ public: \\r
+ static Class class##class_name; \\r
+ virtual Class* getClass() const; \\r
+ static Object* createObject(); \\r
+\r
+ // The runtime class implementation. \r
+ #define MSG_IMPLEMENT_CLASS(class_name, base_class_name, pfn,class_init) \\r
+ Class class_name::class##class_name = { \\r
+ #class_name, sizeof(class class_name),pfn, \\r
+ MSG_GET_CLASS(base_class_name), NULL,class_init}; \\r
+ Class* class_name::getClass() const \\r
+ { return MSG_GET_CLASS(class_name); } \\r
+ \r
+ // CreateObject implementation. \r
+ #define MSG_IMPLEMENT_DYNAMIC(class_name, base_class_name) \\r
+ Object* class_name::createObject() \\r
+ { return (Object*)(new class_name); } \\r
+ DeclaringClass _declaringClass_##class_name(MSG_GET_CLASS(class_name)); \\r
+ MSG_IMPLEMENT_CLASS(class_name, base_class_name, \\r
+ class_name::createObject, &_declaringClass_##class_name) \\r
+\r
+ //////////////////////////////////////////////////////////////////////////////\r
+ // Classes declared in this file.\r
+\r
+ class Object; // The msg object.\r
+\r
+ //////////////////////////////////////////////////////////////////////////////\r
+ // Structures declared in this files.\r
+\r
+ struct Class; // used during the rtti operations\r
+ struct DeclaringClass; // used during the instances registration.\r
+\r
+\r
+ class DeclaringClasses;\r
+\r
+ //////////////////////////////////////////////////////////////////////////////\r
+ // Global functions\r
+\r
+ // Used during the registration.\r
+ void DeclareClass(Class* c);\r
+\r
+ //////////////////////////////////////////////////////////////////////////////\r
+ // DeclaringClass\r
+\r
+ struct SIMGRIDX_EXPORT DeclaringClass\r
+ {\r
+ // Constructor : add the runtime classe in the list.\r
+ DeclaringClass(Class* c);\r
+ \r
+ // Destructor\r
+ virtual ~DeclaringClass(void);\r
+\r
+ // Attributes :\r
+ // the list of runtime classes.\r
+ static DeclaringClasses* declaringClasses;\r
+ };\r
+\r
+ #define MSG_DELCARING_CLASSES (*(DeclaringClass::declaringClasses))\r
+ \r
+ \r
+ struct SIMGRIDX_EXPORT Class\r
+ {\r
+ \r
+ // Attributes\r
+ \r
+ const char* name; // class name.\r
+ size_t typeSize; // type size. \r
+ Object* (*createObjectFn)(void); // pointer to the create object function. \r
+ Class* baseClass; // the runtime class of the runtime class.\r
+ Class* next; // the next runtime class in the list.\r
+ const DeclaringClass* declaringClass; // used during the registration of the class.\r
+ \r
+ // Operations\r
+ \r
+ // Create the runtime class from its name.\r
+ static Class* fromName(const char* name)\r
+ throw (ClassNotFoundException);\r
+ \r
+ // Create an object from the name of the its class.\r
+ static Object* createObject(const char* name);\r
+ \r
+ // Create an instance of the class.\r
+ Object* createObject(void);\r
+ \r
+ // Return true is the class is dervived from the base class baseClass.\r
+ bool isDerivedFrom(const Class* baseClass) const;\r
+\r
+ };\r
+\r
+ // Create an instance of the class.\r
+ inline Object* Class::createObject(void)\r
+ {\r
+ return (*createObjectFn)();\r
+ }\r
+ \r
+ \r
+ class SIMGRIDX_EXPORT Object\r
+ {\r
+ public:\r
+ \r
+ // Default constructor.\r
+ Object(){}\r
+ \r
+ // Destructor.\r
+ virtual ~Object(){}\r
+ \r
+ // Operations.\r
+ \r
+ // Get the runtime class.\r
+ virtual Class* getClass(void) const;\r
+ \r
+ // Returns true if the class is derived from the class baseClass. Otherwise\r
+ // the method returns false.\r
+ bool isDerivedFrom(const Class* baseClass) const;\r
+ \r
+ // Returns true if the object is valid. Otherwise the method returns false.\r
+ virtual bool isValid(void) const;\r
+\r
+ // Returns true is the object is an instance of the class specified as parameter.\r
+ bool isInstanceOf(const char* className);\r
+ \r
+ // Operators.\r
+\r
+ // Attributes.\r
+ \r
+ // The runtime class.\r
+ static const Class classObject;\r
+ };\r
+\r
+ // inline member functions of the class Object.\r
+ \r
+ // Returns the runtime class of the object.\r
+ inline Class* Object::getClass(void) const\r
+ {\r
+ return MSG_GET_CLASS(Object);\r
+ }\r
+\r
+ // Returns true if the class is derived from the class pBaseClass. Otherwise\r
+ // the method returns false.\r
+ inline bool Object::isDerivedFrom(const Class* baseClass) const\r
+ {\r
+ return (getClass()->isDerivedFrom(baseClass));\r
+ }\r
+ \r
+ // Returns true if the object is valid. Otherwise the method returns false.\r
+ inline bool Object::isValid(void) const\r
+ {\r
+ // returns always true.\r
+ return true; \r
+ }\r
+\r
+ \r
+ class DeclaringClasses \r
+ {\r
+ public:\r
+ \r
+ // Constructor.\r
+ DeclaringClasses();\r
+\r
+ // Destructor.\r
+ virtual ~DeclaringClasses(){}\r
+ \r
+ // Operations.\r
+ \r
+ // Add the class at the head of the list.\r
+ void addHead(Class* c);\r
+ \r
+ // Get the runtime class of the head of the list.\r
+ Class* getHead(void) const ;\r
+ \r
+ // Remove the class from the list (don't destroy it).\r
+ bool remove(Class* c);\r
+ \r
+ // Remove the head of the list.\r
+ Class* removeHead(void);\r
+ \r
+ // Return true if the list is empty.\r
+ \r
+ bool isEmpty(void) const;\r
+ \r
+ // Remove of the elements of the list.\r
+ void removeAll(void);\r
+ \r
+ // Get the number of classes in the list.\r
+ unsigned int getCount(void);\r
+ \r
+ void lock(void){}\r
+ \r
+ void unlock(void){}\r
+ \r
+ //Attributes\r
+ \r
+ // The head of the list.\r
+ Class* head;\r
+\r
+ private:\r
+ \r
+ // Attributes\r
+ \r
+ // The number of elements of the list.\r
+ unsigned int count;\r
+ };\r
+\r
+\r
+ // Constructor (Add the class in the list).\r
+ inline DeclaringClass::DeclaringClass(Class* c)\r
+ {\r
+ if(!declaringClasses)\r
+ declaringClasses = new DeclaringClasses();\r
+\r
+ DeclareClass(c);\r
+ }\r
+\r
+ // Destructor.\r
+ inline DeclaringClass::~DeclaringClass()\r
+ {\r
+ /*if(NULL != declaringClasses)\r
+ delete declaringClasses;\r
+\r
+ declaringClasses=NULL;*/\r
+\r
+ }\r
+\r
+ // Returns the number of elements of the list.\r
+ inline unsigned int DeclaringClasses::getCount()\r
+ {\r
+ return count;\r
+ }\r
+ \r
+ // Returns the head of the list.\r
+ inline Class* DeclaringClasses::getHead() const\r
+ {\r
+ return head;\r
+ }\r
+ \r
+ // Returns true if the list is empty. Otherwise this function\r
+ // returns false.\r
+ inline bool DeclaringClasses::isEmpty() const\r
+ {\r
+ return(!head);\r
+ }\r
+ \r
+ // Removes all the elements of the list.\r
+ inline void DeclaringClasses::removeAll()\r
+ {\r
+ head = 0;\r
+ count=0;\r
+ }\r
+ \r
+ } // namespace Msg \r
+} // namespace SimGrid\r
+\r
+\r
+using namespace SimGrid::Msg;\r
+\r
+#define instanceOf(class_name) reinterpret_cast<class_name*>(Class::createObject(#class_name))\r
+\r
+#endif // !MSG_OBJECT_H\r
+\r
--- /dev/null
+#include <ProcessNotFoundException.hpp>\r
+\r
+#include <string.h>\r
+#include <stdlib.h>\r
+#include <stdio.h>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ ProcessNotFoundException::ProcessNotFoundException()\r
+ {\r
+ this->reason = (char*) calloc(strlen("Host not found : unknown") + 1, sizeof(char));\r
+ strcpy(this->reason, "Host not found : unknown");\r
+ }\r
+ \r
+ \r
+ ProcessNotFoundException::ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException)\r
+ {\r
+ const char* reason = rProcessNotFoundException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ strcpy(this->reason, reason);\r
+ \r
+ }\r
+ \r
+ \r
+ ProcessNotFoundException::ProcessNotFoundException(int PID)\r
+ {\r
+ char buff[7] = {0};\r
+ _itoa(PID, buff, 10);\r
+ this->reason = (char*) calloc(strlen("Process not found : ") + strlen(buff) + 1, sizeof(char));\r
+ sprintf(this->reason, "Host not found : %s", buff);\r
+ }\r
+ \r
+ \r
+ ProcessNotFoundException::~ProcessNotFoundException()\r
+ {\r
+ if(this->reason)\r
+ free(this->reason);\r
+ }\r
+ \r
+ const char* ProcessNotFoundException::toString(void) const\r
+ {\r
+ return (const char*)(this->reason); \r
+ }\r
+ \r
+ \r
+ const ProcessNotFoundException& ProcessNotFoundException::operator = (const ProcessNotFoundException& rProcessNotFoundException)\r
+ {\r
+ const char* reason = rProcessNotFoundException.toString();\r
+ this->reason = (char*) calloc(strlen(reason) + 1, sizeof(char));\r
+ \r
+ return *this;\r
+ }\r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+\r
--- /dev/null
+/*\r
+ * ProcessNotFoundException.hpp\r
+ *\r
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier \r
+ * All right reserved. \r
+ *\r
+ * This program is free software; you can redistribute \r
+ * it and/or modify it under the terms of the license \r
+ *(GNU LGPL) which comes with this package. \r
+ *\r
+ */ \r
+ \r
+#ifndef MSG_PROCESSNOTFOUNDEXCEPTION_HPP\r
+#define MSG_PROCESSNOTFOUNDEXCEPTION_HPP\r
+\r
+#include <Exception.hpp>\r
+\r
+namespace SimGrid\r
+{\r
+ namespace Msg\r
+ {\r
+ \r
+ class SIMGRIDX_EXPORT ProcessNotFoundException : public Exception\r
+ {\r
+ public:\r
+ \r
+ // Default constructor.\r
+ ProcessNotFoundException();\r
+ \r
+ // Copy constructor.\r
+ ProcessNotFoundException(const ProcessNotFoundException& rProcessNotFoundException);\r
+ \r
+ // This constructor takes PID of the process.\r
+ ProcessNotFoundException(int PID);\r
+ \r
+ // Destructor.\r
+ virtual ~ProcessNotFoundException();\r
+ \r
+ // Operations.\r
+ \r
+ // Returns the reason of the exception :\r
+ // the message "Process not found `PID'"\r
+ const char* toString(void) const;\r
+ \r
+ // Operators.\r
+ \r
+ // Assignement.\r
+ const ProcessNotFoundException& operator = (const ProcessNotFoundException& rProcessNotFoundException);\r
+ \r
+ private :\r
+ \r
+ // Attributes.\r
+ \r
+ // A buffer used to build the message returned by the methode toString().\r
+ char* reason;\r
+ };\r
+ \r
+ \r
+ } // namespace Msg \r
+\r
+}// namespace SimGrid\r
+\r
+\r
+#endif // !MSG_PROCESSNOTFOUNDEXCEPTION_HPP\r