2 using System.Collections.Generic;
3 using System.Diagnostics.Contracts;
6 using System.Threading;
7 using Pithos.Interfaces;
11 [ContractClass(typeof(IStatusKeeperContract))]
12 public interface IStatusKeeper
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);
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);
28 void StartProcessing(CancellationToken token);
30 string BlockHash { get; set; }
31 int BlockSize { get; set; }
32 void ChangeRoots(string oldPath, string newPath);
35 [ContractClassFor(typeof(IStatusKeeper))]
36 public abstract class IStatusKeeperContract : IStatusKeeper
38 public void SetFileOverlayStatus(string path, FileOverlayStatus status)
40 Contract.Requires(!String.IsNullOrWhiteSpace(path));
41 Contract.Requires(Path.IsPathRooted(path));
44 public void UpdateFileChecksum(string path, string checksum)
46 Contract.Requires(!String.IsNullOrWhiteSpace(path));
47 Contract.Requires(checksum!=null);
48 Contract.Requires(Path.IsPathRooted(path));
51 /* public void RemoveFileOverlayStatus(string path)
53 Contract.Requires(!String.IsNullOrWhiteSpace(path));
54 Contract.Requires(Path.IsPathRooted(path));
57 public void RenameFileOverlayStatus(string oldPath, string newPath)
59 Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));
60 Contract.Requires(Path.IsPathRooted(oldPath));
61 Contract.Requires(!String.IsNullOrWhiteSpace(newPath));
62 Contract.Requires(Path.IsPathRooted(newPath));
66 public void SetFileStatus(string path, FileStatus status)
68 Contract.Requires(!String.IsNullOrWhiteSpace(path));
69 Contract.Requires(Path.IsPathRooted(path));
72 public FileStatus GetFileStatus(string path)
74 Contract.Requires(!String.IsNullOrWhiteSpace(path));
75 Contract.Requires(Path.IsPathRooted(path));
77 return default(FileStatus);
80 public FileOverlayStatus GetFileOverlayStatus(string path)
82 Contract.Requires(!String.IsNullOrWhiteSpace(path));
83 Contract.Requires(Path.IsPathRooted(path));
85 return default(FileOverlayStatus);
88 public void ProcessExistingFiles(IEnumerable<FileInfo> paths)
90 Contract.Requires(paths!=null);
98 public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus)
100 Contract.Requires(!String.IsNullOrWhiteSpace(path));
101 Contract.Requires(Path.IsPathRooted(path));
104 public void StoreInfo(string path, ObjectInfo objectInfo)
106 Contract.Requires(!String.IsNullOrWhiteSpace(path));
107 Contract.Requires(objectInfo!=null);
108 Contract.Requires(Path.IsPathRooted(path));
111 public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)
113 Contract.Requires(!String.IsNullOrWhiteSpace(path));
114 Contract.Requires(getter!=null);
115 Contract.Requires(Path.IsPathRooted(path));
120 public void SetStatus(string path, Action<FileState> setter)
122 Contract.Requires(!String.IsNullOrWhiteSpace(path));
123 Contract.Requires(setter != null);
124 Contract.Requires(Path.IsPathRooted(path));
127 public void SetNetworkState(string path, NetworkOperation operation)
129 Contract.Requires(!String.IsNullOrWhiteSpace(path));
130 Contract.Requires(Path.IsPathRooted(path));
131 Contract.Requires(Path.IsPathRooted(path));
134 public NetworkOperation GetNetworkState(string path)
136 Contract.Requires(!String.IsNullOrWhiteSpace(path));
137 Contract.Requires(Path.IsPathRooted(path));
139 return default(NetworkOperation);
142 public void ClearFileStatus(string path)
144 Contract.Requires(!String.IsNullOrWhiteSpace(path));
145 Contract.Requires(Path.IsPathRooted(path));
148 public void SetPithosStatus(PithosStatus status)
152 public void StartProcessing(CancellationToken token)
154 Contract.Requires(token != null, "token can't be empty");
157 public abstract string BlockHash { get; set; }
158 public abstract int BlockSize { get; set; }
159 public void ChangeRoots(string oldPath, string newPath)
161 Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));
162 Contract.Requires(Path.IsPathRooted(oldPath));
163 Contract.Requires(!string.IsNullOrWhiteSpace(newPath));
164 Contract.Requires(Path.IsPathRooted(newPath));