1 /**
2 Copyright: 2018 Mark Fisher
3 
4 License:
5 Permission is hereby granted, free of charge, to any person obtaining a copy of
6 this software and associated documentation files (the "Software"), to deal in
7 the Software without restriction, including without limitation the rights to
8 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9 of the Software, and to permit persons to whom the Software is furnished to do
10 so, subject to the following conditions:
11 
12 The above copyright notice and this permission notice shall be included in all
13 copies or substantial portions of the Software.
14 
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 SOFTWARE.
22 **/
23 module dxx.app.resource.file;
24 
25 public import dxx.util;
26 public import dxx.app;
27 
28 struct FileResourceDesc {
29     string uri;
30     bool isFolder;
31     void* contents;
32 }
33 
34 abstract class ResourceBase : SyncNotificationSource, Resource {
35 
36 }
37 
38 abstract class FileOrFolderResourceBase : ResourceBase, Resource {
39     string _uri;
40     FolderResource _parent;
41     Project _parentProject;
42     Resource[] _children;
43     //void* _contents;
44     Workspace _parentWorkspace;
45 
46     Project parentProject() {
47       return _parentProject;
48     }
49 
50     ResourceSet owner() {
51         return owner;
52     }
53 
54     @property
55     override Resource parent() {
56         return _parent;
57     }
58 
59     @property
60     override Resource[] children() {
61         return _children;
62     }
63 
64     @property
65     override const(string) uri() {
66         return _uri;
67     }
68 
69     this(string uri,FolderResource parent) {
70       this._uri = uri;
71       this._parent = parent;
72       if(parent !is null) {
73         this._parentWorkspace = parent.parentWorkspace;
74       } else {
75         this._parentWorkspace = DXXPlatform.getDefaultWorkspace;
76       }
77     }
78 
79     Workspace parentWorkspace() {
80       return _parentWorkspace;
81     }
82 }
83 
84 class FileResourceBase : FileOrFolderResourceBase,FileResource {
85     this(string uri,FolderResource parent) {
86         super(uri,parent);
87     }
88     override bool isFolder() {
89         return false;
90     }
91     //override void* contents() {
92     //    return null;
93     //}
94     //@property
95     //override void* contents() {
96     //    return _contents;
97     //}
98 
99 }
100 
101 class FolderResourceBase : FileOrFolderResourceBase,FolderResource {
102     this(string uri,FolderResource parent) {
103         super(uri,parent);
104     }
105     override bool isFolder() {
106         return true;
107     }
108 }