]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPRequest.h
7f3a3a2755a3b4bd1843c0ed63640330b6077a22
[openldap] / contrib / ldapc++ / src / LDAPRequest.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_REQUEST_H
8 #define LDAP_REQUEST_H
9
10 #include <LDAPConstraints.h>
11 #include <LDAPAsynConnection.h>
12 #include <LDAPMessageQueue.h>
13
14 class LDAPUrl;
15
16 /**
17  * For internal use only
18  * 
19  * Each request that is sent to a LDAP-server by this library is
20  * represented by a special object that contains the parameters and some
21  * other info of the request. This virtual class is the common base classe
22  * for these specialized request classes.
23  */
24 class LDAPRequest{
25
26     public :
27         static const int BIND=0;
28         static const int UNBIND=2;
29         static const int SEARCH=3;
30         static const int MODIFY=7;
31         static const int ADD=8;
32                 static const int DELETE=10;
33         static const int COMPARE=14;
34
35         LDAPRequest(const LDAPRequest& req);
36         LDAPRequest(LDAPAsynConnection* conn, 
37                 const LDAPConstraints* cons, bool isReferral=false,
38                 const LDAPRequest* parent=0);
39         virtual ~LDAPRequest();
40         
41         const LDAPConstraints* getConstraints() const;
42         const LDAPAsynConnection* getConnection() const;
43         int getType()const;
44         int getMsgID() const;
45         int getHopCount() const;
46
47         /**
48          * @return The LDAPRequest that has created this object. Or 0 if
49          * this object was not created by another request.
50          */
51         const LDAPRequest* getParent() const;
52
53         /**
54          * @return true if this object was created during the automatic
55          * chasing of referrals. Otherwise false
56          */
57         bool isReferral() const;
58         
59         void unbind() const; 
60
61         /**
62          * This method encodes the request an calls the apprpriate
63          * functions of the C-API to send the Request to a LDAP-Server
64          */
65         virtual LDAPMessageQueue* sendRequest()=0;
66         virtual LDAPRequest* followReferral(LDAPMsg* ref)=0;
67
68         /**
69          * Compare this request with another on. And returns true if they
70          * have the same parameters.
71          */
72         virtual bool equals(const LDAPRequest* req) const;
73
74         bool isCycle() const;
75         
76     protected :
77         bool m_isReferral;
78         int m_requestType;
79         LDAPConstraints *m_cons;
80         LDAPAsynConnection *m_connection;
81         const LDAPRequest* m_parent;
82         int m_hopCount;
83         int m_msgID;  //the associated C-API Message ID
84         LDAPRequest();
85 };
86 #endif //LDAP_REQUEST_H 
87