00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00035 #ifndef _PROTLIB__MESSAGE_H_
00036 #define _PROTLIB__MESSAGE_H_
00037
00038 #include <pthread.h>
00039 #include <ext/hash_set>
00040
00041 #include "protlib_types.h"
00042 #include "fqueue.h"
00043
00044 namespace protlib {
00045
00050
00051 class FastQueue;
00052
00053
00054 class Context;
00055
00057
00058 class message {
00059 public:
00061
00062 enum type_t {
00063 type_transport,
00064 type_timer,
00065 type_signaling,
00066 type_context,
00067 type_info,
00068 type_routing,
00069 type_API
00070 };
00071
00073
00076 enum qaddr_t {
00077 qaddr_unknown,
00078 qaddr_transport,
00079 qaddr_timer,
00080 qaddr_coordination,
00081 qaddr_coordination_internal,
00082 qaddr_signaling,
00083 qaddr_policy,
00084 qaddr_resource,
00085 qaddr_routing,
00086 qaddr_accounting,
00087 qaddr_router_config,
00088 qaddr_tp_over_sctp,
00089 qaddr_tp_over_tcp,
00090 qaddr_tp_over_tls_tcp,
00091 qaddr_tp_over_udp,
00092 qaddr_tp_queryencap,
00093 qaddr_qos_nslp_timerprocessing,
00094 qaddr_qos_nslp_coordination,
00095 qaddr_qos_nslp_signaling,
00096 qaddr_appl_qos_signaling,
00097 qaddr_qos_appl_signaling,
00098 qaddr_gui,
00099 qaddr_api_0,
00100 qaddr_api_1,
00101 qaddr_api_2,
00102 qaddr_api_3,
00103 qaddr_api_4,
00104 qaddr_api_5,
00105 qaddr_api_6,
00106 qaddr_api_7,
00107 qaddr_api_wrapper_input,
00108 qaddr_tp_over_uds,
00109 qaddr_uds_appl_qos
00110 };
00111
00113
00120 typedef gp_id_t id_t;
00122 message(type_t t, qaddr_t s = qaddr_unknown, id_t id = 0);
00124 virtual ~message();
00126 id_t get_id() const;
00128 id_t set_id(id_t id);
00130 id_t new_id();
00132 type_t get_type() const;
00134 FastQueue *get_source_queue() const;
00136 qaddr_t get_source() const;
00138 qaddr_t set_source(qaddr_t s);
00140 const char* get_qaddr_name() const;
00142 static const char* get_qaddr_name(qaddr_t s);
00144 const char* get_type_name() const { return type_string[type]; }
00146 static const char* get_type_name(type_t t) { return type_string[t]; }
00148 bool send(qaddr_t src, FastQueue* destqueue, bool exp = false);
00150 bool send(qaddr_t src, qaddr_t dest, bool exp = false);
00151
00153 bool send_to(qaddr_t dest, bool exp = false);
00154 bool send_to(FastQueue* destqueue, bool exp = false);
00155
00157 bool send_back(qaddr_t from, bool exp = false);
00159
00160 void send_or_delete(qaddr_t src, qaddr_t dest, bool exp = false) { if (!send(src,dest,exp)) delete this; }
00161 void send_to_or_delete(qaddr_t dest, bool exp = false) { if (!send_to(dest,exp)) delete this; }
00162 void send_back_or_delete(qaddr_t src, bool exp = false) { if (!send_back(src,exp)) delete this; }
00164
00165 virtual void clear_pointers();
00166 private:
00167 const type_t type;
00168 qaddr_t source;
00169 id_t msg_id;
00171 static const char* const qaddr_string[];
00173 static const char* const type_string[];
00174 };
00175
00176
00177
00179
00180 }
00181
00182 namespace __gnu_cxx {
00183
00185
00186 template <> struct hash<protlib::message*> {
00187 inline size_t operator()(protlib::message* m) const { return (size_t)m; }
00188 };
00189
00190 }
00191
00192 #endif // _PROTLIB__MESSAGE_H_