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