6c73186eca4ce95fff6d9f287d1d5992b9effb26
[metaproxy-moved-to-github.git] / src / p2_frontend.cpp
1 /* $Id: p2_frontend.cpp,v 1.2 2005-10-06 19:33:58 adam Exp $
2    Copyright (c) 1998-2005, Index Data.
3
4 This file is part of the yaz-proxy.
5
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
9 version.
10
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
14 for more details.
15
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
19 02111-1307, USA.
20  */
21
22 #include <yaz/log.h>
23 #include <yaz/diagbib1.h>
24 #include "p2_frontend.h"
25
26 using namespace yazpp_1;
27 using namespace std;
28
29 P2_Frontend::P2_Frontend(IPDU_Observable *the_PDU_Observable,
30                          ThreadPoolSocketObserver 
31                          *my_thread, P2_Server *server)
32     :  Z_Assoc(the_PDU_Observable)
33 {
34     m_my_thread = my_thread;
35     m_server = server;
36     m_no_requests = 0;
37     m_delete_flag = 0;
38     yaz_log(YLOG_LOG, "Construct P2_Frontend=%p", this);
39 }
40
41
42 IPDU_Observer *P2_Frontend::sessionNotify(IPDU_Observable
43                                           *the_PDU_Observable, int fd)
44 {
45     return 0;
46 }
47
48 P2_Frontend::~P2_Frontend()
49 {
50     yaz_log(YLOG_LOG, "Destroy P2_Frontend=%p", this);
51
52     list<P2_FrontResultSet *>::iterator it;
53     
54     for (it = m_resultSets.begin(); it != m_resultSets.end(); it++)
55     {
56         delete *it;
57         *it = 0;
58     }
59 }
60
61 void P2_Frontend::recv_GDU(Z_GDU *z_pdu, int len)
62 {
63     GDU *gdu = new GDU(z_pdu);
64
65     P2_Msg *m = new P2_Msg(gdu, this, m_server);
66     m_no_requests++;
67     m_my_thread->put(m);  
68 }
69
70 void P2_Frontend::failNotify()
71 {
72     m_delete_flag = 1;
73     if (m_no_requests == 0)
74         delete this;
75     
76 }
77
78 void P2_Frontend::timeoutNotify()
79 {
80     m_delete_flag = 1;
81     if (m_no_requests == 0)
82         delete this;
83 }
84
85 void P2_Frontend::connectNotify()
86 {
87
88 }
89
90 /*
91  * Local variables:
92  * c-basic-offset: 4
93  * indent-tabs-mode: nil
94  * End:
95  * vim: shiftwidth=4 tabstop=8 expandtab
96  */