Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / example / dbos / workdir / storage / Directory.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_Directory_hpp
10 #define dbos_workdir_storage_Directory_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 Directory;
30 }
31
32 namespace storage {
33
34 using namespace anna;
35
36 class Directory : public dbos::Object, public dbos::ObjectFacade <Directory> {
37 public:
38   const filesystem::Directory* getFilesystemDirectory() const throw() { return a_filesystemDirectory; }
39   int getINode() const throw() { return a_inode; }
40
41   std::string asString() const throw();
42
43   static void setup(dbos::Repository&, const int maxSize) throw(RuntimeException);
44   static Directory* instantiate(const filesystem::Directory*) throw(RuntimeException);
45
46   static const char* getStorageAreaName() throw() { return "storage::Directory"; }
47   static const dbos::Size getMaxSize() throw() { return st_maxSize; }
48
49 private:
50   class Loader : public dbos::Loader {
51   public:
52     Loader() : dbos::Loader() {;}
53
54     Loader& setKey(const filesystem::Directory* directory) throw() {
55       a_filesystemDirectory = directory;
56       return *this;
57     }
58
59     const filesystem::Directory* getDirectory() const throw() { return a_filesystemDirectory; }
60     int getINode() const throw() { return a_inode; }
61
62     dbos::Index getIndex() const throw();
63     std::string asString() const throw();
64
65   private:
66     const filesystem::Directory* a_filesystemDirectory;
67     int a_inode;
68
69     // dbms::Statement is not required
70     dbms::Statement* initialize(dbms::Database&) throw(RuntimeException) { return NULL; }
71     bool load(dbms::Connection*, const dbos::StorageArea*) throw(RuntimeException);
72   };
73
74   const filesystem::Directory* a_filesystemDirectory;
75   int a_inode;
76
77   static Loader* st_loader;
78   static ExclusiveHash <std::string> st_hash;
79   static int st_maxSize;
80
81   Directory() { ; }
82   Directory(const Directory&);
83
84   void initialize(dbos::Loader& loader) throw(RuntimeException, dbms::DatabaseException);
85   void destroy() throw();
86
87   dbos_declare_object(Directory);
88 };
89
90 }
91 }
92
93 #endif