A Resourceful c-treeACE Feature
Resources play an important role in the architecture of many advanced c-treeACE features. Some of these include:
- c-treeACE SQL
- ODBC Drivers
- Heterogeneous Networking
- File Security Features
Resources are a c-treeACE feature that allow you to handle auxiliary information in data files, without requiring special record handling on the part of the developer. Using resources offer benefits to the developer that can prove useful in many situations:
- Portability
- No custom external file handling
- No exception handling of records
- Protection of your data with c-treeACE integrity
Resource Fast Facts
- Resources are stored in the data file as variable length records, regardless if the file is fixed or variable length.
- Resources are stored as "chains", whereby the list of resources can be quickly traversed.
- c-treeACE expects locks held on resource entries will only be held for very short intervals. Avoid Resource updates as part of long transactions, as the locks will be held until the transaction commits or aborts.
- Resources are best for storing data that change relatively infrequently. Rapidly changing values, such as serial counters, are not good candidates for maintaining as c-treeACE data resources, as your performance may be diminished.
- Enabling Resources precludes processing a data file in reverse physical order with LastRecord(), PreviousRecord(). Complete reverse traversal capability is supported using an index.
- IFILs and DODAs are nothing more than specialized FairCom Resources.

FairCom Resources
FairCom maintains several resources that provided extended functionality for many c-treeACE features. These resources include:
- IFILs - The Incremental File Structure. This structure relates the data and index file associations for complete ISAM functionality.
- DODAs - The "Data Object Definition Array" (DODA) provides schema information over your data allowing field level access through SQL and the c-tree Plus ODBC Driver. Through this information, c-treeACE can also take advantage of properties of your data at the field level, such as automatic byte swapping in heterogeneous systems.
- Padding/Delimiter - These values are the characters stored at the table level to use as padding and string delimiters.
- File Security - A coarse file security password can be assigned to a data file and the attributes of that security are stored as a resource.
- Alternate Collation Sequences - When working with character sets or data that require sorting parameters other than typical ASCII, this resource makes this capability configurable on a file by file basis.
Custom Resources
c-treeACE provides extensive flexibility to developers. Use resources to store you own custom information as part of the data file. Examples include:
- Application Configurations - Let c-treeACE maintain your configuration data for you without having to develop custom file formats and maintain application portability without messy Windows Registry entries.
- Versioning - Maintain version in your data file for easy application upgrades.
- Application State information - Windows screen positions, and other user preferences are ideal candidates for maintaining as c-treeACE resource records.
Custom resources are easily added to any data file. Only a handful of c-tree functions are required to create and access custom resource data. For ISAM applications the following c-treeACE API calls are used:
- AddCtResource() - Adds a resource to a file.
- UpdateCtResource() - Updates a resource in a file, resizing it if necessary.
- DeleteCtResource() - Deletes a resource from a file.
- GetCtResource() - Retrieves a resource from a file given a name or number.
- EnableCtResource() - Enabled resources in files created without resources.
c-treeACE also offers support for resources at the c-treeDB C and C++ APIs as well as .NET support.
Resources are composed of four key elements.
- Type - Related resources are maintained as groups.
- Number - A custom numbering maintained within a type.
- Name - Assigned name to the resource.
- Information - The actual data contained in the resource.
Example
The following .NET C# example demonstrates a common use of custom resources. This demonstration adds a resource to a file for an imaginary application to maintain windows screen coordinates and a user name between application runs. This C# code example takes advantage of .NET object serialization to store a byte array directly into the resource, and then reconstruct the object upon resource retrieval.
You can copy in the source of this example into your C# Tutorial 1 and use our existing Visual Studio projects and solutions found in your c-treeACE installation to examine and run this example.
C# Resource Example
Running this example, you should see results similar to the following:
This resource contains
======================
255
255
300
300
JOEBOB
======================
Maximize your productivity today and let c-treeACE resource handling help store all of your important application data safely and efficiently through the integrity of c-treeACE data files.
See Also
c-treeACE Resources
c-treeACE IFIL Structures
c-treeACE Data Schemas
|