Remove warnings
[anna.git] / include / anna / comm / AccessPoint.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_AccessPoint_hpp
10 #define anna_comm_AccessPoint_hpp
11
12 #include <sys/un.h>
13
14 #include <anna/core/RuntimeException.hpp>
15
16 #include <anna/comm/INetAddress.hpp>
17
18 namespace anna {
19
20 namespace xml {
21 class Node;
22 }
23
24 namespace comm {
25
26 class Socket;
27
28 /**
29    Estructura para mantener la informacion de los extremos de un Socket.
30
31    Dependiendo del tipo de Socket puede tener un punto local y/o un punto
32    remoto.
33
34    \see Socket
35    \warning This should be internally used
36 */
37 class AccessPoint {
38 public:
39   AccessPoint() : a_path(NULL) {;}
40   AccessPoint(const std::string& path) : a_path(new std::string(path)) {;}
41   AccessPoint(const INetAddress& inetAddress) : a_path(NULL), a_inetAddress(inetAddress) {;}
42
43   ~AccessPoint() { delete a_path;  }
44
45   const INetAddress& getINetAddress() const throw() { return a_inetAddress; }
46   const std::string& getPath() const throw() { return *a_path; }
47
48   void clear() throw() { a_inetAddress.clear(); delete a_path; a_path = NULL; }
49   bool isNull() const throw() { return a_path == NULL && a_inetAddress.isNull(); }
50
51   bool operator == (const AccessPoint&) const throw();
52   AccessPoint& operator = (const INetAddress&) throw();
53   AccessPoint& operator = (const std::string& path) throw();
54   AccessPoint& operator = (const AccessPoint&) throw();
55
56   void asString(std::string& msg) const throw();
57
58   void asXML(const char* name, xml::Node* parent) const throw(RuntimeException);
59
60   std::string serialize() const throw();
61
62   void translate(const Socket&, sockaddr*&, int& len) throw(RuntimeException);
63
64 private:
65   const Socket* a_owner;
66   std::string* a_path;
67   INetAddress a_inetAddress;
68   sockaddr_in a_sockaddr_in;
69   sockaddr_un a_sockaddr_un;
70 };
71
72 }
73 }
74
75 #endif
76