]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPRequest.h
moved ldap_result() code to the LDAPRequest-Class
[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         LDAPMsg *getNextMessage() const;
44         int getType()const;
45         int getMsgID() const;
46         int getHopCount() const;
47
48         /**
49          * @return The LDAPRequest that has created this object. Or 0 if
50          * this object was not created by another request.
51          */
52         const LDAPRequest* getParent() const;
53
54         /**
55          * @return true if this object was created during the automatic
56          * chasing of referrals. Otherwise false
57          */
58         bool isReferral() const;
59         
60         void unbind() const; 
61
62         /**
63          * This method encodes the request an calls the apprpriate
64          * functions of the C-API to send the Request to a LDAP-Server
65          */
66         virtual LDAPMessageQueue* sendRequest()=0;
67         virtual LDAPRequest* followReferral(LDAPMsg* ref)=0;
68
69         /**
70          * Compare this request with another on. And returns true if they
71          * have the same parameters.
72          */
73         virtual bool equals(const LDAPRequest* req) const;
74
75         bool isCycle() const;
76         
77     protected :
78         bool m_isReferral;
79         int m_requestType;
80         LDAPConstraints *m_cons;
81         LDAPAsynConnection *m_connection;
82         const LDAPRequest* m_parent;
83         int m_hopCount;
84         int m_msgID;  //the associated C-API Message ID
85         LDAPRequest();
86 };
87 #endif //LDAP_REQUEST_H 
88