1 /* $Id: p2_frontend.h,v 1.2 2005-10-06 19:33:58 adam Exp $
2 Copyright (c) 1998-2005, Index Data.
4 This file is part of the yaz-proxy.
6 YAZ proxy is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2, or (at your option) any later
11 YAZ proxy is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with YAZ proxy; see the file LICENSE. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
29 #include "thread_pool_observer.h"
30 #include <yaz++/z-assoc.h>
31 #include <yaz++/pdu-assoc.h>
32 #include <yaz++/gdu.h>
33 #include <yaz++/z-query.h>
38 class P2_ConfigTarget;
39 class P2_ModuleFactory;
43 class P2_BackendResultSet {
45 P2_BackendResultSet();
46 ~P2_BackendResultSet();
47 yazpp_1::Yaz_Z_Query m_query;
48 std::list<std::string> m_db_list;
50 IP2_BackendSet *m_int;
58 P2_Backend(P2_ConfigTarget *cfg, IP2_Backend *backend_interface);
61 std::list<P2_BackendResultSet *>m_resultSets;
62 P2_ConfigTarget *m_configTarget;
67 class P2_Server : public yazpp_1::Z_Assoc {
70 P2_Server(yazpp_1::IPDU_Observable *the_PDU_Observable,
71 ThreadPoolSocketObserver *m_my_thread,
73 P2_ModuleFactory *modules);
74 P2_Config *lockConfig();
76 std::list<P2_Backend *>m_backend_list;
77 P2_ModuleFactory *m_modules;
79 yazpp_1::IPDU_Observer* sessionNotify(
80 yazpp_1::IPDU_Observable *the_PDU_Observable,
82 void recv_GDU(Z_GDU *apdu, int len);
89 ThreadPoolSocketObserver *m_my_thread;
90 pthread_mutex_t m_mutex_config;
93 class P2_FrontResultSet {
95 P2_FrontResultSet(const char *id);
97 void setQuery(Z_Query *z_query);
98 void setDatabases(char **db, int num);
99 std::string m_resultSetId;
100 std::vector<std::string> m_db_list;
101 yazpp_1::Yaz_Z_Query m_query;
104 class P2_Msg : public IThreadPoolMsg {
108 yazpp_1::GDU *m_output;
109 P2_Frontend *m_front;
111 IThreadPoolMsg *handle();
113 P2_Msg(yazpp_1::GDU *gdu, P2_Frontend *front, P2_Server *server);
117 Z_APDU *frontend_search_resultset(Z_APDU *z_gdu, ODR odr,
118 P2_FrontResultSet **rset);
119 Z_APDU *frontend_present_resultset(Z_APDU *z_gdu, ODR odr,
120 P2_FrontResultSet **rset);
121 Z_APDU *frontend_search_apdu(Z_APDU *z_gdu, ODR odr);
122 Z_APDU *frontend_present_apdu(Z_APDU *z_gdu, ODR odr);
123 P2_Backend *select_backend(std::string db,
124 yazpp_1::Yaz_Z_Query *query,
125 P2_BackendResultSet **bset);
126 P2_Backend *create_backend(std::string db);
129 class P2_Frontend : public yazpp_1::Z_Assoc {
132 P2_Frontend(yazpp_1::IPDU_Observable *the_PDU_Observable,
133 ThreadPoolSocketObserver *m_my_thread, P2_Server *server);
134 IPDU_Observer* sessionNotify(yazpp_1::IPDU_Observable *the_PDU_Observable,
137 void recv_GDU(Z_GDU *apdu, int len);
140 void timeoutNotify();
141 void connectNotify();
145 std::list<P2_FrontResultSet *> m_resultSets;
148 yazpp_1::GDUQueue m_in_queue;
149 ThreadPoolSocketObserver *m_my_thread;
152 bool P2_Frontend::search(Z_GDU *z_gdu);
153 bool P2_Frontend::handle_init(Z_GDU *z_gdu);
160 * indent-tabs-mode: nil
162 * vim: shiftwidth=4 tabstop=8 expandtab