repositories
/
mTask.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use share lenses
[mTask.git]
/
Utils
/
SDS.icl
diff --git
a/Utils/SDS.icl
b/Utils/SDS.icl
index
9c6b46a
..
a7c3763
100644
(file)
--- a/
Utils/SDS.icl
+++ b/
Utils/SDS.icl
@@
-7,23
+7,30
@@
import Shares.mTaskShare
import Tasks.Examples
import qualified Data.Map as DM
from Data.Func import $
import Tasks.Examples
import qualified Data.Map as DM
from Data.Func import $
-
-derive class iTask MTaskShare
+import Data.Tuple
memoryShare :: String a -> Shared a | iTask a
memoryShare :: String a -> Shared a | iTask a
-memoryShare s d = sdsFocus s $ memoryStore "" $ Just d
+memoryShare s d = sdsFocus s $ memoryStore s $ Just d
+
+deviceStoreNP :: Shared [MTaskDevice]
+deviceStoreNP = sdsFocus Nothing $ deviceStore
-deviceStore :: Shared [MTaskDevice]
-deviceStore = sharedStore "mTaskDevices" []
+deviceStore :: RWShared (Maybe Int) [MTaskDevice] [MTaskDevice]
+deviceStore = SDSSource {SDSSource
+ | name = "deviceStore"
+ , read = \_->read realDeviceStore
+ , write= \p w->appFst ((<$) (lens p)) o write w realDeviceStore
+ }
-sdsStore :: Shared [MTaskShare]
-sdsStore = memoryShare "mTaskShares" []
+lens Nothing _ = True
+lens _ Nothing = True
+lens (Just p) (Just p`) = p` == -1 || p == p`
+
+realDeviceStore :: Shared [MTaskDevice]
+realDeviceStore = sharedStore "mTaskDevices" []
bcStateStore :: Shared BCState
bcStateStore = memoryShare "mTaskBCState" zero
mTaskTaskStore :: Shared [String]
mTaskTaskStore = memoryShare "mTaskTasks" $ 'DM'.keys allmTasks
bcStateStore :: Shared BCState
bcStateStore = memoryShare "mTaskBCState" zero
mTaskTaskStore :: Shared [String]
mTaskTaskStore = memoryShare "mTaskTasks" $ 'DM'.keys allmTasks
-
-getSDSRecord :: Int -> Task MTaskShare
-getSDSRecord i = get sdsStore @ \l->hd [s\\s<-l | s.identifier == i]