1 // ANNA - Anna is Not Nothingness Anymore
3 // (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
5 // http://redmine.teslayout.com/projects/anna-suite
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 the copyright holder 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 dbos_workdir_storage_File_hpp
38 #define dbos_workdir_storage_File_hpp
40 #include <anna/dbos/Object.hpp>
41 #include <anna/dbos/ObjectFacade.hpp>
42 #include <anna/dbos/Loader.hpp>
56 namespace filesystem {
66 class File : public dbos::Object, public dbos::ObjectFacade <File> {
68 const Directory* getParent() const throw() { return a_parent; }
69 const filesystem::File* getFilesystemFile() const throw() { return a_filesystemFile; }
70 int getINode() const throw() { return a_inode; }
72 std::string asString() const throw();
74 static void setup(dbos::Repository&, const int maxSize) throw(RuntimeException);
75 static File* instantiate(const filesystem::File*) throw(RuntimeException);
77 static const char* getStorageAreaName() throw() { return "storage::File"; }
78 static const dbos::Size getMaxSize() throw() { return st_maxSize; }
81 class Loader : public dbos::Loader {
83 Loader() : dbos::Loader() {;}
85 Loader& setKey(const filesystem::File* file) throw() {
86 a_filesystemFile = file;
90 const filesystem::File* getFile() const throw() { return a_filesystemFile; }
91 int getINode() const throw() { return a_inode; }
93 dbos::Index getIndex() const throw();
94 std::string asString() const throw();
97 const filesystem::File* a_filesystemFile;
100 // dbms::Statement is not required
101 dbms::Statement* initialize(dbms::Database&) throw(RuntimeException) { return NULL; }
102 bool load(dbms::Connection*, const dbos::StorageArea*) throw(RuntimeException);
106 const filesystem::File* a_filesystemFile;
109 static Loader* st_loader;
110 static ExclusiveHash <std::string> st_hash;
111 static int st_maxSize;
113 File() : a_parent(NULL) { ; }
116 void initialize(dbos::Loader& loader) throw(RuntimeException, dbms::DatabaseException);
117 void destroy() throw();
119 dbos_declare_object(File);