The revisions state variable records for each client which files contain pending
edits for that client. The value is a map of file names to the current edit operation.
The conflicts state variable is used when committing changes to the database.
It contains a set of files with version conflicts. Such files must be resolved before a
change may be committed to the repository.
The commitPending state variable records whether a client is in the process
of perfoming a commit operation. Client operations are disabled when there is a
pending commit operation.
Derived state
The C# model program includes several elements of derived state. These aremethods
or properties that query the state but do not change it.
partial static class User
{
static bool CommitPending(string user)
{ return commitPending.Contains(user); }
174 Modeling Systems with Structured State
static bool IsUser(string user)
{ return version.ContainsKey(user); }
static bool CanStep(string user)
{ return IsUser(user) && !CommitPending(user); }
static Set
Users()
{ return version.Keys; }
}
The CommitPending method says whether a given user is waiting for a Commit
action to respond.
The IsUser method determines whether the string given as its argument has
appeared in at least one Synchronize action.
The CanStep method says whether the client actions Commit, Resolve, Edit, and
Revert can be taken.
Pages:
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244