]> git.sur5r.net Git - openldap/blob - contrib/ldapc++/src/LDAPRequest.cpp
Entry rwlock is no longer needed as concurrency is managed
[openldap] / contrib / ldapc++ / src / LDAPRequest.cpp
1 /*
2  * Copyright 2000, OpenLDAP Foundation, All Rights Reserved.
3  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
4  */
5
6
7 #include "debug.h"
8 #include "LDAPRequest.h"
9
10 using namespace std;
11
12 LDAPRequest::LDAPRequest(){
13     DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPRequest::LDAPRequest()" << endl);
14 }
15
16 LDAPRequest::LDAPRequest(const LDAPRequest& req){
17     DEBUG(LDAP_DEBUG_CONSTRUCT, "LDAPRequest::LDAPRequest(&)" << endl);
18     m_isReferral=req.m_isReferral;
19     m_cons = new LDAPConstraints(*(req.m_cons));
20     m_connection = req.m_connection;
21     m_parent = req.m_parent;
22     m_hopCount = req.m_hopCount;
23     m_msgID = req.m_msgID;
24 }
25
26 LDAPRequest::LDAPRequest(LDAPAsynConnection* con, 
27        const LDAPConstraints* cons,bool isReferral, const LDAPRequest* parent){
28     DEBUG(LDAP_DEBUG_CONSTRUCT,"LDAPRequest::LDAPRequest()" << endl);
29     m_connection=con;
30     if(cons == 0){
31         m_cons=new LDAPConstraints( *(con->getConstraints()) );
32     }else{
33         m_cons=new LDAPConstraints( *cons);
34     }
35     m_isReferral=isReferral; 
36     if(m_isReferral){
37         m_hopCount = (parent->getHopCount()+1);
38         m_parent= parent;
39     }else{
40         m_hopCount=0;
41         m_parent=0;
42     }
43 }
44
45 LDAPRequest::~LDAPRequest(){
46     DEBUG(LDAP_DEBUG_DESTROY,"LDAPRequest::~LDAPRequest()" << endl);
47     delete m_cons;
48 }
49
50 const LDAPConstraints* LDAPRequest::getConstraints() const{
51     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getConstraints()" << endl);
52     return m_cons;
53 }
54
55 const LDAPAsynConnection* LDAPRequest::getConnection() const{
56     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getConnection()" << endl);
57     return m_connection;
58 }
59
60 int LDAPRequest::getType() const {
61     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getType()" << endl);
62     return m_requestType;
63 }
64
65 int LDAPRequest::getMsgID() const {
66     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getMsgId()" << endl);
67     return m_msgID;
68 }
69
70 int LDAPRequest::getHopCount() const {
71     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getHopCount()" << endl);
72     return m_hopCount;
73 }
74
75 const LDAPRequest* LDAPRequest::getParent() const{
76     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::getParent()" << endl);
77     return m_parent;
78 }
79
80 bool LDAPRequest::isReferral() const {
81     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::isReferral()" << endl);
82     return m_isReferral;
83 }
84
85 bool LDAPRequest::equals(const LDAPRequest* req) const{
86     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::equals()" << endl);
87     if( (this->m_requestType == req->getType()) && 
88         (this->m_connection->getHost() == req->m_connection->getHost()) && 
89         (this->m_connection->getPort() == req->m_connection->getPort())
90       ){
91         return true;
92     }return false;        
93 }
94
95 bool LDAPRequest::isCycle() const{
96     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::isCycle()" << endl);
97     const LDAPRequest* parent=m_parent;
98     if(parent != 0){
99         do{
100             if(this->equals(parent)){
101                 return true;
102             }else{
103                 parent=parent->getParent();
104             }
105         }
106         while(parent != 0);
107     }
108     return false;
109 }
110
111 void LDAPRequest::unbind() const{
112     DEBUG(LDAP_DEBUG_TRACE,"LDAPRequest::unbind()" << endl);
113     m_connection->unbind();
114 }