Remove dynamic exceptions
[anna.git] / include / anna / app / Application.hpp
index 153f5b9..8e868a6 100644 (file)
@@ -1,37 +1,9 @@
-// ANNA - Anna is Not 'N' Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// https://bitbucket.org/testillano/anna
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-//          cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
 
 
 #ifndef anna_app_Application_hpp
@@ -53,13 +25,12 @@ class Component;
 struct functions;
 
 /**
-   Abstraccion de la aplicacion.
+   Application abstraction.
 
-   Mantiene la informacion de todos los recursos usados (version, titulo, linea de comandos,
-   threads, etc ...) por nuestras aplicaciones.
+   Gather all the information of resources (version, title, command line,
+   threads, etc ...) used by our applications.
 
-   Slo puede haber una nica instancia de la aplicacio, que seria accesible mediante el
-   metodo anna::functions::getApp.
+   Only one single instance could exists for the application, accessed by mean anna::functions::getApp.
 */
 class Application {
 public:
@@ -72,12 +43,11 @@ public:
   /**
      Constructor.
 
-     @param shortName Nombre logico de esta instancia.
-     @param title Titulo de la aplicacion que aparecera al arrancar.
-     @param version version de este programa. Aconsejamos el forma X.YRZZ. Donde X es la
-     version principal, Y la version secundaria y ZZ es el numero de entrega realizada.
-     \param date Fecha de realizacion del componente. Normalmente sera el contenido de la macro __DATE__.
-     \param time Hora de realizacion del componente. Normalmente sera el contenido de la macro __TIME__.
+     @param shortName Instance logical name.
+     @param title Application title (appears when the application starts).
+     @param version Program version (recommended X.YRZZn with X = main version, Y = secondary version, ZZ = delivery number
+     \param date Component build date. Normally the macro __DATE__.
+     \param time Component build time. Normally the macro __TIME__.
   */
   Application(const char* shortName, const char* title, const char* version, const char* date = NULL, const char* time = NULL);
 
@@ -86,36 +56,36 @@ public:
   */
   virtual ~Application() { a_components.clear(); }
 
-  // Accesores
+  // Getters
   /**
-     Devuelve el nombre corto indicado en el constructor.
-     \return El nombre corto indicado en el constructor.
+     Short name given in constructor.
+     \return Short name given in constructor.
   */
-  const char* getShortName() const throw() { return a_shortName; }
+  const char* getShortName() const { return a_shortName; }
 
   /**
-     Devuelve la version indicado en el contructor de esta aplicacion.
-     \return La version indicado en el contructor de esta aplicacion.
+     Version given in constructor.
+     \return Version given in constructor.
   */
-  const std::string& getVersion() const throw() { return a_version; }
+  const std::string& getVersion() const { return a_version; }
 
   /**
      Devuelve el titulo indicado en el contructor de esta aplicacion.
      \return el titulo indicado en el contructor de esta aplicacion.
   */
-  const std::string& getTitle() const throw() { return a_title; }
+  const std::string& getTitle() const { return a_title; }
 
   /**
      Devuelve el pid asignado por el sistema operativo a la aplicacion que estamos ejecutando.
      @return El pid asignado por el sistema operativo a la aplicacion que estamos ejecutando.
   */
-  pid_t getPid() const throw() { return a_pid; }
+  pid_t getPid() const { return a_pid; }
 
   /**
      Activa la salida por pantalla del mensaje referente a la licencia GPL 3.0.
      \warning Para que tenga efecto debe ser invocado antes de ejecutar el metodo Application::start.
   */
-  void activateGeneralPublicLicense() throw() { a_enableGPL = true; }
+  void activateGeneralPublicLicense() { a_enableGPL = true; }
 
   /**
    * Crea un nuevo proceso a partir de este usando el metodo \em fork.
@@ -129,50 +99,50 @@ public:
    * Para saber en cual de los procesos
    * \return La instancia de la nueva aplicacion.
    */
-  Application& clone() throw(RuntimeException);
+  Application& clone() noexcept(false);
 
   /**
      Devuelve la instancia del componente que corresponde con el nombre recibido.
      \return La instancia del componente que corresponde con el nombre recibido. Puede ser NULL si no
      hay ningun componente asociado a la �ta aplicacion que corresponda con el nombre.
   */
-  Component* find(const char* className) throw();
+  Component* find(const char* className) ;
 
   /**
      Inicializa los elementos propios de nuestra aplicacio, invoca al metodo #initialize
      e invoca al metodo #run.
   */
-  void start() throw(RuntimeException);
+  void start() noexcept(false);
 
   /**
      Devuelve un iterador al primer componente definido en la aplicacion.
      \return un iterador al primer componente definido en la aplicacion.
   */
-  const_iterator begin() const throw() { return a_components.begin(); }
+  const_iterator begin() const { return a_components.begin(); }
 
   /**
      Devuelve un iterador al primer componente definido en la aplicacion.
      \return un iterador al primer componente definido en la aplicacion.
   */
-  iterator begin() throw() { return a_components.begin(); }
+  iterator begin() { return a_components.begin(); }
 
   /**
      Devuelve un iterador al ultimo componente definido en la aplicacion.
      \return un iterador al ultimo componente definido en la aplicacion.
   */
-  const_iterator end() const throw() { return a_components.end(); }
+  const_iterator end() const { return a_components.end(); }
 
   /**
      Devuelve un iterador al ultimo componente definido en la aplicacion.
      \return un iterador al ultimo componente definido en la aplicacion.
   */
-  iterator end() throw() { return a_components.end(); }
+  iterator end() { return a_components.end(); }
 
   /**
      Vuelva un documento XML con el contexto de la aplicacion.
      \param file Ruta completa del fichero en el que grabar el contexto de la aplicacion.
   */
-  void writeContext(const std::string& file) throw(RuntimeException);
+  void writeContext(const std::string& file) noexcept(false);
 
   /**
      metodo que puede ser reescrito en las clases heredadas de Application y que nos
@@ -181,46 +151,46 @@ public:
      \warning En el momento de invocar a esta funcin los componentes (\see Component) pueden no
      estar disponibles.
   */
-  virtual void initialize() throw(RuntimeException) {;}
+  virtual void initialize() noexcept(false) {;}
 
   /**
      Devuelve si esta aplicacion tiene soporto para comunicaciones entre procesos.
      \return \em true si la aplicacion tiene soporta para comunicacion entre proceso o \em false
      en otro caso.
   */
-  virtual bool supportCommunication() const throw() { return false; }
+  virtual bool supportCommunication() const { return false; }
 
   /**
-   * Este método se invocará cuando alguna capa superior a ésta detecte un problema tan grave
-   * como para parar la aplicación de forma súbita.
+   * Este m�todo se invocar� cuando alguna capa superior a �sta detecte un problema tan grave
+   * como para parar la aplicaci�n de forma s�bita.
    * \param className Nombre de la clase que genera el evento.
    *
-   * \warning En el momento de invocar a este método la aplicación puede estar en un estado
-   * no muy estable por lo que se deberían minizar las operaciones a realizar para evitar
-   * bloquear la aplicación.
+   * \warning En el momento de invocar a este m�todo la aplicaci�n puede estar en un estado
+   * no muy estable por lo que se deberan minizar las operaciones a realizar para evitar
+   * bloquear la aplicacin.
    */
-  virtual void eventAbnormalTermination(const char* className) throw() { ; }
+  virtual void eventAbnormalTermination(const char* className) { ; }
 
   /**
      Devuelve una cadena con la informacion referente a esta instancia.
      \param parent Nodo XML del que dependende la informacion.
      @return Una cadena con la informacion referente a esta instancia.
   */
-  virtual xml::Node* asXML(xml::Node* parent) const throw();
+  virtual xml::Node* asXML(xml::Node* parent) const ;
 
   /**
      Devuelve el objeto sobre el que esta posicionado el iterator recibido como parametro.
      \param ii Iterator que deberia estar comprendido entre #begin y #end.
      \return El objeto sobre el que esta posicionado el iterator recibido como parametro.
   */
-  static const Component* component(const_iterator& ii) throw() { return *ii; }
+  static const Component* component(const_iterator& ii) { return *ii; }
 
   /**
      Devuelve el objeto sobre el que esta posicionado el iterator recibido como parametro.
      \param ii Iterator que deberia estar comprendido entre #begin y #end.
      \return El objeto sobre el que esta posicionado el iterator recibido como parametro.
   */
-  static Component* component(iterator& ii) throw() { return *ii; }
+  static Component* component(iterator& ii) { return *ii; }
 
 protected:
   static Application* st_application;
@@ -228,102 +198,102 @@ protected:
   /**
      metodo que debemos implementar para ejecutar nuestra aplicacion.
   */
-  virtual void run() throw(RuntimeException) = 0;
+  virtual void run() noexcept(false) = 0;
 
   /**
      Handler for SIGUSR1. Application context written by default.
   */
-  virtual void signalUSR1() throw(RuntimeException);
+  virtual void signalUSR1() noexcept(false);
 
   /**
      Handler for SIGUSR2. Nothing done by default.
   */
-  virtual void signalUSR2() throw(RuntimeException);
+  virtual void signalUSR2() noexcept(false);
 
   /**
      Metodo manejador que podemos re-escribir para tratar la recepcion de la senhal SIGTERM.
   */
-  virtual void signalTerminate() throw(RuntimeException) {;}
+  virtual void signalTerminate() noexcept(false) {;}
 
   /**
    * Metodo que debemos implementar en la clase heredada para tratar el proceso de clonado de
    * esta aplicacion desde el punto de vista del proceso original.
    * \warning Si se detecta algun error terminara abortara la ejecucion del proceso hijo.
    */
-  virtual void do_cloneParent() throw(RuntimeException) {;}
+  virtual void do_cloneParent() noexcept(false) {;}
 
   /**
    * Metodo que debemos implementar en la clase heredada para tratar el proceso de clonado de
    * esta aplicacion desde el punto de vista del proceso hijo.
    * \warning Si se detecta algun error terminara abortara la ejecucion de este proceso.
    */
-  virtual void do_cloneChild() throw(RuntimeException) {;}
+  virtual void do_cloneChild() noexcept(false) {;}
 
   /**
      Devuelve un iterador al primer proceso hijo creado por la aplicacion (ver #clone),
      \return un iterador al primer proceso hijo definido en la aplicacion.
   */
-  pid_iterator pid_begin() throw() { return a_pids.begin(); }
+  pid_iterator pid_begin() { return a_pids.begin(); }
 
   /**
      Devuelve un iterador al final de lista lista de procesos hijos creados por la aplicacion (ver #clone).
      \return un iterador al primer proceso hijo definido en la aplicacion.
   */
-  pid_iterator pid_end() throw() { return a_pids.end(); }
+  pid_iterator pid_end() { return a_pids.end(); }
 
   /**
    * Devuelve el numero de procesos hijos.
    * \return el numero de procesos hijos.
    */
-  int pid_size() const throw() { return a_pids.size(); }
+  int pid_size() const { return a_pids.size(); }
 
   /**
      Devuelve un iterador al primer proceso hijo creado por la aplicacion (ver #clone),
      \return un iterador al primer proceso hijo definido en la aplicacion.
   */
-  const_pid_iterator pid_begin() const throw() { return a_pids.begin(); }
+  const_pid_iterator pid_begin() const { return a_pids.begin(); }
 
   /**
      Devuelve un iterador al final de lista lista de procesos hijos creados por la aplicacion (ver #clone).
      \return un iterador al primer proceso hijo definido en la aplicacion.
   */
-  const_pid_iterator pid_end() const throw() { return a_pids.end(); }
+  const_pid_iterator pid_end() const { return a_pids.end(); }
 
   /**
      Devuelve el PID sobre el que esta posicionado el iterator recibido como parametro.
      \param ii Iterator que deberia estar comprendido entre #pid_begin y #pid_end.
      \return El objeto sobre el que esta posicionado el iterator recibido como parametro.
   */
-  static pid_t pid(pid_iterator& ii) throw() { return *ii; }
+  static pid_t pid(pid_iterator& ii) { return *ii; }
 
   /**
      Devuelve el PID sobre el que esta posicionado el iterator recibido como parametro.
      \param ii Iterator que deberia estar comprendido entre #pid_begin y #pid_end.
      \return El objeto sobre el que esta posicionado el iterator recibido como parametro.
   */
-  static pid_t pid(const_pid_iterator& ii) throw() { return *ii; }
+  static pid_t pid(const_pid_iterator& ii) { return *ii; }
 
 private:
-  bool a_running;
-  std::string a_version;
   const std::string a_title;
   std::vector <Component*> a_components;
   pid_t a_pid;
   const char* a_shortName;
+  bool a_running;
+  std::string a_version;
   bool a_enableGPL;
   pid_container a_pids;
 
-  void attach(Component*) throw(RuntimeException);
-  void detach(Component*) throw(RuntimeException);
+  void attach(Component*) noexcept(false);
+  void detach(Component*) noexcept(false);
 
-  void startComponents() throw(RuntimeException);
-  void stopComponents() throw(RuntimeException);
-  void sendSignalToChilds(const int signal) throw();
+  void startComponents() noexcept(false);
+  void stopComponents() noexcept(false);
+  void sendSignalToChilds(const int signal) ;
 
-  void signalUSR(int) throw(RuntimeException);
-  static void handlerSignalUSR(int) throw();
-  static void handlerSignalTerminate(int) throw();
-  static void handlerChildTerminate(int sig) throw();
+  void signalUSR(int) noexcept(false);
+  static void handlerSignalUSR(int) ;
+  static void handlerSignalTerminate(int) ;
+  static void handlerChildTerminate(int sig) ;
 
   friend class Component;  // Para poder acceder a los metodo attach y detach
   friend struct functions;