Important: The information in this document is obsolete and should not be used for new development.
Chapter 3 -
This chapter describes technologies that are widely used by the MacApp class library and by most MacApp applications. The following topics are covered:
Core Technologies
- Dependencies. MacApp implements a simple yet powerful system for managing dependency relationships between objects. It allows an object to be registered as a dependent of another object and to be notified of changes in the object it depends on.
- Streams. MacApp provides stream classes that facilitate the transfer of bytes to and from files, memory, and other destinations.
- Failure handling. MacApp's failure-handling mechanism provides an efficient way to signal errors and to clean up after an error occurs.
- Lists and iterators. MacApp provides classes for efficient storage and retrieval of items in sorted lists. Iterator classes process the items stored in lists. Strings can be stored in sorted lists with associated keys.
- Memory management. MacApp's memory management
- attempts to ensure that there is always enough memory available to perform a critical operation, such as saving data or quitting the application
- uses its own object heap for efficient object allocation
- Segmentation. MacApp provides an efficient mechanism for managing an application's code segments (for segmented 68K applications only).
- Trap patching. MacApp supplies a general-purpose mechanism for patching Toolbox traps that handles differences between patches for 68K-based and Power Macintosh computers.
Chapter Contents
- Dependencies
- Basic Operations on Dependencies
- Storing Dependency Relationships
- Establishing and Removing Dependencies
- Iterating Over Dependents and Notifiers
- Change Notification and Command Objects
- Updating Algorithms
- TSimpleDependencySpace
- TStandardDependencySpace
- Marking Objects
- Dependency Space Data Structures
- Streams
- Streaming Object Data
- Examples of Using Streams in MacApp
- Advantages of Using Streams
- Disadvantages of Using Streams
- File Formats
- Speed and Data Access
- Ease of Modification
- Failure Handling
- The Failure Routine
- The FailInfo Class
- The Try Macro
- Saving and Restoring the Machine State
- Calling Success to Remove a Failure Handler From the List
- The MAVolatile and MAVolatileInit Macros
- Failure Handling Embedded in Objects
- Lists and Iteration
- Dynamic Memory Allocation
- Permanent and Temporary Memory
- Determining the Size of Memory Reserves
- The Grow-Zone Function
- Grow-Zone Hooks
- Purging Algorithms
- Initializing MacApp's Memory Management
- Initializing MacApp's Segment Management
- Allocating Objects
- Creating an Object in the Object Heap
- Freeing an Object in the Object Heap
- Recovering Freed Memory
- Replacing MacApp's Global New and Delete Operators
- Segment Management (68K-Based Applications Only)
- The Power Macintosh Doesn't Require Segmentation
- Segmenting a 68K Macintosh Application
- Segmentation Strategies
- Using ModelFar Addressing to Create Large Segments
- Avoiding Jump-Table Limits
- Creating Segments of Minimal Size
- Putting Related Code in the Same Segment
- Creating Segments
- Remapping Segment Names
- Creating a Link Map
- The 'seg!' Resource
- The 'res!' Resource
- Trap Patching
- Patching Traps in Your Application
- MacApp's Patching for Segmentation
- Patching for Nonstandard Builds
- Patching for a Standard Build