Design Mode 1 simple factory, simple design mode Factory

Source: Internet
Author: User

Design Mode 1 simple factory, simple design mode Factory

1 #-*-coding: UTF-8-*-2 3 4 class Main (): 5 slot = None 6 7 def _ init _ (self ): 8 pass 9 10 def triggerEvent (self, slot): 11 pass12 13 def endup (sef): 14 pass15 16 def run (self): 17 pass18 19 # slot function, in triggerEvent, call 20 @ pyqtSlot () 21 def handleCard (): 22 pass23 24 25 26 class ChildMain1 (main): 27 slot = None28 29 def _ init _ (self): 30 pass31 32 def triggerEvent (self, slot): 33 self. slot = slot34 ...... 35 # a event business logic 36 ...... 37 return self. slot38 print "a event business logic completed" 39 40 def endup (sef): 41 # End Process 42 43 def run (self): 44 while True: 45 pass46 if True: 47 pass48 print "a process completed" 49 50 # slot function, call 51 @ pyqtSlot () 52 def handleCard (): 53 'a event triggered in triggerEvent. '54 55 class ChildMain2 (Main): 56 slot = None57 58 def _ init _ (self): 59 pass60 61 def triggerEvent (self, slot): 62 self. slot = slot63 ...... 64 # B event business logic 65 ...... 66 return self. slot67 print "business logic completed" 68 69 def endup (sef): 70 # B event completion process 71 72 def run (self): 73 while True: 74 pass75 if True: 76 pass77 print "B process completed" 78 79 # slot function, call 80 @ pyqtSlot () 81 def handleCard (): 82 'B event triggered in triggerEvent. '83 84 class RunMain (): 85 def run (self, topic): 86 dic = {87 "a": ChildMain1, 88 "B": ChildMain289} 90 if dic. has_key (topic): 91 di = dic [topic] () 92 return 93 94

A simple factory is to judge how to execute and what to execute during execution.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.