예제 #1
0
class ServicesLocator:
    
    instance = None
    
    def __init__(self, useGetInstanceInstead):
        self.factsService = FactsService(self)
        self.decksService = DecksService(self)
        self.languagesService = LanguagesService(self)
        self.morphemesService = MorphemesService(self)
        self.japaneseMorphemesService = JapaneseMorphemesService(self)
        self.frenchMorphemesService = FrenchMorphemesService(self)
        
        ServicesLocator.instance = self
        
        self.factsService.setupServices()
        self.decksService.setupServices()
        self.languagesService.setupServices()
        self.morphemesService.setupServices()
        self.japaneseMorphemesService.setupServices()
        self.frenchMorphemesService.setupServices()
    
    @staticmethod
    def getInstance():
        if ServicesLocator.instance == None:
            ServicesLocator.instance = ServicesLocator(None)
        return ServicesLocator.instance

    def getFactsService(self):
        return self.factsService
    
    def getDecksService(self):
        return self.decksService
    
    def getLanguagesService(self):
        return self.languagesService
    
    def getMorphemesService(self, language = None):
        
        if language != None:
            if language.nameId == Language.JAPANESE:
                return self.japaneseMorphemesService
            elif language.nameId == Language.FRENCH:
                return self.frenchMorphemesService
        return self.morphemesService
예제 #2
0
 def __init__(self, useGetInstanceInstead):
     self.factsService = FactsService(self)
     self.decksService = DecksService(self)
     self.languagesService = LanguagesService(self)
     self.morphemesService = MorphemesService(self)
     self.japaneseMorphemesService = JapaneseMorphemesService(self)
     self.frenchMorphemesService = FrenchMorphemesService(self)
     
     ServicesLocator.instance = self
     
     self.factsService.setupServices()
     self.decksService.setupServices()
     self.languagesService.setupServices()
     self.morphemesService.setupServices()
     self.japaneseMorphemesService.setupServices()
     self.frenchMorphemesService.setupServices()