1 // ANNA - Anna is Not Nothingness Anymore //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
9 #ifndef anna_ldap_Response_hpp
10 #define anna_ldap_Response_hpp
12 #include <anna/core/util/Recycler.hpp>
13 #include <anna/core/Allocator.hpp>
15 #include <anna/ldap/defines.hpp>
16 #include <anna/ldap/ClassCode.hpp>
17 #include <anna/ldap/ResultCode.hpp>
29 Modela las respuesta que podemos recibir de un servidor LDAP.
31 La respuesta correspondiente a una peticion se genera automaticamente al invocar a ldap::Session::send.
32 El nucleo de ANNA.ldap notifica el resultado de la operacion solicitada mediante la invocacion
33 al metodo-menejador ldap::Session::eventResponse de nuestra sesion.
37 typedef Recycler<Attribute> attribute_container;
38 typedef attribute_container::iterator attribute_iterator;
39 typedef attribute_container::const_iterator const_attribute_iterator;
41 typedef Recycler<std::string> referral_container;
42 typedef referral_container::const_iterator const_referral_iterator;
45 Devuelve el tipo de la clase de esta respuesta.
46 \return El tipo de la clase de esta respuesta.
48 ClassCode::_v getClassCode() const throw() { return a_classCode; }
51 Devuelve la identificacion del mensaje LDAP.
52 Esta identificacion sera generada automaticamente al enviar la peticion.
53 \return Identificacion del mensaje asociado a esta peticion/respuesta.
54 \see ldap::Session::send
56 IdMessage getIdMessage() const throw() { return a_idMessage; }
59 Devuelve la sesion que genera esta respuesta.
60 \return La instancia de la sesion que genera esta respuesta.
62 const Session* getSession() const throw() { return a_session; }
65 Devuelve el resultado de la peticion LDAP solicitada.
66 \return El resultado de la peticion LDAP solicitada.
68 const ResultCode& getResultCode() const throw() { return a_resultCode; }
71 Devuelve el nombre del DN asociado a esta peticion.
72 \return El nombre del DN asociado a esta peticion.
74 const std::string& getName() const throw() { return a_name; }
77 Devuelve la peticion que origino la creacion de esta respuesta.
78 \return La peticion que origino la creacion de esta respuesta.
79 \see ldap::Session::send
81 const Request* getRequest()const throw() { return a_request; }
84 Devuelve la sesion que origino la creacion de esta respuesta.
85 \return La sesion que origino la creacion de esta respuesta.
87 Session* getSession() throw() { return a_session; }
90 * Devuelve el nº de atributos que contiene la respuesta.
91 * \return el nº de atributos que contiene la respuesta.
93 int attribute_size() const throw() { return a_attributes.size(); }
96 Devuelve el iterador al comienzo de la lista de atributos asociados a esta respuesta.
97 \return El iterador al comienzo de la lista de atributos asociados a esta respuesta.
99 const_attribute_iterator attribute_begin() const throw() { return a_attributes.begin(); }
102 Devuelve el iterador al final de la lista de atributos asociados a esta respuesta.
103 \return El iterador al final de la lista de atributos asociados a esta respuesta.
105 const_attribute_iterator attribute_end() const throw() { return a_attributes.end(); }
108 * Devuelve el nº de referencias que contiene la respuesta.
109 * \return el nº de referencias que contiene la respuesta.
111 int referral_size() const throw() { return a_referrals.size(); }
114 Devuelve el iterador al comienzo de la lista de referencias asociados a esta respuesta.
115 \return El iterador al comienzo de la lista de referencias asociados a esta respuesta.
117 const_referral_iterator referral_begin() const throw() { return a_referrals.begin(); }
120 Devuelve el iterador al final de la lista de referencias asociados a esta respuesta.
121 \return El iterador al final de la lista de referencias asociados a esta respuesta.
123 const_referral_iterator referral_end() const throw() { return a_referrals.end(); }
126 Devuelve el atributo asociado al iterador recibido como parametro.
127 \param ii Instancia del iterador usado para recorrer los datos. Estara comprendido
128 entre [#attribute_begin, #attribute_end).
129 \return El atributo referenciado por el iterador.
131 static const Attribute* attribute(const_attribute_iterator ii) throw() { return attribute_container::data(ii); }
134 Devuelve la referencia asociada al iterador recibido como parametro.
135 \param ii Instancia del iterador usado para recorrer los datos. Estara comprendido
136 entre [#referral_begin, #referral_end).
137 \return La referencia apuntada por el iterador.
139 static const std::string& referral(const_referral_iterator ii) throw() { return *referral_container::data(ii); }
142 Devuelve una cadena con la informacion relevante sobre esta instancia.
143 \return Una cadena con la informacion relevante sobre esta instancia.
145 std::string asString() const throw();
148 ClassCode::_v a_classCode;
149 IdMessage a_idMessage;
151 ResultCode a_resultCode;
153 attribute_container a_attributes;
154 referral_container a_referrals;
156 const Request* a_request;
158 typedef Recycler<Response> response_pool;
159 static response_pool st_responses;
163 static Response* instance(const ClassCode::_v, const IdMessage) throw(RuntimeException);
164 static void release(Response* response) throw();
166 void clear() throw();
168 void setName(const std::string& name) throw() { a_name = name; }
169 void setSession(Session* session) throw() { a_session = session; }
170 void setRequest(const Request* request) throw() { a_request = request; }
171 void activateTimer() throw(RuntimeException);
172 void cancelTimer() throw();
173 void setResultCode(const ResultCode& resultCode) throw() { a_resultCode = resultCode; }
175 Attribute* createAttribute(const std::string& name) throw(RuntimeException);
177 void createReferral(const char* value) throw(RuntimeException) {
178 std::string* newReferral = a_referrals.create();
179 *newReferral = value;
183 attribute_iterator attribute_begin() throw() { return a_attributes.begin(); }
184 attribute_iterator attribute_end() throw() { return a_attributes.end(); }
185 static Attribute* attribute(attribute_iterator ii) throw() { return attribute_container::data(ii); }
187 friend class Session;
188 friend class Allocator<Response>;