1// $OpenLDAP$
2/*
3 * Copyright 2000-2011 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5 */
6
7
8#ifndef LDAP_MESSAGE_QUEUE_H
9#define LDAP_MESSAGE_QUEUE_H
10
11#include <stack>
12
13#include <LDAPUrlList.h>
14#include <LDAPMessage.h>
15
16class LDAPAsynConnection;
17class LDAPRequest;
18class LDAPSearchRequest;
19class LDAPUrl;
20typedef std::stack<LDAPRequest*> LDAPRequestStack;
21typedef std::list<LDAPRequest*> LDAPRequestList;
22
23/**
24 * This class is created for the asynchronous LDAP-operations. And can be
25 * used by the client to retrieve the results of an operation.
26 */
27class LDAPMessageQueue{
28    public :
29
30        /**
31         * This creates a new LDAPMessageQueue. For a LDAP-request
32         *
33         * @param conn  The Request for that is queue can be used to get
34         *              the results.
35         */
36        LDAPMessageQueue(LDAPRequest *conn);
37        /**
38         * Destructor
39         */
40        ~LDAPMessageQueue();
41
42        /**
43         * This method reads exactly one Message from the results of a
44         * Request.
45         * @throws LDAPException
46         * @return A pointer to an object of one of the classes that were
47         *          derived from LDAPMsg. The user has to cast it to the
48         *          correct type (e.g. LDAPResult or LDAPSearchResult)
49         */
50        LDAPMsg* getNext();
51
52        /**
53         * For internat use only.
54         *
55         * The method is used to start the automatic referral chasing
56         */
57        LDAPRequest* chaseReferral(LDAPMsg* ref);
58
59        /**
60         * For internal use only
61         *
62         * The referral chasing algorithm needs this method to see the
63         * currently active requests.
64         */
65        LDAPRequestStack* getRequestStack();
66
67    private :
68        LDAPRequestStack m_activeReq;
69        LDAPRequestList m_issuedReq;
70};
71#endif //ifndef LDAP_MESSAGE_QUEUE_H
72
73