1 /* $Id: p2_frontend.h,v 1.5 2005-10-14 10:27:18 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.hpp"
30 #include <yaz++/z-assoc.h>
31 #include <yaz++/pdu-assoc.h>
32 #include <yaz++/gdu.h>
33 #include <yaz++/gduqueue.h>
34 #include <yaz++/z-query.h>
39 class P2_ConfigTarget;
40 class P2_ModuleFactory;
44 class P2_BackendResultSet {
46 P2_BackendResultSet();
47 ~P2_BackendResultSet();
48 yazpp_1::Yaz_Z_Query m_query;
49 std::list<std::string> m_db_list;
51 IP2_BackendSet *m_int;
59 P2_Backend(P2_ConfigTarget *cfg, IP2_Backend *backend_interface);
62 std::list<P2_BackendResultSet *>m_resultSets;
63 P2_ConfigTarget *m_configTarget;
68 class P2_Server : public yazpp_1::Z_Assoc {
71 P2_Server(yazpp_1::IPDU_Observable *the_PDU_Observable,
72 yp2::ThreadPoolSocketObserver *m_my_thread,
74 P2_ModuleFactory *modules);
75 P2_Config *lockConfig();
77 std::list<P2_Backend *>m_backend_list;
78 P2_ModuleFactory *m_modules;
80 yazpp_1::IPDU_Observer* sessionNotify(
81 yazpp_1::IPDU_Observable *the_PDU_Observable,
83 void recv_GDU(Z_GDU *apdu, int len);
90 yp2::ThreadPoolSocketObserver *m_my_thread;
91 pthread_mutex_t m_mutex_config;
94 class P2_FrontResultSet {
96 P2_FrontResultSet(const char *id);
98 void setQuery(Z_Query *z_query);
99 void setDatabases(char **db, int num);
100 std::string m_resultSetId;
101 std::vector<std::string> m_db_list;
102 yazpp_1::Yaz_Z_Query m_query;
105 class P2_Msg : public yp2::IThreadPoolMsg {
109 yazpp_1::GDU *m_output;
110 P2_Frontend *m_front;
112 yp2::IThreadPoolMsg *handle();
114 P2_Msg(yazpp_1::GDU *gdu, P2_Frontend *front, P2_Server *server);
118 Z_APDU *frontend_search_resultset(Z_APDU *z_gdu, ODR odr,
119 P2_FrontResultSet **rset);
120 Z_APDU *frontend_present_resultset(Z_APDU *z_gdu, ODR odr,
121 P2_FrontResultSet **rset);
122 Z_APDU *frontend_search_apdu(Z_APDU *z_gdu, ODR odr);
123 Z_APDU *frontend_present_apdu(Z_APDU *z_gdu, ODR odr);
124 P2_Backend *select_backend(std::string db,
125 yazpp_1::Yaz_Z_Query *query,
126 P2_BackendResultSet **bset);
127 P2_Backend *create_backend(std::string db);
130 class P2_Frontend : public yazpp_1::Z_Assoc {
133 P2_Frontend(yazpp_1::IPDU_Observable *the_PDU_Observable,
134 yp2::ThreadPoolSocketObserver *m_my_thread, P2_Server *server);
135 IPDU_Observer* sessionNotify(yazpp_1::IPDU_Observable *the_PDU_Observable,
138 void recv_GDU(Z_GDU *apdu, int len);
141 void timeoutNotify();
142 void connectNotify();
146 std::list<P2_FrontResultSet *> m_resultSets;
149 yazpp_1::GDUQueue m_in_queue;
150 yp2::ThreadPoolSocketObserver *m_my_thread;
153 bool P2_Frontend::search(Z_GDU *z_gdu);
154 bool P2_Frontend::handle_init(Z_GDU *z_gdu);
161 * indent-tabs-mode: nil
163 * vim: shiftwidth=4 tabstop=8 expandtab