root / trunk / Pithos.Core / IStatusKeeper.cs @ 039a89e5
History | View | Annotate | Download (5.9 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 |
} |
35 |
|
36 |
[ContractClassFor(typeof(IStatusKeeper))] |
37 |
public abstract class IStatusKeeperContract : IStatusKeeper |
38 |
{ |
39 |
public void SetFileOverlayStatus(string path, FileOverlayStatus status) |
40 |
{ |
41 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
42 |
Contract.Requires(Path.IsPathRooted(path)); |
43 |
} |
44 |
|
45 |
public void UpdateFileChecksum(string path, string checksum) |
46 |
{ |
47 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
48 |
Contract.Requires(checksum!=null); |
49 |
Contract.Requires(Path.IsPathRooted(path)); |
50 |
} |
51 |
|
52 |
/* public void RemoveFileOverlayStatus(string path) |
53 |
{ |
54 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
55 |
Contract.Requires(Path.IsPathRooted(path)); |
56 |
}*/ |
57 |
|
58 |
public void RenameFileOverlayStatus(string oldPath, string newPath) |
59 |
{ |
60 |
Contract.Requires(!String.IsNullOrWhiteSpace(oldPath)); |
61 |
Contract.Requires(Path.IsPathRooted(oldPath)); |
62 |
Contract.Requires(!String.IsNullOrWhiteSpace(newPath)); |
63 |
Contract.Requires(Path.IsPathRooted(newPath)); |
64 |
|
65 |
} |
66 |
|
67 |
public void SetFileStatus(string path, FileStatus status) |
68 |
{ |
69 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
70 |
Contract.Requires(Path.IsPathRooted(path)); |
71 |
} |
72 |
|
73 |
public FileStatus GetFileStatus(string path) |
74 |
{ |
75 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
76 |
Contract.Requires(Path.IsPathRooted(path)); |
77 |
|
78 |
return default(FileStatus); |
79 |
} |
80 |
|
81 |
public FileOverlayStatus GetFileOverlayStatus(string path) |
82 |
{ |
83 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
84 |
Contract.Requires(Path.IsPathRooted(path)); |
85 |
|
86 |
return default(FileOverlayStatus); |
87 |
} |
88 |
|
89 |
public void ProcessExistingFiles(IEnumerable<FileInfo> paths) |
90 |
{ |
91 |
Contract.Requires(paths!=null); |
92 |
} |
93 |
|
94 |
public void Stop() |
95 |
{ |
96 |
|
97 |
} |
98 |
|
99 |
public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus) |
100 |
{ |
101 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
102 |
Contract.Requires(Path.IsPathRooted(path)); |
103 |
} |
104 |
|
105 |
public void StoreInfo(string path, ObjectInfo objectInfo) |
106 |
{ |
107 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
108 |
Contract.Requires(objectInfo!=null); |
109 |
Contract.Requires(Path.IsPathRooted(path)); |
110 |
} |
111 |
|
112 |
public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue) |
113 |
{ |
114 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
115 |
Contract.Requires(getter!=null); |
116 |
Contract.Requires(Path.IsPathRooted(path)); |
117 |
|
118 |
return default(T); |
119 |
} |
120 |
|
121 |
public void SetStatus(string path, Action<FileState> setter) |
122 |
{ |
123 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
124 |
Contract.Requires(setter != null); |
125 |
Contract.Requires(Path.IsPathRooted(path)); |
126 |
} |
127 |
|
128 |
public void SetNetworkState(string path, NetworkOperation operation) |
129 |
{ |
130 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
131 |
Contract.Requires(Path.IsPathRooted(path)); |
132 |
Contract.Requires(Path.IsPathRooted(path)); |
133 |
} |
134 |
|
135 |
public NetworkOperation GetNetworkState(string path) |
136 |
{ |
137 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
138 |
Contract.Requires(Path.IsPathRooted(path)); |
139 |
|
140 |
return default(NetworkOperation); |
141 |
} |
142 |
|
143 |
public void ClearFileStatus(string path) |
144 |
{ |
145 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
146 |
Contract.Requires(Path.IsPathRooted(path)); |
147 |
} |
148 |
|
149 |
public void SetPithosStatus(PithosStatus status) |
150 |
{ |
151 |
} |
152 |
|
153 |
public void StartProcessing(CancellationToken token) |
154 |
{ |
155 |
Contract.Requires(token != null, "token can't be empty"); |
156 |
} |
157 |
|
158 |
public abstract string BlockHash { get; set; } |
159 |
public abstract int BlockSize { get; set; } |
160 |
public void ChangeRoots(string oldPath, string newPath) |
161 |
{ |
162 |
Contract.Requires(!String.IsNullOrWhiteSpace(oldPath)); |
163 |
Contract.Requires(Path.IsPathRooted(oldPath)); |
164 |
Contract.Requires(!string.IsNullOrWhiteSpace(newPath)); |
165 |
Contract.Requires(Path.IsPathRooted(newPath)); |
166 |
} |
167 |
|
168 |
public FileState GetStateByFilePath(string path) |
169 |
{ |
170 |
Contract.Requires(!String.IsNullOrWhiteSpace(path)); |
171 |
Contract.Requires(Path.IsPathRooted(path)); |
172 |
|
173 |
return null; |
174 |
} |
175 |
} |
176 |
} |