Updated copyright headers.
[yazpp-moved-to-github.git] / include / yazpp / ir-assoc.h
1 /* This file is part of the yazpp toolkit.
2  * Copyright (C) 1998-2008 Index Data and Mike Taylor
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *     * Redistributions of source code must retain the above copyright
8  *       notice, this list of conditions and the following disclaimer.
9  *     * Redistributions in binary form must reproduce the above copyright
10  *       notice, this list of conditions and the following disclaimer in the
11  *       documentation and/or other materials provided with the distribution.
12  *     * Neither the name of Index Data nor the names of its contributors
13  *       may be used to endorse or promote products derived from this
14  *       software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27
28 #include <yazpp/z-assoc.h>
29 #include <yazpp/z-query.h>
30
31 namespace yazpp_1 {
32 /** Information Retrieval Assocation.
33     This object implements the client - and server role of a generic
34     Z39.50 Association.
35 */
36 class YAZ_EXPORT IR_Assoc: public Z_Assoc {
37  public:
38     /// Create object using the PDU Observer specified
39     IR_Assoc(IPDU_Observable *the_PDU_Observable);
40     /// Destroy assocation and close PDU Observer
41     virtual ~IR_Assoc();
42     /// Receive Z39.50 PDU
43     void recv_Z_PDU(Z_APDU *apdu, int len);
44     void recv_GDU(Z_GDU *apdu, int len);
45     /// Set Database Names
46     void set_databaseNames (int num, const char **list);
47     void set_databaseNames(const char *dblist, const char *sep);
48     /// Get Database Names
49     void get_databaseNames (int *num, char ***list);
50
51     void client(const char *addr);
52
53     /// Set Preferred Record Syntax
54     void set_preferredRecordSyntax (int value);
55     void set_preferredRecordSyntax (const char *syntax);
56     /// Get Preferred Record Syntax
57     void get_preferredRecordSyntax (int *val);
58     void get_preferredRecordSyntax (const char **syntax);
59
60     /// Set ElementSetName
61     void set_elementSetName (const char *elementSetName);
62     /// Get ElementSetName
63     void get_elementSetName (const char **elementSetName);
64     void get_elementSetName (Z_ElementSetNames **elementSetNames);
65
66     int get_lastReceived();
67     void set_lastReceived(int lastReceived);
68
69     /// Settings
70     void set_proxy(const char *str);
71     const char *get_proxy();
72     const char *get_host();
73
74     void set_cookie(const char *str);
75     const char *get_cookie();
76
77     /// Send Services
78     int send_initRequest(char* pRefId=NULL);
79     int send_searchRequest(Yaz_Z_Query *query, char* pResultSetId = NULL, char* pRefId = NULL);
80     int send_presentRequest(int start, int number, char* pResultSetId = NULL, char* pRefId = NULL);
81     int send_deleteResultSetRequest(char* pResultSetId = 0, char* pRefId = 0);
82     
83     /// Recv Services
84     virtual void recv_initRequest(Z_InitRequest *initRequest);
85     virtual void recv_initResponse(Z_InitResponse *initResponse);
86     virtual void recv_searchRequest(Z_SearchRequest *searchRequest);
87     virtual void recv_presentRequest(Z_PresentRequest *presentRequest);
88     virtual void recv_searchResponse(Z_SearchResponse *searchResponse);
89     virtual void recv_presentResponse(Z_PresentResponse *presentResponse);
90     virtual void recv_extendedServicesResponse(Z_ExtendedServicesResponse *extendedServicesResponse);
91  private:
92     char *m_proxy;
93     char *m_host;
94     char *m_cookie;
95     int m_num_databaseNames;
96     char **m_databaseNames;
97     char *m_preferredRecordSyntax;
98     Z_ElementSetNames *m_elementSetNames;
99     int m_lastReceived;
100     int m_log;
101 };
102 };
103 /*
104  * Local variables:
105  * c-basic-offset: 4
106  * indent-tabs-mode: nil
107  * End:
108  * vim: shiftwidth=4 tabstop=8 expandtab
109  */
110