diplomacy: add methods to find {out,in}ner-most common node
This commit is contained in:
committed by
mwachs5
parent
67ab27f5a5
commit
fee67c4abf
@ -72,9 +72,21 @@ object TLImp extends NodeImp[TLClientPortParameters, TLManagerPortParameters, TL
|
||||
}
|
||||
|
||||
override def mixO(pd: TLClientPortParameters, node: OutwardNode[TLClientPortParameters, TLManagerPortParameters, TLBundle]): TLClientPortParameters =
|
||||
pd.copy(clients = pd.clients.map { c => c.copy (nodePath = node +: c.nodePath) })
|
||||
pd.copy(clients = pd.clients.map { c => c.copy (nodePath = node +: c.nodePath) })
|
||||
override def mixI(pu: TLManagerPortParameters, node: InwardNode[TLClientPortParameters, TLManagerPortParameters, TLBundle]): TLManagerPortParameters =
|
||||
pu.copy(managers = pu.managers.map { m => m.copy (nodePath = node +: m.nodePath) })
|
||||
pu.copy(managers = pu.managers.map { m => m.copy (nodePath = node +: m.nodePath) })
|
||||
override def getO(pu: TLManagerPortParameters): Option[BaseNode] = {
|
||||
val head = pu.managers.map(_.nodePath.headOption)
|
||||
if (head.exists(!_.isDefined) || head.map(_.get).distinct.size != 1) {
|
||||
None
|
||||
} else {
|
||||
val subproblem = pu.copy(managers = pu.managers.map(m => m.copy(nodePath = m.nodePath.tail)))
|
||||
getO(subproblem) match {
|
||||
case Some(x) => Some(x)
|
||||
case None => Some(head(0).get)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
case class TLIdentityNode() extends IdentityNode(TLImp)
|
||||
|
Reference in New Issue
Block a user