1 // ANNA - Anna is Not 'N' Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // https://bitbucket.org/testillano/anna
7 // Redistribution and use in source and binary forms, with or without
8 // modification, are permitted provided that the following conditions
11 // * Redistributions of source code must retain the above copyright
12 // notice, this list of conditions and the following disclaimer.
13 // * Redistributions in binary form must reproduce the above
14 // copyright notice, this list of conditions and the following disclaimer
15 // in the documentation and/or other materials provided with the
17 // * Neither the name of Google Inc. nor the names of its
18 // contributors may be used to endorse or promote products derived from
19 // this software without specific prior written permission.
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 // Authors: eduardo.ramos.testillano@gmail.com
34 // cisco.tierra@gmail.com
37 #ifndef anna_ldap_Request_hpp
38 #define anna_ldap_Request_hpp
40 #include <anna/ldap/defines.hpp>
41 #include <anna/ldap/ClassCode.hpp>
54 Prototipo de las peticiones que podemos realizar a un servidor LDAP.
59 * Define las acciones a realizar en caso de que el temporizador de la petición expire.
61 struct OnExpiry { enum _v { Abandon, Ignore }; };
64 Devuelve el tipo de la clase de esta peticion indicada en el contructor.
65 \return El tipo de la clase de esta peticion indicada en el contructor.
67 ClassCode::_v getClassCode() const throw() { return a_classCode; }
70 * Devuelve la acción a realizar en caso de que el temporizador asociado a esta petición expire.
71 * \return la acción a realizar en caso de que el temporizador asociado a esta petición expire.
73 OnExpiry::_v getOnExpiry() const throw() { return a_onExpiry; }
76 * Establece la acción a realizar en caso de que el temporizador asociado a esta petición expire.
77 * \param onExpiry Indica la acción a realizar en caso de que el temporizador asociado a esta petición expire.
79 * \warning Establecer el valor OnExpiry::Ignore podría causar pérdida de memoria y uso innecesario de recursos.
81 void setOnExpiry(const OnExpiry::_v onExpiry) throw() { a_onExpiry = onExpiry; }
84 Devuelve una cadena con la informacion mas relevante de esta instancia.
85 \return Una cadena con la informacion mas relevante de esta instancia.
87 virtual std::string asString() const throw();
90 Devuelve un documento XML con la informacion mas relevante de esta instancia.
91 \param parent Nodo XML del que colgar la informacion referente a esta instancia.
92 \return Un documento XML con la informacion mas relevante de esta instancia.
94 virtual xml::Node* asXML(xml::Node* parent) const throw();
97 Inicializa los parametros de esta peticion.
99 virtual void clear() throw() = 0;
102 Devuelve \em NULL si la \em std::string recibida como parametro esta vacia o el contenido de la
104 \return \em NULL si la \em std::string recibida como parametro esta vacia o el contenido de la
106 \warning Uso interno.
108 static const char* asCString(const std::string& value) throw() {
109 return (value.empty() == true) ? NULL : value.c_str();
113 Devuelve \em "<null>" si la std::string recibida como parametro esta vacia o el contenido de la
115 \return \em "<null>" si la std::string recibida como parametro esta vacia o el contenido de la
118 static const char* asText(const std::string& value) throw() {
119 return (value.empty() == true) ? "<null>" : value.c_str();
125 \param classCode Tipo de clase de esta peticion.
126 \param onExpiry Indica la acción a realizar si el temporizador de esta transación expira.
128 Request(const ClassCode::_v classCode, const OnExpiry::_v onExpiry) : a_classCode(classCode), a_onExpiry(onExpiry) {;}
131 ClassCode::_v a_classCode;
132 OnExpiry::_v a_onExpiry;
134 virtual IdMessage send(Session&) const throw() = 0;
136 friend class Session;