home *** CD-ROM | disk | FTP | other *** search
- -- 2000.02.26
- -- Clive Green <clivegreen@atlas.co.uk>
-
- ------------------------------------------------------------------------------------------------------
-
- -- this simply holds a propList of unique instantiates - one for each general service which is needed
- -- by the programme.
-
- ------------------------------------------------------------------------------------------------------
-
- -- declare properties:
- property main -- main code directory object
- property registry -- propList of refs to objects providing general services to the program
-
- ------------------------------------------------------------------------------------------------------
-
- on new me,L
-
- -- (1) extract and check arguments:
-
- -- check for a parameter list:
- if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"serviceManager:new"]
-
- -- a reference to the parent codebase is REQUIRED:
- main = L[#main]
- if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"serviceManager:new"]
-
- -- add my object reference to the parameter list passed to me:
- L[#serviceManager] = me
-
- --------------------
-
- -- (2) what services are required by the programme?
- sL = []
-
- add sL,#CDROMservice
- add sL,#feedbackService
- add sL,#cursorService
- add sL,#conditionsService
- add sL,#mainLogoService
- add sL,#glueService
- add sL,#navigationService
- add sL,#onlineService
- add sL,#installerService
- add sL,#soundFXService
-
- --------------------
-
- -- compile a list of programming service instantiates:
- registry = [:]
- repeat with i in sL
-
- -- attempt to obtain a legitimate service object:
- o = main.createInstance(i,L)
-
- -- all services are REQUIRED; fail on first missing instance:
- if (ilk(o) <> #instance) then return o
-
- -- store named instantiate:
- registry[i] = o
-
- end repeat
-
- --------------------
-
- -- pass back my address:
- return me
-
- ----------------------------------------------------------------------------------------------------
-
- on getService me,n
-
- -- pass back a reference to the programme service #ref supplied:
- o = registry[n]
-
- -- only provide pukka object references:
- if (ilk(o) <> #instance) then return [#error:#e0011]
- return o
-
- ----------------------------------------------------------------------------------------------------