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