0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ResponseCallback.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2015 Hypertable, Inc.
3  *
4  * This file is part of Hypertable.
5  *
6  * Hypertable is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 3
9  * of the License, or any later version.
10  *
11  * Hypertable is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301, USA.
20  */
21 
29 #ifndef AsyncComm_RESPONSECALLBACK_H
30 #define AsyncComm_RESPONSECALLBACK_H
31 
32 #include "Common/String.h"
33 
34 #include "Comm.h"
35 #include "Event.h"
36 
37 namespace Hypertable {
38 
47 
48  public:
49 
57  : m_comm(comm), m_event(event) { return; }
58 
61  ResponseCallback() : m_comm(0), m_event(0) { return; }
62 
64  virtual ~ResponseCallback() { return; }
65 
77  virtual int error(int error, const String &msg);
78 
84  virtual int response_ok();
85 
89  void get_address(struct sockaddr_in &addr) {
90  memcpy(&addr, &m_event->addr, sizeof(addr));
91  }
92 
96  const InetAddr get_address() const {
97  return m_event->addr;
98  }
99 
103  EventPtr &event() { return m_event; }
104 
105  protected:
108  };
110 } // namespace Hypertable
111 
112 #endif // AsyncComm_RESPONSECALLBACK_H
const InetAddr get_address() const
Gets the remote address of the requesting client.
virtual ~ResponseCallback()
Destructor.
void get_address(struct sockaddr_in &addr)
Gets the remote address of the requesting client.
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
virtual int response_ok()
Sends a a simple success response back to the client which is just the 4-byte error code Error::OK...
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
Comm * m_comm
Comm pointer.
Declarations for Event.
ResponseCallback(Comm *comm, EventPtr &event)
Constructor.
Encapsulate an internet address.
Definition: InetAddr.h:66
ResponseCallback()
Default constructor.
This class is used to generate and deliver standard responses back to a client.
Hypertable definitions
Entry point to AsyncComm service.
Definition: Comm.h:61
virtual int error(int error, const String &msg)
Sends a standard error response back to the client.
Declarations for Comm.
A String class based on std::string.
EventPtr m_event
Smart pointer to event object.
EventPtr & event()
Get smart pointer to event object that triggered the request.