Add no-deprecated to warnings due to dynamic exceptions.
[anna.git] / example / dbos / workdir / storage / File.hpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #ifndef dbos_workdir_storage_File_hpp
10 #define dbos_workdir_storage_File_hpp
11
12 #include <anna/dbos/Object.hpp>
13 #include <anna/dbos/ObjectFacade.hpp>
14 #include <anna/dbos/Loader.hpp>
15
16 namespace anna {
17 namespace dbms {
18 class Database;
19 class Connection;
20 }
21 namespace dbos {
22 class Repository;
23 }
24 }
25
26 namespace workdir {
27
28 namespace filesystem {
29 class File;
30 }
31
32 namespace storage {
33
34 class Directory;
35
36 using namespace anna;
37
38 class File : public dbos::Object, public dbos::ObjectFacade <File> {
39 public:
40   const Directory* getParent() const throw() { return a_parent; }
41   const filesystem::File* getFilesystemFile() const throw() { return a_filesystemFile; }
42   int getINode() const throw() { return a_inode; }
43
44   std::string asString() const throw();
45
46   static void setup(dbos::Repository&, const int maxSize) throw(RuntimeException);
47   static File* instantiate(const filesystem::File*) throw(RuntimeException);
48
49   static const char* getStorageAreaName() throw() { return "storage::File"; }
50   static const dbos::Size getMaxSize() throw() { return st_maxSize; }
51
52 private:
53   class Loader : public dbos::Loader {
54   public:
55     Loader() : dbos::Loader() {;}
56
57     Loader& setKey(const filesystem::File* file) throw() {
58       a_filesystemFile = file;
59       return *this;
60     }
61
62     const filesystem::File* getFile() const throw() { return a_filesystemFile; }
63     int getINode() const throw() { return a_inode; }
64
65     dbos::Index getIndex() const throw();
66     std::string asString() const throw();
67
68   private:
69     const filesystem::File* a_filesystemFile;
70     int a_inode;
71
72     // dbms::Statement is not required
73     dbms::Statement* initialize(dbms::Database&) throw(RuntimeException) { return NULL; }
74     bool load(dbms::Connection*, const dbos::StorageArea*) throw(RuntimeException);
75   };
76
77   Directory* a_parent;
78   const filesystem::File* a_filesystemFile;
79   int a_inode;
80
81   static Loader* st_loader;
82   static ExclusiveHash <std::string> st_hash;
83   static int st_maxSize;
84
85   File() : a_parent(NULL) { ; }
86   File(const File&);
87
88   void initialize(dbos::Loader& loader) throw(RuntimeException, dbms::DatabaseException);
89   void destroy() throw();
90
91   dbos_declare_object(File);
92 };
93
94 }
95 }
96
97 #endif