ANNA Suite  2020b
Multipurpose development suite for Telco applications
Receiver.hpp
Go to the documentation of this file.
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_Receiver_hpp
10 #define anna_comm_Receiver_hpp
11 
12 #include <string>
13 
14 #include <anna/xml/Node.hpp>
15 #include <anna/comm/Server.hpp>
16 
17 namespace anna {
18 
19 namespace comm {
20 
21 class ClientSocket;
22 class Server;
23 class ReceiverFactory;
24 class Message;
25 
33 class Receiver {
34 public:
39  const std::string& getName() const { return a_name; }
40 
50  virtual void apply(ClientSocket& clientSocket, const Message& message) noexcept(false) = 0;
51 
56  virtual void eventBreakConnection(const comm::ClientSocket& clientSocket) {;}
57 
62  virtual void eventBreakLocalConnection(const comm::ClientSocket& clientSocket) {;}
63 
68  virtual void eventCreateConnection(const Server* server) {;}
69 
74  virtual std::string asString() const
75  {
76  std::string msg("anna::comm::Receiver { Name: ");
77  msg += a_name;
78  return msg += " }";
79  }
80 
86  virtual xml::Node* asXML(xml::Node* parent) const noexcept(false) {
87  xml::Node* node = parent->createChild("comm.Receiver");
88  node->createAttribute("Name", a_name);
89  return node;
90  }
91 
92 protected:
97  Receiver(const char* name) : a_name(name) { ; }
98 
102  virtual void initialize() noexcept(false) { ; }
103 
104 private:
105  std::string a_name;
106 
107  friend class ReceiverFactory;
108 
113  friend class ClientSocket;
114 };
115 
116 }
117 }
118 
119 
120 #endif
121 
xml::Attribute * createAttribute(const char *name, const char *value, const Namespace *_namespace=NULL)
Node * createChild(const char *name)
virtual void initialize() noexcept(false)
Definition: Receiver.hpp:102
Definition: Server.hpp:53
virtual void eventBreakConnection(const comm::ClientSocket &clientSocket)
Definition: Receiver.hpp:56
const std::string & getName() const
Definition: Receiver.hpp:39
Definition: Node.hpp:56
virtual xml::Node * asXML(xml::Node *parent) const noexcept(false)
Definition: Receiver.hpp:86
virtual void apply(ClientSocket &clientSocket, const Message &message) noexcept(false)=0
Definition: ClientSocket.hpp:38
virtual void eventCreateConnection(const Server *server)
Definition: Receiver.hpp:68
Definition: Message.hpp:26
Definition: ReceiverFactory.hpp:53
Definition: Receiver.hpp:33
Definition: app.hpp:12
virtual void eventBreakLocalConnection(const comm::ClientSocket &clientSocket)
Definition: Receiver.hpp:62
virtual std::string asString() const
Definition: Receiver.hpp:74
Receiver(const char *name)
Definition: Receiver.hpp:97