Remove dynamic exceptions
[anna.git] / include / anna / comm / Status.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef anna_comm_Status_hpp
10 #define anna_comm_Status_hpp
11
12 #include <string>
13
14 namespace anna {
15 namespace comm {
16
17 /**
18    Estados en los que puede estar un proceso desde el punto de vista de las comunicaciones.
19    \see Communicator.
20 */
21 class Status {
22 public:
23   enum _v {
24     Available = 0, /**< Disponible para recibir peticiones */
25     Unavailable = 1, /**< No disponible para recibir peticiones, quizas debido al fallo de un servicio critico */
26     Overload = 2 /**< Sobrecargado */
27   };
28
29   Status() : a_value(Unavailable) {;}
30   Status(const Status& other) : a_value(other.a_value) {;}
31   Status(const _v v) : a_value(v) {;}
32   Status& operator = (const _v v) { a_value = v; return *this; }
33   Status& operator = (const Status& other) { a_value = other.a_value; return *this; }
34
35   bool operator != (const Status& other) const { return a_value != other.a_value;  }
36   bool operator != (const Status::_v v) const { return a_value != v ;  }
37   bool operator == (const Status& other) const { return a_value == other.a_value;  }
38   bool operator == (const Status::_v v) const { return a_value == v ;  }
39
40   _v value() const { return a_value; }
41
42   std::string asString() const ;
43
44 private:
45   _v a_value;
46 };
47
48 }
49 }
50
51
52 #endif
53