2 * thrift_multiplexed_processor.h
4 * Created on: 14 sept. 2017
8 #ifndef _THRIFT_MULTIPLEXED_MULTIPLEXED_PROCESSOR_H_
9 #define _THRIFT_MULTIPLEXED_MULTIPLEXED_PROCESSOR_H_
12 #include <glib-object.h>
14 #include <thrift/c_glib/processor/thrift_processor.h>
19 /*! \file thrift_multiplexed_processor.h
20 * \brief The multiplexed processor for c_glib.
24 #define THRIFT_TYPE_MULTIPLEXED_PROCESSOR (thrift_multiplexed_processor_get_type ())
25 #define THRIFT_MULTIPLEXED_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THRIFT_TYPE_MULTIPLEXED_PROCESSOR, ThriftMultiplexedProcessor))
26 #define THRIFT_IS_MULTIPLEXED_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THRIFT_TYPE_MULTIPLEXED_PROCESSOR))
27 #define THRIFT_MULTIPLEXED_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), THRIFT_TYPE_MULTIPLEXED_PROCESSOR, ThriftMultiplexedProcessorClass))
28 #define THRIFT_IS_MULTIPLEXED_PROCESSOR_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE ((c), THRIFT_TYPE_MULTIPLEXED_PROCESSOR))
29 #define THRIFT_MULTIPLEXED_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THRIFT_TYPE_MULTIPLEXED_PROCESSOR, ThriftMultiplexedProcessorClass))
31 /* define the GError domain string */
32 #define THRIFT_MULTIPLEXED_PROCESSOR_ERROR_DOMAIN "thrift-multiplexed-processor-error-quark"
36 * Thrift MultiplexedProcessor object
38 struct _ThriftMultiplexedProcessor
40 ThriftProcessor parent
;
43 gchar
* default_processor_name
;
44 GHashTable
*multiplexed_services
;
46 typedef struct _ThriftMultiplexedProcessor ThriftMultiplexedProcessor
;
49 * Thrift MultiplexedProcessor class
51 struct _ThriftMultiplexedProcessorClass
53 ThriftProcessorClass parent
;
55 gboolean (* register_processor
) (ThriftProcessor
*self
, const gchar
* multiplexed_processor_name
, ThriftProcessor
* multiplexed_processor
, GError
**error
);
58 typedef struct _ThriftMultiplexedProcessorClass ThriftMultiplexedProcessorClass
;
60 /* used by THRIFT_TYPE_MULTIPLEXED_PROCESSOR */
61 GType
thrift_multiplexed_processor_get_type (void);
64 * Processes the request.
65 * \public \memberof ThriftMultiplexedProcessorClass
67 gboolean
thrift_multiplexed_processor_process (ThriftMultiplexedProcessor
*processor
,
68 ThriftProtocol
*in
, ThriftProtocol
*out
,
75 * @brief Registers a processor in the multiplexed processor under its name. It
76 * will take a reference to the processor so refcount will be incremented.
77 * It will also be decremented on object destruction.
79 * The first registered processor becomes default. But you can override it with
82 * It returns a compliant error if it cannot be registered.
84 * @param processor Pointer to the multiplexed processor.
85 * @param multiplexed_processor_name Name of the processor you want to register
86 * @param multiplexed_processor Pointer to implemented processor you want multiplex.
87 * @param error Error object where we should store errors.
89 * @see https://developer.gnome.org/glib/stable/glib-Error-Reporting.html#g-set-error
91 gboolean
thrift_multiplexed_processor_register_processor(ThriftProcessor
*processor
, const gchar
* multiplexed_processor_name
, ThriftProcessor
* multiplexed_processor
, GError
**error
);
94 /* define error/exception types */
97 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_UNKNOWN
,
98 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_SERVICE_UNAVAILABLE
,
99 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_MESSAGE_TYPE
,
100 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_MESSAGE_WRONGLY_MULTIPLEXED
,
101 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_SEND
,
102 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_RECEIVE
,
103 THRIFT_MULTIPLEXED_PROCESSOR_ERROR_CLOSE
104 } ThriftMultiplexedProcessorError
;
107 GQuark
thrift_multiplexed_processor_error_quark (void);
108 #define THRIFT_MULTIPLEXED_PROCESSOR_ERROR (thrift_multiplexed_processor_error_quark ())
114 #endif /* _THRIFT_MULTIPLEXED_MULTIPLEXED_PROCESSOR_H_ */