Revert "Remove mysql and oracle resources for anna-ericsson project"
[anna.git] / example / dbos / workdir / filesystem / Abstract.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_filesystem_Abstract_hpp
10 #define dbos_workdir_filesystem_Abstract_hpp
11
12 #include <vector>
13 #include <string>
14
15 #include <anna/core/util/ExclusiveHash.hpp>
16
17 namespace workdir {
18
19 namespace filesystem {
20
21 using namespace anna;
22
23 class Abstract {
24 public:
25    struct ClassType { enum _v { Directory, File }; };
26    
27    typedef std::vector <Abstract*> child_container;
28    typedef child_container::iterator child_iterator;
29    typedef child_container::const_iterator const_child_iterator;
30    
31    virtual ~Abstract ();
32    
33    Abstract* getParent () const throw () { return a_parent; }
34    ClassType::_v getClassType () const throw () { return a_classType; }
35    const std::string& getName () const throw () { return a_name; }
36    const std::string& getPath () const throw () { return a_path; }
37
38    int child_size () const throw () { return a_children.size (); }
39    
40    child_iterator child_begin () throw () { return a_children.begin (); }
41    child_iterator child_end () throw () { return a_children.end (); }   
42    static Abstract* child (child_iterator ii) throw () { return *ii; }
43
44    const_child_iterator child_begin () const throw () { return a_children.begin (); }
45    const_child_iterator child_end () const throw () { return a_children.end (); }   
46    static const Abstract* child (const_child_iterator ii) throw () { return *ii; }
47    
48    static std::string calculePath (const Abstract* parent, const std::string& shortPath) throw ();
49    
50    virtual void print (const int level) const throw () = 0;
51
52 protected:
53    Abstract (const ClassType::_v, const std::string& name);
54    Abstract (const ClassType::_v, Abstract* parent, const std::string& name);
55    
56 private:
57    const ClassType::_v a_classType;
58    Abstract* a_parent;   
59    const std::string a_name;
60    std::string a_path;
61    child_container a_children;
62    
63    Abstract (const Abstract&);
64 };
65
66 }
67 }
68
69 #endif