equal
deleted
inserted
replaced
176 |
176 |
177 type Nodes = Map[Node.Name, Node] |
177 type Nodes = Map[Node.Name, Node] |
178 |
178 |
179 object Version |
179 object Version |
180 { |
180 { |
181 val init: Version = Version() |
181 val init: Version = new Version() |
182 } |
182 |
183 |
183 def make(nodes: Nodes): Version = new Version(new_id(), nodes) |
184 sealed case class Version( |
184 } |
|
185 |
|
186 class Version private( |
185 val id: Version_ID = no_id, |
187 val id: Version_ID = no_id, |
186 val nodes: Nodes = Map.empty.withDefaultValue(Node.empty)) |
188 val nodes: Nodes = Map.empty.withDefaultValue(Node.empty)) |
187 { |
189 { |
188 def topological_order: List[Node.Name] = |
190 def topological_order: List[Node.Name] = |
189 { |
191 { |
334 def find_command(version: Version, id: ID): Option[(Node, Command)] = |
336 def find_command(version: Version, id: ID): Option[(Node, Command)] = |
335 commands.get(id) orElse execs.get(id) match { |
337 commands.get(id) orElse execs.get(id) match { |
336 case None => None |
338 case None => None |
337 case Some(st) => |
339 case Some(st) => |
338 val command = st.command |
340 val command = st.command |
339 version.nodes.get(command.node_name).map((_, command)) |
341 val node = version.nodes(command.node_name) |
|
342 Some((node, command)) |
340 } |
343 } |
341 |
344 |
342 def the_version(id: Version_ID): Version = versions.getOrElse(id, fail) |
345 def the_version(id: Version_ID): Version = versions.getOrElse(id, fail) |
343 def the_command(id: Command_ID): Command.State = commands.getOrElse(id, fail) // FIXME rename |
346 def the_command(id: Command_ID): Command.State = commands.getOrElse(id, fail) // FIXME rename |
344 def the_exec(id: Exec_ID): Command.State = execs.getOrElse(id, fail) |
347 def the_exec(id: Exec_ID): Command.State = execs.getOrElse(id, fail) |