1 | //============================================================================ |
2 | // |
3 | // SSSS tt lll lll |
4 | // SS SS tt ll ll |
5 | // SS tttttt eeee ll ll aaaa |
6 | // SSSS tt ee ee ll ll aa |
7 | // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" |
8 | // SS SS tt ee ll ll aa aa |
9 | // SSSS ttt eeeee llll llll aaaaa |
10 | // |
11 | // Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony |
12 | // and the Stella Team |
13 | // |
14 | // See the file "License.txt" for information on usage and redistribution of |
15 | // this file, and for a DISCLAIMER OF ALL WARRANTIES. |
16 | //============================================================================ |
17 | |
18 | #ifndef FSNODE_FACTORY_HXX |
19 | #define FSNODE_FACTORY_HXX |
20 | |
21 | class AbstractFSNode; |
22 | |
23 | #if defined(ZIP_SUPPORT) |
24 | #include "FSNodeZIP.hxx" |
25 | #endif |
26 | #if defined(BSPF_UNIX) || defined(BSPF_MACOS) |
27 | #include "FSNodePOSIX.hxx" |
28 | #elif defined(BSPF_WINDOWS) |
29 | #include "FSNodeWINDOWS.hxx" |
30 | #elif defined(__LIB_RETRO__) |
31 | #include "FSNodeLIBRETRO.hxx" |
32 | #else |
33 | #error Unsupported platform in FSNodeFactory! |
34 | #endif |
35 | |
36 | /** |
37 | This class deals with creating the different FSNode implementations. |
38 | |
39 | @author Stephen Anthony |
40 | */ |
41 | class FilesystemNodeFactory |
42 | { |
43 | public: |
44 | enum class Type { SYSTEM, ZIP }; |
45 | |
46 | public: |
47 | static unique_ptr<AbstractFSNode> create(const string& path, Type type) |
48 | { |
49 | switch(type) |
50 | { |
51 | case Type::SYSTEM: |
52 | #if defined(BSPF_UNIX) || defined(BSPF_MACOS) |
53 | return make_unique<FilesystemNodePOSIX>(path); |
54 | #elif defined(BSPF_WINDOWS) |
55 | return make_unique<FilesystemNodeWINDOWS>(path); |
56 | #elif defined(__LIB_RETRO__) |
57 | return make_unique<FilesystemNodeLIBRETRO>(path); |
58 | #endif |
59 | break; |
60 | case Type::ZIP: |
61 | #if defined(ZIP_SUPPORT) |
62 | return make_unique<FilesystemNodeZIP>(path); |
63 | #endif |
64 | break; |
65 | } |
66 | return nullptr; |
67 | } |
68 | |
69 | private: |
70 | // Following constructors and assignment operators not supported |
71 | FilesystemNodeFactory() = delete; |
72 | FilesystemNodeFactory(const FilesystemNodeFactory&) = delete; |
73 | FilesystemNodeFactory(FilesystemNodeFactory&&) = delete; |
74 | FilesystemNodeFactory& operator=(const FilesystemNodeFactory&) = delete; |
75 | FilesystemNodeFactory& operator=(FilesystemNodeFactory&&) = delete; |
76 | }; |
77 | |
78 | #endif |
79 | |