Fix C++ compiles on newer GCC
[yazpp-moved-to-github.git] / include / yaz++ / z-assoc.h
1 /*
2  * Copyright (c) 1998-2000, Index Data.
3  * See the file LICENSE for details.
4  * 
5  * $Id: z-assoc.h,v 1.3 2003-10-10 12:37:26 adam Exp $
6  */
7
8 #ifndef YAZ_Z_ASSOC_INCLUDED
9 #define YAZ_Z_ASSOC_INCLUDED
10
11 #include <yaz/proto.h>
12 #include <yaz/odr.h>
13 #include <yaz++/pdu-observer.h>
14
15 /** Z39.50 Assocation.
16     This object implements the client - and server role of a generic
17     Z39.50 Association.
18 */
19 class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer {
20  public:
21     /// Create object using the PDU Observer specified
22     Yaz_Z_Assoc(IYaz_PDU_Observable *the_PDU_Observable);
23     /// Destroy assocation and close PDU Observer
24     virtual ~Yaz_Z_Assoc();
25     /// Receive PDU
26     void recv_PDU(const char *buf, int len);
27     /// Connect notification
28     virtual void connectNotify() = 0;
29     /// Failure notification
30     virtual void failNotify() = 0;
31     /// Timeout notification
32     virtual void timeoutNotify() = 0;
33     /// Timeout specify
34     void timeout(int timeout);
35     /// Begin Z39.50 client role
36     int client(const char *addr);
37     /// Begin Z39.50 server role
38     void server(const char *addr);
39     /// Close connection
40     void close();
41     /// Decode Z39.50 PDU.
42     Z_APDU *decode_Z_PDU(const char *buf, int len);
43     /// Encode Z39.50 PDU.
44     int encode_Z_PDU(Z_APDU *apdu, char **buf, int *len);
45     /// Send Z39.50 PDU
46     int send_Z_PDU(Z_APDU *apdu, int *len);
47     /// Receive Z39.50 PDU
48     virtual void recv_Z_PDU(Z_APDU *apdu, int len) = 0;
49     /// Create Z39.50 PDU with reasonable defaults
50     Z_APDU *create_Z_PDU(int type);
51     /// Request Alloc
52     ODR odr_encode ();
53     ODR odr_decode ();
54     ODR odr_print ();
55
56     void set_APDU_log(const char *fname);
57     const char *get_APDU_log();
58
59     /// OtherInformation
60     void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip);
61     Z_OtherInformationUnit *update_otherInformation (
62         Z_OtherInformation **otherInformationP, int createFlag,
63         int *oid, int categoryValue, int deleteFlag);
64     void set_otherInformationString (
65         Z_OtherInformation **otherInformationP,
66         int *oid, int categoryValue,
67         const char *str);
68     void set_otherInformationString (
69         Z_OtherInformation **otherInformation,
70         int oidval, int categoryValue,
71         const char *str);
72     void set_otherInformationString (
73         Z_APDU *apdu,
74         int oidval, int categoryValue,
75         const char *str);
76
77     Z_ReferenceId *getRefID(char* str);
78     Z_ReferenceId **get_referenceIdP(Z_APDU *apdu);
79     void transfer_referenceId(Z_APDU *from, Z_APDU *to);
80
81     const char *get_hostname();
82
83  private:
84     static int yaz_init_flag;
85     static int yaz_init_func();
86     IYaz_PDU_Observable *m_PDU_Observable;
87     ODR m_odr_in;
88     ODR m_odr_out;
89     ODR m_odr_print;
90     int m_log;
91     FILE *m_APDU_file;
92     char *m_APDU_fname;
93     char *m_hostname;
94 };
95
96 #endif