home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 488.lha / TCL_alpha2 / tcl.lzh / tcl / docs / tcla / resources.doc < prev    next >
Encoding:
Text File  |  1990-05-04  |  2.9 KB  |  91 lines

  1.  
  2.  
  3. Resource Banks
  4. --------------
  5.  
  6. You must call TclaInitResources() to access the resource bank and use
  7. the resource bank management routines.
  8.  
  9. The model of easily intercommunicating programs provided by Tcl made
  10. clear that it was necessary to provide a way for tasks to formally
  11. share named data entities.  For example, a SMUS loader might handle
  12. the loading and unloading of SMUS files, but a SMUS player would need
  13. to be able to locate them in order to play them.
  14.  
  15. Resource banks were created by Hackercorp to address needs such as this,
  16. and the resulting code is placed into the public domain.
  17.  
  18. Resource banks work like the Amiga resources accessed by AddResource,
  19. OpenResource, etc, but they maintain a number of named lists to which
  20. the actual data is a subordinate named entry to.
  21.  
  22. For example,
  23.  
  24. ResourceBankList -->  SMUS  -->  8SVX  -->  ILBM  -->  null
  25.                        |          |          |
  26.                     introsong   strat1      pic1
  27.                        |          |          |
  28.                     highscore   organ       null
  29.                        |          |
  30.                       null      ahhvoice
  31.                                   |
  32.                                 null
  33.  
  34.  
  35.  
  36. The resource bank master list entry is located by doing an Amiga
  37. OpenResource looking for resourcebank.resource.  The first program
  38. to look for the resource and not find it creates it.  The
  39. resourcebank.resource entry and the top level entries in the list
  40. are not expected to be removed for an entire run (i.e. til the
  41. next reboot)  This should only amount to a few dozen bytes.
  42.  
  43. To the resource handler, a resource is just a blob pointed to by
  44. a 32-bit pointer that's specified when you connect something to
  45. an entry in the resource bank.  That is to say that the resource
  46. bank handling routines don't know anything about and don't care
  47. about anything at the other end of that pointer.
  48.  
  49.  
  50. The user-callable routines are:
  51.  
  52. void *LocateResource(char *groupname, char *itemname)
  53.  
  54.     given group name and entry name, locate a resource entry within 
  55.     the resource bank and return it's data pointer.  Returns NULL
  56.     if it can't find the specified resource entry.
  57.  
  58.  
  59. int ConnectResource(char *groupname, char *resourcename, void *data)
  60.  
  61.     given the name of an entry and the name of a group for it to go in,
  62.     locate the group, creating it if it doesn't exist, and find or
  63.     create the named entry, then set the data pointer to the passed
  64.     data pointer.
  65.  
  66.  
  67. void *DisconnectResource(char *groupname, char *resourcename)
  68.  
  69.     given a the name of a group and a resource entry, locat the
  70.     entry, remove it from the list and return the pointer to
  71.     the data attached to that resource.  Returns NULL if it couldn't
  72.     find it.
  73.  
  74.  
  75.  
  76.  
  77.  
  78. Tcl-callable resource routines
  79. ------------------------------
  80.  
  81. There is a routine callable from Tcl that does a couple things with resource
  82. banks.
  83.  
  84. resource list banks
  85.  
  86. will return a list containing the names of all the banks, and
  87.  
  88. resource list entries foo
  89.  
  90. will return a list containing the names of all the entries in bank foo.
  91.