+++ /dev/null
-// 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 <anna/core/functions.hpp>
-#include <anna/core/tracing/Logger.hpp>
-
-#include <anna/io/functions.hpp>
-
-#include <anna/dbms/Database.hpp>
-#include <anna/dbms/Statement.hpp>
-
-#include <anna/dbos/Repository.hpp>
-
-#include "../filesystem/File.hpp"
-#include "../filesystem/Directory.hpp"
-
-#include "File.hpp"
-#include "Directory.hpp"
-
-using namespace std;
-using namespace anna;
-using namespace workdir;
-
-/*static*/
-storage::File::Loader* storage::File::st_loader = NULL;
-
-/*static*/
-ExclusiveHash <std::string> storage::File::st_hash;
-
-/*static*/
-int storage::File::st_maxSize = 0;
-
-dbos_prepare_object (storage::File);
-
-void storage::File::setup (dbos::Repository& repository, const int maxSize)
- throw (RuntimeException)
-{
- st_loader = new File::Loader ();
- st_maxSize = maxSize;
-
- File::setStorageArea (
- repository.createStorageArea ( // (1)
- File::getStorageAreaId (), File::getStorageAreaName (), File::getMaxSize (),
- File::allocator, 2
- )
- );
-}
-
-storage::File* storage::File::instantiate (const filesystem::File* file)
- throw (RuntimeException)
-{
- if (st_loader == NULL)
- throw RuntimeException ("storage::File::setup no ha sido invocado", ANNA_FILE_LOCATION);
-
- File* result = NULL;
-
- try {
- Guard guard (st_loader, "storage::File::Loader");
- result = dbos::ObjectFacade <File>::instance (st_loader->setKey (file));
- }
- catch (dbms::DatabaseException& edb) {
- throw RuntimeException (edb);
- }
-
- return result;
-}
-
-void storage::File::initialize (dbos::Loader& loader)
- throw (RuntimeException, dbms::DatabaseException)
-{
- File::Loader& dbLoader = static_cast <File::Loader&> (loader);
-
- a_filesystemFile = dbLoader.getFile ();
- a_parent = Directory::instantiate (filesystem::Directory::down_cast (a_filesystemFile->getParent ()));
- a_inode = dbLoader.getINode ();
-
- LOGINFORMATION (
- string msg ("storage::File::initialize | ");
- msg += asString ();
- Logger::information (msg, ANNA_FILE_LOCATION);
- );
-}
-
-void storage::File::destroy ()
- throw ()
-{
- LOGINFORMATION (
- string msg ("storage::File::destroy | ");
- msg += asString ();
- Logger::information (msg, ANNA_FILE_LOCATION);
- );
- Directory::release (a_parent);
-}
-
-string storage::File::asString () const
- throw ()
-{
- std::string result ("storage::File { Name: ");
- result += a_filesystemFile->getPath ();
- result += functions::asHexText (" | I-Node: ", a_inode);
- return result += " }";
-}
-
-/*
- * Transfiere la información del medio físico al primer nivel de C++.
- * Posteriormente será interpretada en storage::File::initialize
- */
-bool storage::File::Loader::load (dbms::Connection*, const dbos::StorageArea* ssaa)
- throw (RuntimeException)
-{
- a_inode = io::functions::getINode (a_filesystemFile->getPath ());
- return true;
-}
-
-dbos::Index storage::File::Loader::getIndex () const
- throw ()
-{
- return st_hash.calcule (a_filesystemFile->getPath ());
-}
-
-string storage::File::Loader::asString () const
- throw ()
-{
- std::string result ("storage::Loader::File { Name: ");
- result += a_filesystemFile->getPath ();
- return result += " }";
-}
-