Statistics
| Branch: | Revision:

root / trunk / Pithos.Core / IStatusKeeper.cs @ cfed7823

History | View | Annotate | Download (5.3 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
    }
33

    
34
    [ContractClassFor(typeof(IStatusKeeper))]
35
    public abstract class IStatusKeeperContract : IStatusKeeper
36
    {
37
        public void SetFileOverlayStatus(string path, FileOverlayStatus status)
38
        {
39
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
40
            Contract.Requires(Path.IsPathRooted(path));
41
        }
42

    
43
        public void UpdateFileChecksum(string path, string checksum)
44
        {
45
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
46
            Contract.Requires(checksum!=null);
47
            Contract.Requires(Path.IsPathRooted(path));
48
        }
49

    
50
     /*   public void RemoveFileOverlayStatus(string path)
51
        {
52
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
53
            Contract.Requires(Path.IsPathRooted(path));
54
        }*/
55

    
56
        public void RenameFileOverlayStatus(string oldPath, string newPath)
57
        {
58
            Contract.Requires(!String.IsNullOrWhiteSpace(oldPath));
59
            Contract.Requires(Path.IsPathRooted(oldPath));
60
            Contract.Requires(!String.IsNullOrWhiteSpace(newPath));
61
            Contract.Requires(Path.IsPathRooted(newPath));
62

    
63
        }
64

    
65
        public void SetFileStatus(string path, FileStatus status)
66
        {
67
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
68
            Contract.Requires(Path.IsPathRooted(path));
69
        }
70

    
71
        public FileStatus GetFileStatus(string path)
72
        {
73
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
74
            Contract.Requires(Path.IsPathRooted(path));
75

    
76
            return default(FileStatus);
77
        }
78

    
79
        public FileOverlayStatus GetFileOverlayStatus(string path)
80
        {
81
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
82
            Contract.Requires(Path.IsPathRooted(path));
83

    
84
            return default(FileOverlayStatus);
85
        }
86

    
87
        public void ProcessExistingFiles(IEnumerable<FileInfo> paths)
88
        {
89
            Contract.Requires(paths!=null);
90
        }
91

    
92
        public void Stop()
93
        {
94
            
95
        }
96

    
97
        public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus)
98
        {
99
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
100
            Contract.Requires(Path.IsPathRooted(path));
101
        }
102

    
103
        public void StoreInfo(string path, ObjectInfo objectInfo)
104
        {
105
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
106
            Contract.Requires(objectInfo!=null);
107
            Contract.Requires(Path.IsPathRooted(path));
108
        }
109

    
110
        public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)
111
        {
112
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
113
            Contract.Requires(getter!=null);
114
            Contract.Requires(Path.IsPathRooted(path));
115

    
116
            return default(T);
117
        }
118

    
119
        public void SetStatus(string path, Action<FileState> setter)
120
        {
121
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
122
            Contract.Requires(setter != null);
123
            Contract.Requires(Path.IsPathRooted(path));
124
        }
125

    
126
        public void SetNetworkState(string path, NetworkOperation operation)
127
        {
128
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
129
            Contract.Requires(Path.IsPathRooted(path));
130
            Contract.Requires(Path.IsPathRooted(path));
131
        }
132

    
133
        public NetworkOperation GetNetworkState(string path)
134
        {
135
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
136
            Contract.Requires(Path.IsPathRooted(path));
137

    
138
            return default(NetworkOperation);
139
        }
140

    
141
        public void ClearFileStatus(string path)
142
        {
143
            Contract.Requires(!String.IsNullOrWhiteSpace(path));
144
            Contract.Requires(Path.IsPathRooted(path));
145
        }
146

    
147
        public void SetPithosStatus(PithosStatus status)
148
        {
149
        }
150

    
151
        public void StartProcessing(CancellationToken token)
152
        {
153
            Contract.Requires(token != null, "token can't be empty");
154
        }
155

    
156
        public abstract string BlockHash { get; set; }
157
        public abstract int BlockSize { get; set; }
158
    }
159
}