NavMap Requests - laforge49/Asynchronous-Functional-Programming GitHub Wiki
GetRequest and SetRequest can also be used to access the contents of a NavMap. In this case, the last name in the pathname is the key of the item to be fetched, put or removed.
##NavMap Test
Test code.
val systemServices = SystemServices(new ServicesRootComponentFactory)
val dbName = "IntStringMapNoLog.db"
val file = new java.io.File(dbName)
file.delete
val properties = new Properties
properties.put("dbPathname", dbName)
val db = Subsystem(
systemServices,
new SmallNoLogComponentFactory,
properties = properties,
actorId = ActorId("db"))
val one = IncDesString(null)
val two = IncDesString(null)
val three = IncDesString(null)
val ten = IncDesString(null)
val chain = new Chain
chain.op(systemServices, Register(db))
chain.op(db, SetRequest(db, "/$", IncDesIntStringMap(null, db)))
chain.op(one, Set(null, "One"))
chain.op(db, SetRequest(db, "/$/1", one))
chain.op(two, Set(null, "Two"))
chain.op(db, SetRequest(db, "/$/2", two))
chain.op(db, SetRequest(db, "/$/2", null))
chain.op(three, Set(null, "Three"))
chain.op(db, SetRequest(db, "/$/3", three))
chain.op(ten, Set(null, "Ten"))
chain.op(db, SetRequest(db, "/$/10", ten))
chain.op(db, GetRequest(db, "/$/1"), "one")
chain.op(db, GetRequest(db, "/$/2"), "two")
chain.op(db, GetRequest(db, "/$/3"), "three")
chain.op(db, GetRequest(db, "/$/10"), "ten")
Future(systemServices, chain)
println(chain.results)
systemServices.close
Output.
{one=org.agilewiki.incDes.IncDesString@7eb5666,
ten=org.agilewiki.incDes.IncDesString@6b754699,
three=org.agilewiki.incDes.IncDesString@606e1dec,
two=null}