]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPMessage.h
Entry rwlock is no longer needed as concurrency is managed
[openldap] / contrib / ldapc++ / src / LDAPMessage.h
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #ifndef LDAP_MSG_H
8 #define LDAP_MSG_H
9 #include <ldap.h>
10
11 #include <LDAPControlSet.h>
12
13 class LDAPRequest;
14 /**
15  * This class represents any type of LDAP- Message returned 
16  * from the server.
17  *
18  * This class is never not instantiated directly. Only
19  * its subclasses are used. The main feature of this class is the
20  * static method create() (see below)
21  */
22 class LDAPMsg{
23     public:
24         //public Constants defining the Message types
25         static const int BIND_RESPONSE=LDAP_RES_BIND;
26         static const int SEARCH_ENTRY=LDAP_RES_SEARCH_ENTRY;
27         static const int SEARCH_DONE=LDAP_RES_SEARCH_RESULT;
28         static const int SEARCH_REFERENCE=LDAP_RES_SEARCH_REFERENCE;
29         static const int MODIFY_RESPONSE=LDAP_RES_MODIFY;
30         static const int ADD_RESPONSE=LDAP_RES_ADD;
31         static const int DEL_RESPONSE=LDAP_RES_DELETE;
32         static const int MODDN_RESPONSE=LDAP_RES_MODDN;
33         static const int COMPARE_RESPONSE=LDAP_RES_COMPARE;
34         static const int EXTENDED_RESPONSE=LDAP_RES_EXTENDED;
35        
36         /**
37          * The destructor has no implemenation, because this is an abstract
38          * class.
39          */
40         virtual ~LDAPMsg() {}
41
42         /**
43          * This method is used by the library to parse the results returned
44          * by the C-API.
45          *
46          * Based on msgtype-Value of the *msg-Parameter this method creates
47          * an Object of one of the subtypes of LDAPMsg (e.g. LDAPSearchResult
48          * or LDAPResult) that represents the same Message as the
49          * *msg-Parameter. *msg is e.g. a Message returned by the C-API's
50          * ldap_result call.
51          * @param req   The LDAPRequest-object this result message is
52          *          associated with.
53          * @param msg   The LDAPMessage-structure from the C-API that
54          *          contains the LDAP-message to parse.
55          * @return An Object of one of the subtypes of this class. It
56          *          contains the parsed LDAP-message.
57          */
58         static LDAPMsg* create(const LDAPRequest *req, LDAPMessage *msg);   
59         
60         /**
61          * @returns The Type of message that this object contains. Possible
62          *          values are: <BR>
63          *          BIND_RESPONSE <BR>
64          *          SEARCH_ENTRY  <BR>       
65          *          SEARCH_DONE   <BR>      
66          *          SEARCH_REFERENCE   <BR>      
67          *          MODIFY_RESPONSE     <BR>    
68          *          ADD_RESPONSE       <BR>  
69          *          DEL_RESPONSE       <BR>  
70          *          MODDN_RESPONSE     <BR>    
71          *          COMPARE_RESPONSE   <BR>
72          *          EXTENDED_REPONSE   <BR>      
73          */
74         int getMessageType();
75         
76         /**
77          * @returns The message-ID that the C-API return for the
78          *      Result-message. 
79          */
80         int getMsgID();
81
82         /**
83          * @returns If any Control was sent back by the server this method
84          *       returns true. Otherwise false is returned.
85          */
86         bool hasControls() const;
87
88         /**
89          * @returns Server controls that were sent back by the server.
90          * @note This feature is not test well yet.
91          */
92         const LDAPControlSet& getSrvControls() const;
93     
94     protected:
95         /**
96          * This constructor make a copy of a LDAPMsg-pointer. The object
97          * itself (no the pointer) is copied.
98          * Only for internal use.
99          */
100         LDAPMsg(LDAPMessage *msg);
101        
102         /**
103          * This attribute stores Server-Control that were returned with the
104          * message.
105          */
106         LDAPControlSet m_srvControls;
107         
108         bool m_hasControls;
109
110     private:
111         int msgType;
112         int msgID;
113 };
114 #endif //ifndef LDAP_MSG_H