--- /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/Directory.hpp"
+
+#include "Directory.hpp"
+
+using namespace std;
+using namespace anna;
+using namespace workdir;
+
+/*static*/
+storage::Directory::Loader* storage::Directory::st_loader = NULL;
+
+/*static*/
+ExclusiveHash <std::string> storage::Directory::st_hash;
+
+/*static*/
+int storage::Directory::st_maxSize = 0;
+
+dbos_prepare_object (storage::Directory);
+
+void storage::Directory::setup (dbos::Repository& repository, const int maxSize)
+ throw (RuntimeException)
+{
+ st_loader = new Directory::Loader ();
+ st_maxSize = maxSize;
+
+ Directory::setStorageArea (
+ repository.createStorageArea ( // (1)
+ Directory::getStorageAreaId (), Directory::getStorageAreaName (), Directory::getMaxSize (),
+ Directory::allocator, 2
+ )
+ );
+}
+
+storage::Directory* storage::Directory::instantiate (const filesystem::Directory* directory)
+ throw (RuntimeException)
+{
+ if (st_loader == NULL)
+ throw RuntimeException ("storage::Directory::setup no ha sido invocado", ANNA_FILE_LOCATION);
+
+ Directory* result = NULL;
+
+ try {
+ Guard guard (st_loader, "storage::Directory::Loader");
+ result = dbos::ObjectFacade <Directory>::instance (st_loader->setKey (directory));
+ }
+ catch (dbms::DatabaseException& edb) {
+ throw RuntimeException (edb);
+ }
+
+ return result;
+}
+
+void storage::Directory::initialize (dbos::Loader& loader)
+ throw (RuntimeException, dbms::DatabaseException)
+{
+ Directory::Loader& dbLoader = static_cast <Directory::Loader&> (loader);
+
+ a_filesystemDirectory = dbLoader.getDirectory ();
+ a_inode = dbLoader.getINode ();
+
+ LOGINFORMATION (
+ string msg ("storage::Directory::initialize | ");
+ msg += asString ();
+ Logger::information (msg, ANNA_FILE_LOCATION);
+ );
+}
+
+void storage::Directory::destroy ()
+ throw ()
+{
+ LOGINFORMATION (
+ string msg ("storage::Directory::destroy | ");
+ msg += asString ();
+ Logger::information (msg, ANNA_FILE_LOCATION);
+ );
+}
+
+string storage::Directory::asString () const
+ throw ()
+{
+ std::string result ("storage::Directory { Name: ");
+ result += a_filesystemDirectory->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::Directory::initialize
+ */
+bool storage::Directory::Loader::load (dbms::Connection*, const dbos::StorageArea* ssaa)
+ throw (RuntimeException)
+{
+ a_inode = io::functions::getINode (a_filesystemDirectory->getPath ());
+ return true;
+}
+
+dbos::Index storage::Directory::Loader::getIndex () const
+ throw ()
+{
+ return st_hash.calcule (a_filesystemDirectory->getPath ());
+}
+
+string storage::Directory::Loader::asString () const
+ throw ()
+{
+ std::string result ("storage::Loader::Directory { Name: ");
+ result += a_filesystemDirectory->getPath ();
+ return result += " }";
+}
+