diff --git a/src/app/modules/main/chat_section/io_interface.nim b/src/app/modules/main/chat_section/io_interface.nim index c15e1d6a51..680532c879 100644 --- a/src/app/modules/main/chat_section/io_interface.nim +++ b/src/app/modules/main/chat_section/io_interface.nim @@ -1,18 +1,12 @@ -type - AccessInterface* {.pure inheritable.} = ref object of RootObj - ## Abstract class for any input/interaction with this module. +# Defines how parent module accesses this module +include ./private_interfaces/module_base_interface +include ./private_interfaces/module_access_interface -method delete*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this module view communicates with this module +include ./private_interfaces/module_view_delegate_interface -method load*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this controller communicates with this module +include ./private_interfaces/module_controller_delegate_interface -method isLoaded*(self: AccessInterface): bool {.base.} = - raise newException(ValueError, "No implementation available") - -type - ## Abstract class (concept) which must be implemented by object/s used in this - ## module. - DelegateInterface* = concept c - c.chatSectionDidLoad() +# Defines how submodules of this module communicate with this module +# will be added if needed \ No newline at end of file diff --git a/src/app/modules/main/chat_section/module.nim b/src/app/modules/main/chat_section/module.nim index 056d5d0a18..8216f2a8d6 100644 --- a/src/app/modules/main/chat_section/module.nim +++ b/src/app/modules/main/chat_section/module.nim @@ -1,25 +1,30 @@ -import io_interface, view +import io_interface +import ../io_interface as delegate_interface +import view export io_interface type - Module* [T: DelegateInterface] = ref object of AccessInterface - delegate: T + Module* = ref object of io_interface.AccessInterface + delegate: delegate_interface.AccessInterface view: View moduleLoaded: bool -proc newModule*[T](delegate: T): Module[T] = - result = Module[T]() +proc newModule*(delegate: delegate_interface.AccessInterface): Module = + result = Module() result.delegate = delegate - result.view = newView() + result.view = newView(result) result.moduleLoaded = false -method delete*[T](self: Module[T]) = +method delete*(self: Module) = self.view.delete -method load*[T](self: Module[T]) = - self.moduleLoaded = true - self.delegate.chatSectionDidLoad() +method load*(self: Module) = + self.view.load() -method isLoaded*[T](self: Module[T]): bool = +method isLoaded*(self: Module): bool = return self.moduleLoaded + +method viewDidLoad*(self: Module) = + self.moduleLoaded = true + self.delegate.chatSectionDidLoad() \ No newline at end of file diff --git a/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim new file mode 100644 index 0000000000..d057a91427 --- /dev/null +++ b/src/app/modules/main/chat_section/private_interfaces/module_access_interface.nim @@ -0,0 +1,8 @@ +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method load*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method isLoaded*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/chat_section/private_interfaces/module_base_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_base_interface.nim new file mode 100644 index 0000000000..64e14bbf51 --- /dev/null +++ b/src/app/modules/main/chat_section/private_interfaces/module_base_interface.nim @@ -0,0 +1,5 @@ +type + AccessInterface* {.pure inheritable.} = ref object of RootObj + +# Since nim doesn't support using concepts in second level nested types we +# define delegate interfaces within access interface. \ No newline at end of file diff --git a/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_controller_delegate_interface.nim new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim new file mode 100644 index 0000000000..59261bd5e9 --- /dev/null +++ b/src/app/modules/main/chat_section/private_interfaces/module_view_delegate_interface.nim @@ -0,0 +1,2 @@ +method viewDidLoad*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/chat_section/view.nim b/src/app/modules/main/chat_section/view.nim index f24c6dd410..53a95cd5b0 100644 --- a/src/app/modules/main/chat_section/view.nim +++ b/src/app/modules/main/chat_section/view.nim @@ -1,19 +1,22 @@ import NimQml import model +import io_interface QtObject: type View* = ref object of QObject + delegate: io_interface.AccessInterface model: Model - - proc setup(self: View) = - self.QObject.setup - self.model = newModel() proc delete*(self: View) = self.model.delete self.QObject.delete - proc newView*(): View = + proc newView*(delegate: io_interface.AccessInterface): View = new(result, delete) - result.setup() + result.QObject.setup + result.delegate = delegate + result.model = newModel() + + proc load*(self: View) = + self.delegate.viewDidLoad() \ No newline at end of file diff --git a/src/app/modules/main/community_section/controller.nim b/src/app/modules/main/community_section/controller.nim index 0af9648fa7..66da1be6d0 100644 --- a/src/app/modules/main/community_section/controller.nim +++ b/src/app/modules/main/community_section/controller.nim @@ -1,31 +1,31 @@ import Tables import controller_interface +import io_interface import ../../../../app_service/service/community/service as community_service export controller_interface type - Controller*[T: controller_interface.DelegateInterface] = - ref object of controller_interface.AccessInterface - delegate: T + Controller* = ref object of controller_interface.AccessInterface + delegate: io_interface.AccessInterface id: string communityService: community_service.ServiceInterface -proc newController*[T](delegate: T, +proc newController*(delegate: io_interface.AccessInterface, id: string, communityService: community_service.ServiceInterface): - Controller[T] = - result = Controller[T]() + Controller = + result = Controller() result.delegate = delegate result.id = id result.communityService = communityService -method delete*[T](self: Controller[T]) = +method delete*(self: Controller) = discard -method init*[T](self: Controller[T]) = +method init*(self: Controller) = discard method getId*(self: Controller): string = diff --git a/src/app/modules/main/community_section/controller_interface.nim b/src/app/modules/main/community_section/controller_interface.nim index baa0329ff9..94ea0cfd61 100644 --- a/src/app/modules/main/community_section/controller_interface.nim +++ b/src/app/modules/main/community_section/controller_interface.nim @@ -15,10 +15,4 @@ method getId*(self: AccessInterface): string {.base.} = method getCommunities*(self: AccessInterface): seq[community_service.Dto] {.base.} = raise newException(ValueError, "No implementation available") - - -type - ## Abstract class (concept) which must be implemented by object/s used in this - ## module. - DelegateInterface* = concept c \ No newline at end of file diff --git a/src/app/modules/main/community_section/io_interface.nim b/src/app/modules/main/community_section/io_interface.nim index 50300fffcf..680532c879 100644 --- a/src/app/modules/main/community_section/io_interface.nim +++ b/src/app/modules/main/community_section/io_interface.nim @@ -1,24 +1,12 @@ -type - AccessInterface* {.pure inheritable.} = ref object of RootObj - ## Abstract class for any input/interaction with this module. +# Defines how parent module accesses this module +include ./private_interfaces/module_base_interface +include ./private_interfaces/module_access_interface -method delete*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this module view communicates with this module +include ./private_interfaces/module_view_delegate_interface -method load*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this controller communicates with this module +include ./private_interfaces/module_controller_delegate_interface -method isLoaded*(self: AccessInterface): bool {.base.} = - raise newException(ValueError, "No implementation available") - -# View Delegate Interface -# Delegate for the view must be declared here due to use of QtObject and multi -# inheritance, which is not well supported in Nim. -method viewDidLoad*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - -type - ## Abstract class (concept) which must be implemented by object/s used in this - ## module. - DelegateInterface* = concept c - c.communitySectionDidLoad() +# Defines how submodules of this module communicate with this module +# will be added if needed \ No newline at end of file diff --git a/src/app/modules/main/community_section/module.nim b/src/app/modules/main/community_section/module.nim index 7e4fff350d..51d4fc89d9 100644 --- a/src/app/modules/main/community_section/module.nim +++ b/src/app/modules/main/community_section/module.nim @@ -1,39 +1,41 @@ import NimQml -import io_interface, view, controller +import io_interface +import ../io_interface as delegate_interface +import view, controller import ../../../../app_service/service/community/service as community_service export io_interface type - Module* [T: io_interface.DelegateInterface] = ref object of io_interface.AccessInterface - delegate: T + Module* = ref object of io_interface.AccessInterface + delegate: delegate_interface.AccessInterface view: View viewVariant: QVariant controller: controller.AccessInterface moduleLoaded: bool -proc newModule*[T](delegate: T, id: string, +proc newModule*(delegate: delegate_interface.AccessInterface, id: string, communityService: community_service.Service): - Module[T] = - result = Module[T]() + Module = + result = Module() result.delegate = delegate result.view = view.newView(result) result.viewVariant = newQVariant(result.view) - result.controller = controller.newController[Module[T]](result, id, communityService) + result.controller = controller.newController(result, id, communityService) result.moduleLoaded = false -method delete*[T](self: Module[T]) = +method delete*(self: Module) = self.view.delete self.viewVariant.delete self.controller.delete -method load*[T](self: Module[T]) = - self.moduleLoaded = true - self.delegate.communitySectionDidLoad() +method load*(self: Module) = + self.view.load() -method isLoaded*[T](self: Module[T]): bool = +method isLoaded*(self: Module): bool = return self.moduleLoaded method viewDidLoad*(self: Module) = - discard \ No newline at end of file + self.moduleLoaded = true + self.delegate.communitySectionDidLoad() \ No newline at end of file diff --git a/src/app/modules/main/community_section/private_interfaces/module_access_interface.nim b/src/app/modules/main/community_section/private_interfaces/module_access_interface.nim new file mode 100644 index 0000000000..d057a91427 --- /dev/null +++ b/src/app/modules/main/community_section/private_interfaces/module_access_interface.nim @@ -0,0 +1,8 @@ +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method load*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method isLoaded*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/community_section/private_interfaces/module_base_interface.nim b/src/app/modules/main/community_section/private_interfaces/module_base_interface.nim new file mode 100644 index 0000000000..64e14bbf51 --- /dev/null +++ b/src/app/modules/main/community_section/private_interfaces/module_base_interface.nim @@ -0,0 +1,5 @@ +type + AccessInterface* {.pure inheritable.} = ref object of RootObj + +# Since nim doesn't support using concepts in second level nested types we +# define delegate interfaces within access interface. \ No newline at end of file diff --git a/src/app/modules/main/community_section/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/community_section/private_interfaces/module_controller_delegate_interface.nim new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/modules/main/community_section/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/community_section/private_interfaces/module_view_delegate_interface.nim new file mode 100644 index 0000000000..59261bd5e9 --- /dev/null +++ b/src/app/modules/main/community_section/private_interfaces/module_view_delegate_interface.nim @@ -0,0 +1,2 @@ +method viewDidLoad*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/controller.nim b/src/app/modules/main/controller.nim index 9514d05c74..a2d3b81f7c 100644 --- a/src/app/modules/main/controller.nim +++ b/src/app/modules/main/controller.nim @@ -1,29 +1,29 @@ import Tables import controller_interface +import io_interface import ../../../app_service/service/community/service as community_service export controller_interface type - Controller*[T: controller_interface.DelegateInterface] = - ref object of controller_interface.AccessInterface - delegate: T + Controller* = ref object of controller_interface.AccessInterface + delegate: io_interface.AccessInterface communityService: community_service.ServiceInterface -proc newController*[T](delegate: T, +proc newController*(delegate: io_interface.AccessInterface, communityService: community_service.ServiceInterface): - Controller[T] = - result = Controller[T]() + Controller = + result = Controller() result.delegate = delegate result.communityService = communityService -method delete*[T](self: Controller[T]) = +method delete*(self: Controller) = discard -method init*[T](self: Controller[T]) = +method init*(self: Controller) = discard -method getCommunities*[T](self: Controller[T]): seq[community_service.Dto] = +method getCommunities*(self: Controller): seq[community_service.Dto] = return self.communityService.getCommunities() \ No newline at end of file diff --git a/src/app/modules/main/controller_interface.nim b/src/app/modules/main/controller_interface.nim index 974e45fe8b..ccee56429b 100644 --- a/src/app/modules/main/controller_interface.nim +++ b/src/app/modules/main/controller_interface.nim @@ -11,11 +11,4 @@ method init*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") method getCommunities*(self: AccessInterface): seq[community_service.Dto] {.base.} = - raise newException(ValueError, "No implementation available") - - -type - ## Abstract class (concept) which must be implemented by object/s used in this - ## module. - DelegateInterface* = concept c - \ No newline at end of file + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/io_interface.nim b/src/app/modules/main/io_interface.nim index decbca329d..edc05b78d0 100644 --- a/src/app/modules/main/io_interface.nim +++ b/src/app/modules/main/io_interface.nim @@ -1,22 +1,18 @@ -type - AccessInterface* {.pure inheritable.} = ref object of RootObj - ## Abstract class for any input/interaction with this module. +# Defines how parent module accesses this module +include ./private_interfaces/module_base_interface +include ./private_interfaces/module_access_interface -method delete*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this module view communicates with this module +include ./private_interfaces/module_view_delegate_interface -method load*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") - -# View Delegate Interface -# Delegate for the view must be declared here due to use of QtObject and multi -# inheritance, which is not well supported in Nim. -method viewDidLoad*(self: AccessInterface) {.base.} = - raise newException(ValueError, "No implementation available") +# Defines how this controller communicates with this module +include ./private_interfaces/module_controller_delegate_interface +# Defines how submodules of this module communicate with this module +include ./private_interfaces/module_chat_section_delegate_interface +include ./private_interfaces/module_community_section_delegate_interface +# This way (using concepts) is used only for the modules managed by AppController type - ## Abstract class (concept) which must be implemented by object/s used in this - ## module. DelegateInterface* = concept c - c.mainDidLoad() \ No newline at end of file + c.mainDidLoad() diff --git a/src/app/modules/main/module.nim b/src/app/modules/main/module.nim index ef85d7112a..b4c5a99088 100644 --- a/src/app/modules/main/module.nim +++ b/src/app/modules/main/module.nim @@ -19,20 +19,6 @@ type chatSectionModule: chat_section_module.AccessInterface communitySectionsModule: OrderedTable[string, community_section_module.AccessInterface] -################################################# -# Forward declaration section - -# Controller Delegate Interface - - -# Chat Section Module Delegate Interface -proc chatSectionDidLoad*[T](self: Module[T]) - -# Community Section Module Delegate Interface -proc communitySectionDidLoad*[T](self: Module[T]) - -################################################# - proc newModule*[T](delegate: T, communityService: community_service.Service): Module[T] = @@ -40,16 +26,16 @@ proc newModule*[T](delegate: T, result.delegate = delegate result.view = view.newView(result) result.viewVariant = newQVariant(result.view) - result.controller = controller.newController[Module[T]](result, communityService) + result.controller = controller.newController(result, communityService) singletonInstance.engine.setRootContextProperty("mainModule", result.viewVariant) # Submodules - result.chatSectionModule = chat_section_module.newModule[Module[T]](result) + result.chatSectionModule = chat_section_module.newModule(result) result.communitySectionsModule = initOrderedTable[string, community_section_module.AccessInterface]() let communities = result.controller.getCommunities() for c in communities: - result.communitySectionsModule[c.id] = community_section_module.newModule[Module[T]](result, + result.communitySectionsModule[c.id] = community_section_module.newModule(result, c.id, communityService) method delete*[T](self: Module[T]) = @@ -87,11 +73,11 @@ proc checkIfModuleDidLoad [T](self: Module[T]) = self.delegate.mainDidLoad() -proc chatSectionDidLoad*[T](self: Module[T]) = +method chatSectionDidLoad*[T](self: Module[T]) = self.checkIfModuleDidLoad() -proc communitySectionDidLoad*[T](self: Module[T]) = +method communitySectionDidLoad*[T](self: Module[T]) = self.checkIfModuleDidLoad() method viewDidLoad*[T](self: Module[T]) = - discard \ No newline at end of file + self.checkIfModuleDidLoad() \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_access_interface.nim b/src/app/modules/main/private_interfaces/module_access_interface.nim new file mode 100644 index 0000000000..7add4c2d80 --- /dev/null +++ b/src/app/modules/main/private_interfaces/module_access_interface.nim @@ -0,0 +1,5 @@ +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method load*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/private_interfaces/module_base_interface.nim b/src/app/modules/main/private_interfaces/module_base_interface.nim new file mode 100644 index 0000000000..64e14bbf51 --- /dev/null +++ b/src/app/modules/main/private_interfaces/module_base_interface.nim @@ -0,0 +1,5 @@ +type + AccessInterface* {.pure inheritable.} = ref object of RootObj + +# Since nim doesn't support using concepts in second level nested types we +# define delegate interfaces within access interface. \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_chat_section_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_chat_section_delegate_interface.nim new file mode 100644 index 0000000000..e1411896db --- /dev/null +++ b/src/app/modules/main/private_interfaces/module_chat_section_delegate_interface.nim @@ -0,0 +1,2 @@ +method chatSectionDidLoad*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/private_interfaces/module_community_section_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_community_section_delegate_interface.nim new file mode 100644 index 0000000000..00d3163f68 --- /dev/null +++ b/src/app/modules/main/private_interfaces/module_community_section_delegate_interface.nim @@ -0,0 +1,2 @@ +method communitySectionDidLoad*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_controller_delegate_interface.nim new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim b/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim new file mode 100644 index 0000000000..59261bd5e9 --- /dev/null +++ b/src/app/modules/main/private_interfaces/module_view_delegate_interface.nim @@ -0,0 +1,2 @@ +method viewDidLoad*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/startup/login/private_interfaces/module_access_interface.nim b/src/app/modules/startup/login/private_interfaces/module_access_interface.nim new file mode 100644 index 0000000000..538d651b33 --- /dev/null +++ b/src/app/modules/startup/login/private_interfaces/module_access_interface.nim @@ -0,0 +1,8 @@ +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method load*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method isLoaded*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/startup/onboarding/private_interfaces/module_access_interface.nim b/src/app/modules/startup/onboarding/private_interfaces/module_access_interface.nim new file mode 100644 index 0000000000..538d651b33 --- /dev/null +++ b/src/app/modules/startup/onboarding/private_interfaces/module_access_interface.nim @@ -0,0 +1,8 @@ +method delete*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method load*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + +method isLoaded*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") \ No newline at end of file