X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=include%2Fanna%2Fdbms%2FDatabase.hpp;fp=include%2Fanna%2Fdbms%2FDatabase.hpp;h=bbe46c59490b5200eb282083986a8a963a5c99eb;hb=78be86969d2f26a9084b0c4af6ce43d5fa4ed3fd;hp=0000000000000000000000000000000000000000;hpb=a3b95648bd76140ef55e0b5941d423eee6c3856f;p=anna.git diff --git a/include/anna/dbms/Database.hpp b/include/anna/dbms/Database.hpp new file mode 100644 index 0000000..bbe46c5 --- /dev/null +++ b/include/anna/dbms/Database.hpp @@ -0,0 +1,296 @@ +// ANNA - Anna is Not Nothingness Anymore // +// // +// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo // +// // +// See project site at http://redmine.teslayout.com/projects/anna-suite // +// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE // + + +#ifndef anna_dbms_Database_hpp +#define anna_dbms_Database_hpp + +#include + +#include + +#include + +namespace anna { + +namespace comm { +class INetAddress; +class Delivery; +} + +namespace dbms { + +class Statement; +class InputBind; +class OutputBind; +class Data; +class FailRecoveryHandler; +class StatementTranslator; + +/** + Clase que modela la interaccion entre la base y nuestra aplicacion. +*/ +class Database : public app::Component { +public: + /** + Numero maximo de conexiones que podemos crear. + */ + static const int MaxConnection = 32; + + /** + Formas de conexion a la base de datos. + */ + struct Type { + enum _v { Local, Remote } value; + Type() : value(Local) {;} + Type(const _v v) : value(v) {;} + Type(const Type& v) : value(v.value) {;} + operator int () const throw() { return value; } + }; + + typedef std::vector ::const_iterator const_connection_iterator; /**::const_iterator const_statement_iterator; /**::iterator connection_iterator; /** a_connections; + std::vector a_statements; + const Type a_type; + FailRecoveryHandler* a_failRecoveryHandler; + StatementTranslator* a_statementTranslator; + + Database(const Database&); + + void do_cloneChild() throw(RuntimeException); + + virtual Connection* allocateConnection(const std::string& name, const char* user, const char* password) + throw(RuntimeException) = 0; + + virtual Statement* allocateStatement(const char* name, const std::string& expression, const bool isCritical) + throw(RuntimeException) = 0; + + virtual InputBind* allocateInputBind(const char* name, Data& data) + throw(RuntimeException) = 0; + virtual void deallocate(InputBind* inputBind) throw() = 0; + + virtual OutputBind* allocateOutputBind(const char* name, Data& data) + throw(RuntimeException) = 0; + virtual void deallocate(OutputBind* outputBind) throw() = 0; + + friend class Statement; + friend ResultCode Connection::execute(Statement*) throw(RuntimeException, DatabaseException); +}; + +} +} + +#endif