root / trunk / Pithos.Core / IStatusKeeper.cs @ 3c76f045
History | View | Annotate | Download (6.5 kB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Diagnostics.Contracts; |
4 |
using System.IO; |
5 |
using System.Linq; |
6 |
using System.Threading; |
7 |
using Pithos.Interfaces; |
8 |
|
9 |
namespace Pithos.Core |
10 |
{ |
11 |
[ContractClass(typeof(IStatusKeeperContract))] |
12 |
public interface IStatusKeeper |
13 |
{ |
14 |
void SetFileOverlayStatus(string path,FileOverlayStatus status); |
15 |
void UpdateFileChecksum(string path, string checksum); |
16 |
void SetFileStatus(string path, FileStatus status); |
17 |
FileStatus GetFileStatus(string path); |
18 |
void ClearFileStatus(string path); |
19 |
void SetPithosStatus(PithosStatus status); |
20 |
FileOverlayStatus GetFileOverlayStatus(string path); |
21 |
void ProcessExistingFiles(IEnumerable<FileInfo> paths); |
22 |
void Stop(); |
23 |
void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus); |
24 |
void StoreInfo(string path, ObjectInfo objectInfo); |
25 |
//T GetStatus<T>(string path,Func<FileState,T> getter,T defaultValue ); |
26 |
//void SetStatus(string path, Action<FileState> setter); |
27 |
|
28 |
void StartProcessing(CancellationToken token); |
29 |
|
30 |
string BlockHash { get; set; } |
31 |
int BlockSize { get; set; } |
32 |
void ChangeRoots(string oldPath, string newPath); |
33 |
FileState GetStateByFilePath(string path); |
34 |
void ClearFolderStatus(string path); |
35 |
IEnumerable<FileState> GetChildren(FileState fileState); |
36 |
} |
37 |
|
38 |
[ContractClassFor(typeof(IStatusKeeper))] |
39 |
public abstract class IStatusKeeperContract : IStatusKeeper |
40 |
{ |
41 |
public void SetFileOverlayStatus(string path, FileOverlayStatus status) |
42 |
{ |
43 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
44 |
Contract.Requires(Path.IsPathRooted(path)); |
45 |
} |
46 |
|
47 |
public void UpdateFileChecksum(string path, string checksum) |
48 |
{ |
49 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
50 |
Contract.Requires(checksum!=null); |
51 |
Contract.Requires(Path.IsPathRooted(path)); |
52 |
} |
53 |
|
54 |
/* public void RemoveFileOverlayStatus(string path) |
55 |
{ |
56 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
57 |
Contract.Requires(Path.IsPathRooted(path)); |
58 |
}*/ |
59 |
|
60 |
public void RenameFileOverlayStatus(string oldPath, string newPath) |
61 |
{ |
62 |
Contract.Requires(!String.IsNullOrWhiteSpace(oldPath)); |
63 |
Contract.Requires(Path.IsPathRooted(oldPath)); |
64 |
Contract.Requires(!String.IsNullOrWhiteSpace(newPath)); |
65 |
Contract.Requires(Path.IsPathRooted(newPath)); |
66 |
|
67 |
} |
68 |
|
69 |
public void SetFileStatus(string path, FileStatus status) |
70 |
{ |
71 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
72 |
Contract.Requires(Path.IsPathRooted(path)); |
73 |
} |
74 |
|
75 |
public FileStatus GetFileStatus(string path) |
76 |
{ |
77 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
78 |
Contract.Requires(Path.IsPathRooted(path)); |
79 |
|
80 |
return default(FileStatus); |
81 |
} |
82 |
|
83 |
public FileOverlayStatus GetFileOverlayStatus(string path) |
84 |
{ |
85 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
86 |
Contract.Requires(Path.IsPathRooted(path)); |
87 |
|
88 |
return default(FileOverlayStatus); |
89 |
} |
90 |
|
91 |
public void ProcessExistingFiles(IEnumerable<FileInfo> paths) |
92 |
{ |
93 |
Contract.Requires(paths!=null); |
94 |
} |
95 |
|
96 |
public void Stop() |
97 |
{ |
98 |
|
99 |
} |
100 |
|
101 |
public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus) |
102 |
{ |
103 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
104 |
Contract.Requires(Path.IsPathRooted(path)); |
105 |
} |
106 |
|
107 |
public void StoreInfo(string path, ObjectInfo objectInfo) |
108 |
{ |
109 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
110 |
Contract.Requires(objectInfo!=null); |
111 |
Contract.Requires(Path.IsPathRooted(path)); |
112 |
} |
113 |
|
114 |
public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue) |
115 |
{ |
116 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
117 |
Contract.Requires(getter!=null); |
118 |
Contract.Requires(Path.IsPathRooted(path)); |
119 |
|
120 |
return default(T); |
121 |
} |
122 |
|
123 |
public void SetStatus(string path, Action<FileState> setter) |
124 |
{ |
125 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
126 |
Contract.Requires(setter != null); |
127 |
Contract.Requires(Path.IsPathRooted(path)); |
128 |
} |
129 |
|
130 |
public void SetNetworkState(string path, NetworkOperation operation) |
131 |
{ |
132 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
133 |
Contract.Requires(Path.IsPathRooted(path)); |
134 |
Contract.Requires(Path.IsPathRooted(path)); |
135 |
} |
136 |
|
137 |
public NetworkOperation GetNetworkState(string path) |
138 |
{ |
139 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
140 |
Contract.Requires(Path.IsPathRooted(path)); |
141 |
|
142 |
return default(NetworkOperation); |
143 |
} |
144 |
|
145 |
public void ClearFileStatus(string path) |
146 |
{ |
147 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
148 |
Contract.Requires(Path.IsPathRooted(path)); |
149 |
} |
150 |
|
151 |
public void SetPithosStatus(PithosStatus status) |
152 |
{ |
153 |
} |
154 |
|
155 |
public void StartProcessing(CancellationToken token) |
156 |
{ |
157 |
Contract.Requires(token != null, "token can't be empty"); |
158 |
} |
159 |
|
160 |
public abstract string BlockHash { get; set; } |
161 |
public abstract int BlockSize { get; set; } |
162 |
public void ChangeRoots(string oldPath, string newPath) |
163 |
{ |
164 |
Contract.Requires(!String.IsNullOrWhiteSpace(oldPath)); |
165 |
Contract.Requires(Path.IsPathRooted(oldPath)); |
166 |
Contract.Requires(!string.IsNullOrWhiteSpace(newPath)); |
167 |
Contract.Requires(Path.IsPathRooted(newPath)); |
168 |
} |
169 |
|
170 |
public FileState GetStateByFilePath(string path) |
171 |
{ |
172 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
173 |
Contract.Requires(Path.IsPathRooted(path)); |
174 |
|
175 |
return null; |
176 |
} |
177 |
|
178 |
public void ClearFolderStatus(string path) |
179 |
{ |
180 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
181 |
Contract.Requires(Path.IsPathRooted(path)); |
182 |
} |
183 |
|
184 |
public IEnumerable<FileState> GetChildren(FileState fileState) |
185 |
{ |
186 |
Contract.Requires(fileState!=null); |
187 |
Contract.Ensures(Contract.Result<IEnumerable<FileState>>()!=null); |
188 |
return default(IEnumerable<FileState>); |
189 |
} |
190 |
} |
191 |
} |