;*************************************************************** ;* ;* 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