home *** CD-ROM | disk | FTP | other *** search
/ LineOne ISP Sign-Up 5 / LineOne.iso / assets / cxt / scripts / parentScripts.cst / 00061_serviceManager parent.ls < prev    next >
Encoding:
Text File  |  2001-01-27  |  2.3 KB  |  80 lines

  1. -- 2000.02.26
  2. -- Clive Green <clivegreen@atlas.co.uk>
  3.  
  4. ------------------------------------------------------------------------------------------------------
  5.  
  6. -- this simply holds a propList of unique instantiates - one for each general service which is needed
  7. -- by the programme.
  8.  
  9. ------------------------------------------------------------------------------------------------------
  10.  
  11. -- declare properties:
  12. property main     -- main code directory object
  13. property registry -- propList of refs to objects providing general services to the program
  14.  
  15. ------------------------------------------------------------------------------------------------------
  16.  
  17. on new me,L
  18.   
  19.   -- (1) extract and check arguments:
  20.   
  21.   -- check for a parameter list:
  22.   if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"serviceManager:new"]
  23.   
  24.   -- a reference to the parent codebase is REQUIRED:
  25.   main = L[#main]
  26.   if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"serviceManager:new"]
  27.   
  28.   -- add my object reference to the parameter list passed to me:
  29.   L[#serviceManager] = me
  30.   
  31.   --------------------
  32.   
  33.   -- (2) what services are required by the programme?
  34.   sL = []
  35.   
  36.   add sL,#CDROMservice
  37.   add sL,#feedbackService
  38.   add sL,#cursorService
  39.   add sL,#conditionsService
  40.   add sL,#mainLogoService
  41.   add sL,#glueService
  42.   add sL,#navigationService
  43.   add sL,#onlineService
  44.   add sL,#installerService
  45.   add sL,#soundFXService
  46.   
  47.   --------------------
  48.   
  49.   -- compile a list of programming service instantiates:
  50.   registry = [:]
  51.   repeat with i in sL
  52.     
  53.     -- attempt to obtain a legitimate service object:
  54.     o = main.createInstance(i,L)
  55.     
  56.     -- all services are REQUIRED; fail on first missing instance:
  57.     if (ilk(o) <> #instance) then return o
  58.     
  59.     -- store named instantiate:
  60.     registry[i] = o
  61.     
  62.   end repeat
  63.   
  64.   --------------------
  65.   
  66.   -- pass back my address:
  67.   return me
  68.   
  69.   ----------------------------------------------------------------------------------------------------
  70.   
  71. on getService me,n
  72.   
  73.   -- pass back a reference to the programme service #ref supplied:
  74.   o = registry[n]
  75.   
  76.   -- only provide pukka object references:
  77.   if (ilk(o) <> #instance) then return [#error:#e0011]
  78.   return o
  79.   
  80.   ----------------------------------------------------------------------------------------------------