0.9.8.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Protocol.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_Protocol_h
30 #define AsyncComm_Protocol_h
31 
32 #include "Event.h"
33 #include "CommHeader.h"
34 #include "CommBuf.h"
35 
36 namespace Hypertable {
37 
42  class CommBuf;
43 
49  class Protocol {
50 
51  public:
52 
54  virtual ~Protocol() { return; }
55 
65  static int32_t response_code(const Event *event);
66 
76  static int32_t response_code(const EventPtr &event) {
77  return response_code(event.get());
78  }
79 
95  static String string_format_message(const Event *event);
96 
112  static String string_format_message(const EventPtr &event) {
113  return string_format_message(event.get());
114  }
115 
128  static CommBufPtr
129  create_error_message(CommHeader &header, int error, const char *msg);
130 
140  virtual const char *command_text(uint64_t command) = 0;
141 
142  };
144 }
145 
146 #endif // AsyncComm_Protocol_h
Network communication event.
Definition: Event.h:54
static int32_t response_code(const Event *event)
Returns the response code from an event event generated in response to a request message.
Definition: Protocol.cc:39
std::string String
A String is simply a typedef to std::string.
Definition: String.h:44
static String string_format_message(const Event *event)
Returns error message decoded standard error MESSAGE generated in response to a request message...
Definition: Protocol.cc:51
std::shared_ptr< Event > EventPtr
Smart pointer to Event.
Definition: Event.h:228
static CommBufPtr create_error_message(CommHeader &header, int error, const char *msg)
Creates a standard error message response.
Definition: Protocol.cc:81
Declarations for Event.
virtual const char * command_text(uint64_t command)=0
Returns the string representation of a command code.
std::shared_ptr< CommBuf > CommBufPtr
Smart pointer to CommBuf.
Definition: CommBuf.h:305
static int32_t response_code(const EventPtr &event)
Returns the response code from an event event generated in response to a request message.
Definition: Protocol.h:76
Hypertable definitions
Header for messages transmitted via AsyncComm.
Definition: CommHeader.h:40
Declarations for CommBuf.
Abstract base class for server protocol drivers.
Definition: Protocol.h:49
static String string_format_message(const EventPtr &event)
Returns error message decoded from standard error MESSAGE generated in response to a request message...
Definition: Protocol.h:112
virtual ~Protocol()
Destructor.
Definition: Protocol.h:54
Declarations for CommHeader.