Modified for new location of YAZ header files. Experimental threaded
[yazpp-moved-to-github.git] / include / yaz-z-assoc.h
1 /*
2  * Copyright (c) 1998-1999, Index Data.
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  * 
6  * $Id: yaz-z-assoc.h,v 1.5 1999-12-06 13:52:45 adam Exp $
7  */
8
9 #include <yaz/proto.h>
10 #include <yaz/odr.h>
11 #include <yaz-pdu-observer.h>
12
13 /** Z39.50 Assocation.
14     This object implements the client - and server role of a generic
15     Z39.50 Association.
16 */
17 class YAZ_EXPORT Yaz_Z_Assoc : public IYaz_PDU_Observer {
18  public:
19     /// Create object using the PDU Observer specified
20     Yaz_Z_Assoc(IYaz_PDU_Observable *the_PDU_Observable);
21     /// Destroy assocation and close PDU Observer
22     virtual ~Yaz_Z_Assoc();
23     /// Receive PDU
24     void recv_PDU(const char *buf, int len);
25     /// Connect notification
26     virtual void connectNotify() = 0;
27     /// Failure notification
28     virtual void failNotify() = 0;
29     /// Timeout notification
30     virtual void timeoutNotify() = 0;
31     /// Timeout specify
32     void timeout(int timeout);
33     /// Begin Z39.50 client role
34     void client(const char *addr);
35     /// Begin Z39.50 server role
36     void server(const char *addr);
37     /// Close connection
38     void close();
39     /// Decode Z39.50 PDU.
40     Z_APDU *decode_Z_PDU(const char *buf, int len);
41     /// Encode Z39.50 PDU.
42     int encode_Z_PDU(Z_APDU *apdu, char **buf, int *len);
43     /// Send Z39.50 PDU
44     int send_Z_PDU(Z_APDU *apdu);
45     /// Receive Z39.50 PDU
46     virtual void recv_Z_PDU(Z_APDU *apdu) = 0;
47     /// Create Z39.50 PDU with reasonable defaults
48     Z_APDU *create_Z_PDU(int type);
49     /// Request Alloc
50     ODR odr_encode ();
51     ODR odr_decode ();
52     ODR odr_print ();
53
54     /// OtherInformation
55     void get_otherInfoAPDU(Z_APDU *apdu, Z_OtherInformation ***oip);
56     Z_OtherInformationUnit *update_otherInformation (
57         Z_OtherInformation **otherInformationP, int createFlag,
58         int *oid, int categoryValue, int deleteFlag);
59     void set_otherInformationString (
60         Z_OtherInformation **otherInformationP,
61         int *oid, int categoryValue,
62         const char *str);
63     void set_otherInformationString (
64         Z_OtherInformation **otherInformation,
65         int oidval, int categoryValue,
66         const char *str);
67     void set_otherInformationString (
68         Z_APDU *apdu,
69         int oidval, int categoryValue,
70         const char *str);
71     void set_apdu_log(const char *file);
72  private:
73     static int yaz_init_flag;
74     static int yaz_init_func();
75     IYaz_PDU_Observable *m_PDU_Observable;
76     ODR m_odr_in;
77     ODR m_odr_out;
78     ODR m_odr_print;
79     int m_log;
80 };