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