274b3d54a3e529fd09ee3e233769985a58a4dd4d
[yazproxy-moved-to-github.git] / src / p2_frontend.cpp
1 /* $Id: p2_frontend.cpp,v 1.1 2005-10-05 12:07:14 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                          Msg_Thread *my_thread, P2_Server *server)
31     :  Z_Assoc(the_PDU_Observable)
32 {
33     m_my_thread = my_thread;
34     m_server = server;
35     m_no_requests = 0;
36     m_delete_flag = 0;
37     yaz_log(YLOG_LOG, "Construct P2_Frontend=%p", this);
38 }
39
40
41 IPDU_Observer *P2_Frontend::sessionNotify(IPDU_Observable
42                                           *the_PDU_Observable, int fd)
43 {
44     return 0;
45 }
46
47 P2_Frontend::~P2_Frontend()
48 {
49     yaz_log(YLOG_LOG, "Destroy P2_Frontend=%p", this);
50
51     list<P2_FrontResultSet *>::iterator it;
52     
53     for (it = m_resultSets.begin(); it != m_resultSets.end(); it++)
54     {
55         delete *it;
56         *it = 0;
57     }
58 }
59
60 void P2_Frontend::recv_GDU(Z_GDU *z_pdu, int len)
61 {
62     GDU *gdu = new GDU(z_pdu);
63
64     P2_Msg *m = new P2_Msg(gdu, this, m_server);
65     m_no_requests++;
66     m_my_thread->put(m);  
67 }
68
69 void P2_Frontend::failNotify()
70 {
71     m_delete_flag = 1;
72     if (m_no_requests == 0)
73         delete this;
74     
75 }
76
77 void P2_Frontend::timeoutNotify()
78 {
79     m_delete_flag = 1;
80     if (m_no_requests == 0)
81         delete this;
82 }
83
84 void P2_Frontend::connectNotify()
85 {
86
87 }
88
89 /*
90  * Local variables:
91  * c-basic-offset: 4
92  * indent-tabs-mode: nil
93  * End:
94  * vim: shiftwidth=4 tabstop=8 expandtab
95  */