Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
a sample of makefile for cpp wrappers library.
[simgrid.git] / src / cxx / Application.cxx
index c188ffb..ca37d24 100644 (file)
-/*\r
- * Application.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
- /* Application member functions implementation.\r
-  */  \r
-\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
-\r
-#include <surf/surfxml_parse.h>\r
-\r
-#ifndef S_ISREG\r
-       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)\r
-#endif\r
-\r
-namespace SimGrid\r
-{\r
-       namespace Msg\r
-       {\r
-       \r
-               Application::Application()\r
-               {\r
-                       this->file = NULL;\r
-                       this->deployed = false;\r
-               }\r
-                               \r
-               Application::Application(const Application& rApplication)\r
-               {\r
-                               \r
-                       this->file = rApplication.getFile();\r
-                       this->deployed = rApplication.isDeployed();\r
-               }\r
-       \r
-               Application::Application(const char* file)\r
-               throw(NullPointerException, FileNotFoundException)\r
-               {\r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException(file);\r
-                               \r
-                       this->file = file;\r
-                       this->deployed = false;\r
-               }\r
-               \r
-               Application::~Application()\r
-               {\r
-                       // NOTHING TODO\r
-               }\r
-                       \r
-               void Application::deploy(const char* file)\r
-               throw(NullPointerException, FileNotFoundException, LogicException, MsgException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       // check the parameters\r
-                               \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException(file);\r
-                                       \r
-                       surf_parse_reset_parser();\r
-                       \r
-                       // set the begin of the xml process element handler\r
-                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
-                               \r
-                       // set the process arg handler\r
-                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
-                               \r
-                       // set the properties handler\r
-                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
-                               \r
-                       // set the end of the xml process element handler\r
-                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
-\r
-                       surf_parse_open(file);\r
-                       \r
-                       // initialize the process factory used by the process handler to build the processes.\r
-                       ApplicationHandler::onStartDocument();\r
-                               \r
-                       if(surf_parse())\r
-                               throw MsgException("surf_parse() failed");\r
-                       \r
-                       surf_parse_close();\r
-                       \r
-                       // release the process factory\r
-                       ApplicationHandler::onEndDocument();    \r
-                       \r
-                       this->file = file;\r
-                       this->deployed = true;\r
-               }\r
-               \r
-               void Application::deploy(void)\r
-               throw(LogicException, MsgException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       // check the parameters\r
-                       if(!this->file)\r
-                               throw LogicException("you must specify the xml file which describe the application\nuse Application::setFile()"); \r
-                       \r
-                       surf_parse_reset_parser();\r
-                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);\r
-                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);\r
-                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);\r
-                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);\r
-                       \r
-                       // initialize the process factory used by the process handler to build the processes.\r
-                       ApplicationHandler::onStartDocument();\r
-\r
-                       surf_parse_open(file);\r
-                       \r
-                       if(surf_parse())\r
-                               throw MsgException("surf_parse() failed");\r
-                       \r
-                       surf_parse_close();\r
-                       \r
-                       this->deployed = true;  \r
-               }\r
-               \r
-               bool Application::isDeployed(void) const\r
-               {\r
-                       return this->deployed;\r
-               }\r
-               \r
-               void Application::setFile(const char* file)\r
-               throw (NullPointerException, FileNotFoundException, LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("your are trying to change the file of an already deployed application");\r
-                               \r
-                       // check parameters\r
-                       \r
-                       if(!file)\r
-                               throw NullPointerException("file");\r
-                       \r
-                       struct stat statBuf = {0};\r
-                               \r
-                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))\r
-                               throw FileNotFoundException("file (file not found)");\r
-                               \r
-                       this->file = file;\r
-                       \r
-               }\r
-               \r
-               const char* Application::getFile(void) const\r
-               {\r
-                       return this->file;\r
-               }\r
-               \r
-               const Application& Application::operator = (const Application& rApplication)\r
-               throw(LogicException)\r
-               {\r
-                       // check logic\r
-                       \r
-                       if(this->deployed)\r
-                               throw LogicException("application already deployed");\r
-                       \r
-                       this->file = rApplication.getFile();\r
-                       this->deployed = rApplication.isDeployed();\r
-                       \r
-                       return *this;\r
-               }\r
-       } // namespace Msg\r
-} // namespace SimGrid\r
-\r
-\r
-\r
+/*
+ * Application.cxx
+ *
+ * Copyright 2006,2007 Martin Quinson, Malek Cherier           
+ * All right reserved. 
+ *
+ * This program is free software; you can redistribute 
+ * it and/or modify it under the terms of the license 
+ *(GNU LGPL) which comes with this package. 
+ *
+ */
+ /* Application member functions implementation.
+  */  
+
+#include <ApplicationHandler.hpp>
+
+#include <Application.hpp>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+
+#include <surf/surfxml_parse.h>
+
+#ifndef S_ISREG
+       #define S_ISREG(__mode) (((__mode) & S_IFMT) == S_IFREG)
+#endif
+
+namespace SimGrid
+{
+       namespace Msg
+       {
+       
+               Application::Application()
+               {
+                       this->file = NULL;
+                       this->deployed = false;
+               }
+                               
+               Application::Application(const Application& rApplication)
+               {
+                               
+                       this->file = rApplication.getFile();
+                       this->deployed = rApplication.isDeployed();
+               }
+       
+               Application::Application(const char* file)
+               throw(NullPointerException, FileNotFoundException)
+               {
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException(file);
+                               
+                       this->file = file;
+                       this->deployed = false;
+               }
+               
+               Application::~Application()
+               {
+                       // NOTHING TODO
+               }
+                       
+               void Application::deploy(const char* file)
+               throw(NullPointerException, FileNotFoundException, LogicException, MsgException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       // check the parameters
+                               
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException(file);
+                                       
+                       surf_parse_reset_parser();
+                       
+                       // set the begin of the xml process element handler
+                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);
+                               
+                       // set the process arg handler
+                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);
+                               
+                       // set the properties handler
+                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);
+                               
+                       // set the end of the xml process element handler
+                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);
+
+                       surf_parse_open(file);
+                       
+                       // initialize the process factory used by the process handler to build the processes.
+                       ApplicationHandler::onStartDocument();
+                               
+                       if(surf_parse())
+                               throw MsgException("surf_parse() failed");
+                       
+                       surf_parse_close();
+                       
+                       // release the process factory
+                       ApplicationHandler::onEndDocument();    
+                       
+                       this->file = file;
+                       this->deployed = true;
+               }
+               
+               void Application::deploy(void)
+               throw(LogicException, MsgException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       // check the parameters
+                       if(!this->file)
+                               throw LogicException("you must specify the xml file which describe the application\nuse Application::setFile()"); 
+                       
+                       surf_parse_reset_parser();
+                       surfxml_add_callback(STag_surfxml_process_cb_list, ApplicationHandler::onBeginProcess);
+                       surfxml_add_callback(ETag_surfxml_argument_cb_list, ApplicationHandler::onProcessArg);
+                       surfxml_add_callback(STag_surfxml_prop_cb_list, ApplicationHandler::OnProperty);
+                       surfxml_add_callback(ETag_surfxml_process_cb_list, ApplicationHandler::onEndProcess);
+                       
+                       // initialize the process factory used by the process handler to build the processes.
+                       ApplicationHandler::onStartDocument();
+
+                       surf_parse_open(file);
+                       
+                       if(surf_parse())
+                               throw MsgException("surf_parse() failed");
+                       
+                       surf_parse_close();
+                       
+                       this->deployed = true;  
+               }
+               
+               bool Application::isDeployed(void) const
+               {
+                       return this->deployed;
+               }
+               
+               void Application::setFile(const char* file)
+               throw (NullPointerException, FileNotFoundException, LogicException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("your are trying to change the file of an already deployed application");
+                               
+                       // check parameters
+                       
+                       if(!file)
+                               throw NullPointerException("file");
+                       
+                       struct stat statBuf = {0};
+                               
+                       if(stat(file, &statBuf) < 0 || !S_ISREG(statBuf.st_mode))
+                               throw FileNotFoundException("file (file not found)");
+                               
+                       this->file = file;
+                       
+               }
+               
+               const char* Application::getFile(void) const
+               {
+                       return this->file;
+               }
+               
+               const Application& Application::operator = (const Application& rApplication)
+               throw(LogicException)
+               {
+                       // check logic
+                       
+                       if(this->deployed)
+                               throw LogicException("application already deployed");
+                       
+                       this->file = rApplication.getFile();
+                       this->deployed = rApplication.isDeployed();
+                       
+                       return *this;
+               }
+       } // namespace Msg
+} // namespace SimGrid
+
+
+