Initial imss Basic Module

This commit is contained in:
René Linder 2023-09-21 15:55:24 +02:00
parent 5c030f2eff
commit da87ec4993
4 changed files with 145 additions and 0 deletions

3
.gitmodules vendored Normal file
View file

@ -0,0 +1,3 @@
[submodule "lhs_lib"]
path = lhs_lib
url = https://gitea.lihaso.com/PB_Includes/lhs_lib.git

26
imss.pb Normal file
View file

@ -0,0 +1,26 @@
;***************************************************************
;*
;* IMSS Sample
;*
;* (c) 2023 by Linder Hard- und Software
;*
;* GPL v2.0 Only
;*
;*
;***************************************************************
EnableExplicit
Define MyUUID.s
XIncludeFile "imss.pbi"
MyUUID = imss::Create()
Debug "Database Created:"+MyUUID
imss::Save(MyUUID, "TestName", "TestValue")
Debug "Test:"+imss::Get(MyUUID, "TestName")
imss::Del(MyUUID, "TestName")
Debug "Test:"+imss::Get(MyUUID, "TestName")
imss::Kill(MyUUID)
Debug "Killed"

115
imss.pbi Normal file
View file

@ -0,0 +1,115 @@
;***************************************************************
;*
;* IMSS Main Module
;*
;* (c) 2023 by Linder Hard- und Software
;*
;* GPL v2.0 Only
;*
;*
;***************************************************************
EnableExplicit
DeclareModule IMSS
Declare.s Create()
Declare Save(UUID.s, ValueName.s, Value.s, UID.s = "", LockID = 0 , Lock = 0)
Declare.s Get(UUID.s, ValueName.s, UID.s = "", LockID = 0 , Lock = 0)
Declare Del(UUID.s, ValueName.s, UID.s = "", LockID = 0 , Lock = 0)
Declare DelUID(UUID.s, UID.s, LockID = 0 , Lock = 0)
Declare Lock(UUID.s, ValueName.s, UID.s = "", LockID = 0, Lock = 0)
Declare LockUID(UUID.s, UID.s, LockID, Lock)
Declare UnLock(UUID.s, ValueName.s, UID.s = "", LockID = 0 , Lock = 0)
Declare UnLockUID(UUID.s, UID.s, LockID, Lock)
Declare Kill(UUID.s)
EndDeclareModule
Module IMSS
IncludeFile "lhs_lib/SYS/lhs_uuid.pbi"
Structure Imss_Object
Map Value.s()
Lock.i
LockID.i
EndStructure
Structure Imss_Database
Map Database.Imss_Object()
Lock.i
LockID.i
EndStructure
Global NewMap IMSSDB.Imss_Database()
Procedure.s Create()
Protected.s UUID
UUID.s = CreateUUID()
IMSSDB(UUID)\Lock = 0
ProcedureReturn UUID
EndProcedure
Procedure Save(UUID.s, ValueName.s, Value.s, UID.s = "")
If FindMapElement(IMSSDB(), UUID)
If UID = ""
IMSSDB(UUID)\Database(ValueName)\Value("Value") = Value
Else
IMSSDB(UUID)\Database(UID)\Value(ValueName) = Value
EndIf
ProcedureReturn #True
Else
ProcedureReturn #False
EndIf
EndProcedure
Procedure.s Get(UUID.s, ValueName.s, UID.s = "")
If FindMapElement(IMSSDB(), UUID)
If UID = ""
If FindMapElement(IMSSDB(UUID)\Database(), ValueName)
ProcedureReturn IMSSDB(UUID)\Database(ValueName)\Value("Value")
Else
ProcedureReturn ""
EndIf
Else
If FindMapElement(IMSSDB(UUID)\Database(), UID)
If FindMapElement(IMSSDB(UUID)\Database(UID)\Value(), ValueName)
ProcedureReturn IMSSDB(UUID)\Database(UID)\Value(ValueName)
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure Del(UUID.s, ValueName.s, UID.s = "")
If FindMapElement(IMSSDB(), UUID)
If UID = ""
If FindMapElement(IMSSDB(UUID)\Database(), ValueName)
DeleteMapElement(IMSSDB(UUID)\Database(), ValueName)
EndIf
Else
If FindMapElement(IMSSDB(UUID)\Database(), UID)
If FindMapElement(IMSSDB(UUID)\Database(UID)\Value(), ValueName)
DeleteMapElement(IMSSDB(UUID)\Database(UID)\Value(), ValueName)
EndIf
EndIf
EndIf
EndIf
EndProcedure
Procedure DelUID(UUID.s, UID.s)
If FindMapElement(IMSSDB(), UUID)
If FindMapElement(IMSSDB(UUID)\Database(), UID)
DeleteMapElement(IMSSDB(UUID)\Database(), UID)
EndIf
EndIf
EndProcedure
Procedure Kill(UUID.s)
If FindMapElement(IMSSDB(), UUID)
DeleteMapElement(IMSSDB(), UUID)
EndIf
EndProcedure
EndModule

1
lhs_lib Submodule

@ -0,0 +1 @@
Subproject commit 28ddc320e56090f5fc0fd827d83e97aa9863f116