X-Git-Url: https://git.teslayout.com/public/public/public/?a=blobdiff_plain;f=source%2Fdbos%2FStorageArea.cpp;h=66ee16bc61944c2566322ea50ff964d8904da55b;hb=5a6cba5fde2b2f538a7515f8293cc0a8d9589dfa;hp=775463780324d767195d0e2426634b649337519d;hpb=39033fd99e58e994a5e98c1060dcc79e0d81f9c9;p=anna.git diff --git a/source/dbos/StorageArea.cpp b/source/dbos/StorageArea.cpp index 7754637..66ee16b 100644 --- a/source/dbos/StorageArea.cpp +++ b/source/dbos/StorageArea.cpp @@ -1,37 +1,9 @@ -// ANNA - Anna is Not Nothingness Anymore -// -// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo -// -// http://redmine.teslayout.com/projects/anna-suite -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following disclaimer -// in the documentation and/or other materials provided with the -// distribution. -// * Neither the name of the copyright holder nor the names of its -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Authors: eduardo.ramos.testillano@gmail.com -// cisco.tierra@gmail.com +// 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 // #include @@ -86,7 +58,7 @@ StorageArea::~StorageArea() { // caso se ha reusado. //------------------------------------------------------------------------------------------------ Object* StorageArea::instance(Connection* connection, Loader& loader) -throw(RuntimeException, DatabaseException) { +noexcept(false) { const Index index = loader.getIndex(); Object* result(NULL); Instance* instance(NULL); @@ -185,7 +157,7 @@ throw(RuntimeException, DatabaseException) { } Object* StorageArea::instance(Connection* connection, CrossedLoader& crossedLoader, Loader& loader) -throw(RuntimeException, DatabaseException) { +noexcept(false) { Object* result = NULL; crossedLoader.a_connection = connection; // Si el seek devuelve 'true' es que ya tiene cargada la correspondencia entre la clave alternativa y la @@ -211,7 +183,7 @@ throw(RuntimeException, DatabaseException) { // Crea un nuevo objeto en el area de almacenamiento. //------------------------------------------------------------------------- Object* StorageArea::create(Connection* connection, Creator& creator) -throw(RuntimeException, DatabaseException) { +noexcept(false) { const Index index = creator.getIndex(); Instance* instance = NULL; Object* result = NULL; @@ -294,7 +266,7 @@ throw(RuntimeException, DatabaseException) { // lo sacamos de ah� //------------------------------------------------------------------------- Object* StorageArea::find(Loader& loader) -throw(RuntimeException) { +noexcept(false) { const Index index = loader.getIndex(); Instance* instance = NULL; Object* result = NULL; @@ -331,7 +303,7 @@ throw(RuntimeException) { } Object* StorageArea::duplicate(const Object* object) -throw(RuntimeException) { +noexcept(false) { if(object == NULL) return NULL; std::string name("dbos::StorageArea::duplicate with "); @@ -364,7 +336,7 @@ throw(RuntimeException) { } bool StorageArea::isLoaded(const Loader& loader) -throw(RuntimeException) { +noexcept(false) { const Index index = loader.getIndex(); std::string name("dbos::StorageArea::isLoaded with "); name += typeid(loader).name(); @@ -384,7 +356,7 @@ throw(RuntimeException) { } void StorageArea::apply(Connection& connection, Recorder& recorder) -throw(RuntimeException, DatabaseException) { +noexcept(false) { ResultCode resultCode = connection.execute(recorder.getStatement()); if(resultCode.successful() == false) @@ -401,7 +373,7 @@ throw(RuntimeException, DatabaseException) { // instancia en cuanto pueda. //------------------------------------------------------------------------------------------------ void StorageArea::apply(Connection& connection, Eraser& eraser) -throw(RuntimeException, DatabaseException) { +noexcept(false) { if(a_accessMode == AccessMode::ReadOnly) { string msg(asString()); msg += " | Cannot erase object with AccessMode::ReadOnly"; @@ -452,7 +424,7 @@ throw(RuntimeException, DatabaseException) { // memoria alcance un numero tal que implique comenzar a reusar objetos liberados. //------------------------------------------------------------------------------------------------ void StorageArea::release(Object** object) -throw(RuntimeException) { +noexcept(false) { if(object == NULL) return; if(*object == NULL) return; @@ -496,7 +468,7 @@ throw(RuntimeException) { // si fuera necesario invocara al 'destroy'. //------------------------------------------------------------------------------------------------ void StorageArea::erase(Object** object) -throw(RuntimeException) { +noexcept(false) { if(object == NULL) return; if(*object == NULL) return; @@ -533,7 +505,7 @@ throw(RuntimeException) { } void StorageArea::dirty(Object* object) -throw(RuntimeException) { +noexcept(false) { if(object == NULL) return; std::string name("dbos::StorageArea::dirty with "); @@ -572,7 +544,7 @@ throw(RuntimeException) { // expulsarla de cache. //-------------------------------------------------------------------------------------------- void StorageArea::clear() -throw(RuntimeException) { +noexcept(false) { Guard guard(this, "dbos::StorageArea::clear"); Instance* instance; int n = 0; @@ -622,7 +594,7 @@ throw(RuntimeException) { // y se libera su memoria. //--------------------------------------------------------------------------------------------------- Object* StorageArea::reload(dbms::Connection* connection, Loader& loader, StorageArea::Instance* instance) -throw(RuntimeException, dbms::DatabaseException) { +noexcept(false) { const bool enableUpdate = (instance->flags & Flag::Dirty) ? true : instance->object->enableUpdate(); bool hasChanges(false); @@ -686,7 +658,7 @@ throw(RuntimeException, dbms::DatabaseException) { // a instanciar, etc, etc //------------------------------------------------------------------------------------------------ void StorageArea::checkIncoherence(StorageArea::Instance* instance) -throw() { +{ if(quickReusing(instance) == true) { LOGWARNING( string msg("dbos::StorageArea::checkIncoherence | "); @@ -721,7 +693,7 @@ throw() { // esta, cambiarle el msHoleTime y volverlo a grabar. //------------------------------------------------------------------------------------------------ bool StorageArea::quickReusing(StorageArea::Instance* instance) -throw() { +{ bool result(false); if(a_holes.insert(instance, Holes::Mode::ReadyToReuse) == true) { // (1) @@ -750,7 +722,7 @@ throw() { } void StorageArea::verifyStatus(StorageArea::Instance* instance, const bool ignoreDirty) -throw(RuntimeException) { +noexcept(false) { if(instance->flags & Flag::Incoherent) { string msg(asString()); msg += " | "; @@ -785,7 +757,7 @@ throw(RuntimeException) { } string StorageArea::asString() const -throw() { +{ string result("dbos::StorageArea { Name: "); const int ratio = (a_hit == 0) ? 0 : (a_hit * 100) / (a_fault + a_hit); /* Nº real de objetos en uso. En el directorio también se mantienen los que tienen la cuenta de utilización a 0 */ @@ -813,7 +785,7 @@ throw() { } xml::Node* StorageArea::asXML(xml::Node* parent) const -throw() { +{ xml::Node* result = parent->createChild("dbos.StorageArea"); xml::Node* node; const int ratio = (a_hit == 0) ? 0 : (a_hit * 100) / (a_fault + a_hit); @@ -836,7 +808,7 @@ throw() { } string StorageArea::asMemorySize(const Size size) -throw() { +{ string result; if(size < 1024) { @@ -853,7 +825,7 @@ throw() { } StorageArea::Instance* StorageArea::allocate() -throw() { +{ Instance* result = NULL; if((result = reuse()) == NULL) { @@ -886,7 +858,7 @@ throw() { // (2) Si el primero de los registros disponibles no es suficientemente antiguo => no hay huecos libres //----------------------------------------------------------------------------------------------------- StorageArea::Instance* StorageArea::reuse() -throw() { +{ if(a_holes.empty() == true) return NULL; @@ -941,7 +913,7 @@ throw() { } std::string StorageArea::asString(const Instance* instance) -throw() { +{ std::string result("Instance { "); if(instance == NULL) @@ -983,7 +955,7 @@ throw() { } const char* StorageArea::AccessMode::asString(const AccessMode::_v v) -throw() { +{ static const char* text [] = { "ReadOnly", "ReadWrite", "ReadEver" }; return text [v]; } @@ -996,12 +968,12 @@ StorageArea::Block::Block(ObjectAllocator objectAllocator, const Size maxSize) : a_maxSize = std::min(8U, std::max(256U, maxSize >> 7)); a_instances = new Instance [a_maxSize]; - for(register int i = 0; i < a_maxSize; i ++) + for(int i = 0; i < a_maxSize; i ++) a_instances [i].object = (*objectAllocator)(); } bool StorageArea::Holes::insert(Instance* instance, const StorageArea::Holes::Mode::_v mode) -throw() { +{ if(instance->copyCounter > 0) return false; @@ -1035,7 +1007,7 @@ throw() { } void StorageArea::Holes::erase(Instance* instance) -throw() { +{ // instance->msHoleTime = 0; instance->flags |= Flag::Ready;