1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 20 #ifndef _THRIFT_SERVER_H 21 #define _THRIFT_SERVER_H 22 23 #include <glib-object.h> 24 25 #include <thrift/c_glib/processor/thrift_processor.h> 26 #include <thrift/c_glib/transport/thrift_server_transport.h> 27 #include <thrift/c_glib/transport/thrift_transport_factory.h> 28 #include <thrift/c_glib/protocol/thrift_protocol_factory.h> 29 30 G_BEGIN_DECLS 31 32 /*! \file thrift_server.h 33 * \brief Abstract class for Thrift servers. 34 */ 35 36 /* type macros */ 37 #define THRIFT_TYPE_SERVER (thrift_server_get_type ()) 38 #define THRIFT_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_SERVER, ThriftServer)) 39 #define THRIFT_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_SERVER)) 40 #define THRIFT_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_SERVER, ThriftServerClass)) 41 #define THRIFT_IS_SERVER_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_SERVER)) 42 #define THRIFT_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_SERVER, ThriftServerClass)) 43 44 typedef struct _ThriftServer ThriftServer; 45 46 /*! 47 * Thrift Server object 48 */ 49 struct _ThriftServer 50 { 51 GObject parent; 52 53 /* protected */ 54 ThriftProcessor *processor; 55 ThriftServerTransport *server_transport; 56 ThriftTransportFactory *input_transport_factory; 57 ThriftTransportFactory *output_transport_factory; 58 ThriftProtocolFactory *input_protocol_factory; 59 ThriftProtocolFactory *output_protocol_factory; 60 }; 61 62 typedef struct _ThriftServerClass ThriftServerClass; 63 64 /*! 65 * Thrift Server class 66 */ 67 struct _ThriftServerClass 68 { 69 GObjectClass parent; 70 71 /* vtable */ 72 gboolean (*serve) (ThriftServer *server, GError **error); 73 void (*stop) (ThriftServer *server); 74 }; 75 76 /* used by THRIFT_TYPE_SERVER */ 77 GType thrift_server_get_type (void); 78 79 /*! 80 * Processes the request. 81 * \public \memberof ThriftServerClass 82 */ 83 gboolean thrift_server_serve (ThriftServer *server, GError **error); 84 85 /*! 86 * Stop handling requests. 87 */ 88 void thrift_server_stop (ThriftServer *server); 89 90 G_END_DECLS 91 92 #endif /* _THRIFT_SERVER_H */ 93 94