home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 14 Text / 14-Text.zip / boview.zip / B-DESIGN.TXT < prev   
Text File  |  1993-12-14  |  9KB  |  209 lines

  1. Bento Design Overview
  2. `````````````````````
  3.  
  4. This file provides an overview of the Bento design.  It describes
  5. the design  more from the API perspective than the format perspective.
  6. However,  most of the concepts also apply to the format level.  In
  7. some respects  the format is simpler than the API, but it difficult
  8. to understand without first understanding the API functionality it is
  9. intended to support.
  10.  
  11. Bento Entities
  12. ==============
  13.  
  14. The easiest way to begin understanding the Bento design is probably to
  15. review the entities that the API manipulates.
  16.  
  17. Primary Entities
  18. ================
  19.  
  20. The most important entities in the Bento design are containers, objects,
  21. properties, values, and types.
  22.  
  23. Every object is in some container.  An object consists of a set of
  24. properties.  The properties are not in any particular order.    Each
  25. property consists of a sequence of values, indexed from 1 to n.  Every
  26. object must have at least one property, and that property must have at
  27. least one value.  Each value has a type; several values of the same
  28. property may have the same type.  The type of a value is unrelated to
  29. its index.  Each value consists of a variable length sequence of bytes.
  30.  
  31. Now let us look at these primary entities in more detail.
  32.  
  33. Containers
  34. ----------
  35.  
  36. All Bento objects are stored in containers.  Bento knows very little
  37. about a container beyond the objects in it.  However, the container
  38. itself is an object, and can have properties, so applications can
  39. specify further information about the container if they wish.
  40.  
  41. Containers are often files, but they can also be many other forms of
  42. storage.  For example, we are already planning to support the following
  43. types of containers: blocks of memory, the clipboard, network messages,
  44. and Bento values.  Undoubtedly other types of containers will be useful
  45. as well.
  46.  
  47. Objects
  48. -------
  49.  
  50. Each Bento object has a persistent ID which is unique within its
  51. container.  Other than that, objects don╒t really exist independent of
  52. their properties.  An object contains no information beyond what is
  53. stored in its properties.
  54.  
  55. Properties
  56. ----------
  57.  
  58. A property defines a role for a value.  Properties are like field names
  59. in a record, except they can be added freely to an object, and their
  60. names are globally unique, so that applications can understand them.
  61. Properties are distinct from types.
  62.  
  63. For example, a string might be used for the name of an object, the
  64. author of the object, a comment, etc  These different uses would be
  65. indicated by different properties.
  66.  
  67. Conversely, the string might be in ASCII, Unicode, or some other
  68. international string representation.  These different formats would not
  69. be indicated by the property, but by the type (see below).
  70.  
  71. Values
  72. ------
  73.  
  74. Values are where the data is actually stored.  The data for a value can
  75. be stored anywhere in a container.  In fact, it can be broken up into
  76. any number of separate pieces, and the pieces can be stored anywhere.
  77. (See the discussion of continued values below.)
  78.  
  79. Values  may range in size from 0  bytes to 2^32 bytes (if you have that
  80. much storage).   Bento is optimized for ╥large╙ values, such as streams
  81. of formatted text, graphics metafiles, etc.
  82.  
  83. Types
  84. -----
  85.  
  86. The type of a value describes the format of that value.  Types record
  87. the structure of a value, whether it is  compressed, what its byte
  88. ordering is, etc.
  89.  
  90. To continue the example above, the type of a string value would indicate
  91. the alphabet, whether it was null terminated, and possibly other
  92. information (such as the intended language).  It might also indicate
  93. that the string was stored in a compressed form, and would indicate the
  94. compression technique, and the dictionary if one was required.  If the
  95. string used multi-byte characters, and the byte-ordering was not defined
  96. by the alphabet, the type would indicate the byte-ordering within the
  97. characters.
  98.  
  99. Secondary Entities
  100. ==================
  101.  
  102. There are several additional entities that play supporting roles in the
  103. Bento design.  These entities are important to fully understand how
  104. Bento works, but they do not signficantly change the picture given
  105. above.
  106.  
  107. Type and property descriptions
  108. ------------------------------
  109.  
  110. The property associated with a value is a reference  to a property
  111. description.  Similarly, the type is a reference to a type description.
  112. These type and property descriptions are objects, and their IDs are
  113. drawn from the same name-space as other object IDs.
  114.  
  115. Many type and property descriptions will simply consist of the globally
  116. unique name of the type or property.  To continue the example above
  117. further, the type of a string of 7-bit ASCII, not compressed or
  118. otherwise transformed, would simply be described by a globally unique
  119. name.  This would allow applications to recognize the type.
  120.  
  121. Reference to type and property descriptions are distinct from references
  122. to ordinary objects in the API to allow language type checking to catch
  123. errors in the manipulation of type and property references.  However,
  124. type and property references can still be passed to the object and value
  125. operations, so that value manipulation can be done on types and
  126. properties as well as normal objects.
  127.  
  128. Globally unique names
  129. ---------------------
  130.  
  131. Globally unique names are simply strings that follow certain
  132. conventions.  They begin with a registered naming authority, and have
  133. additional segments, each of which is unique in the context of the
  134. previous segments.
  135.  
  136. The most common globally unique names will be generated by system
  137. vendors or commercial application developers, and may be registered.
  138. However, many names will be generated by local developers to record
  139. their local types and properties.  To meet this need, the naming rules
  140. allow for local creation of unregistered unique names.
  141.  
  142. IDs and accessors
  143. -----------------
  144.  
  145. Each object is assigned a persistent ID that is unique within the
  146. container in which the object is created.  These IDs are never reused
  147. once they have been assigned, so even if an object is deleted, its ID
  148. will never be reassigned.
  149.  
  150. In the API types, properties, and objects can be referred to using their
  151. IDs, but for convenience, they are usually referred to using accessors
  152. provided by the API.  Since  IDs are only unique within a container,
  153. they must always be used with an explicit container, while the accessors
  154. include an implicit container reference.
  155.  
  156. Accessors are used to refer to containers and values.  Accessors  are
  157. only unique within a given session, so they cannot be stored in values
  158. as reference to other values.  IDs must always be used for persistent
  159. references.
  160.  
  161. Dynamic values
  162. ---------------
  163.  
  164. Bento needs to support external references from one container to
  165. another, or to other entities such as files, etc.  It does this through
  166. dynamic values.  These are values whose types indicate that they contain
  167. a description of the real value, rather than the actual data.
  168.  
  169. Except for the indirect characteristic of their types, indirect values are created and stored exactly like normal values.  However, when they are accessed, a handler is called to resolve the description to an actual value.
  170.  
  171. Value segments
  172. --------------
  173.  
  174. To support interleaving and other uses that require breaking a value up
  175. into pieces, Bento allows a value to consist of multiple segments stored
  176. at different locations in the container.  These segments are not visible
  177. at the API, which glues them together to create a single stream of
  178. bytes.
  179.  
  180. Handlers
  181. ========
  182.  
  183. Handlers are pieces of code called by the Bento library to do specific
  184. jobs, but not part of the Bento library as such.  Functions are put into
  185. handlers rather than the library to make the library more portable, and
  186. also to provide a standard way to extend the library.
  187.  
  188. Handlers come in two main forms: container handlers and value handlers.
  189. In addition, the API uses special handlers for reporting errors and
  190. allocating and deallocating memory.
  191.  
  192. Actual I/O to containers is always done using container handlers, to
  193. provide platform independence.  Container handlers provide stream I/O,
  194. plus a few special interfaces for reading and writing specific parts of
  195. the container format.
  196.  
  197. The many different types of containers mentioned in the first section
  198. are not actually implemented in the Bento library.  Instead, the library
  199. simply calls different types of  handlers, all of which provide the same
  200. interface.  These handlers map I/O to the underlying storage in a way
  201. that depends on the container type.
  202.  
  203. Value handlers are only required for values that require special support
  204. for access.  For example, a value that is compressed on writing and
  205. decompressed on reading would need a special handler.  Value handlers
  206. have the option of providing specialized operations to manipulate the
  207. value, either instead of or in addition to the standard value
  208. operations.
  209.