Introduction to the Frustrum   

Chapters File Handling >>>

Contents

[back to top]


1.1 Introduction

The Frustrum is a set of functions which must be written by the application programmer. They are called by Parasolid to perform the following tasks:

Detailed information on the Frustrum's file handling functionality is in Chapter 2, "File Handling".

The standard format of file headers which the Frustrum should read and write is described in Chapter 3, "File Header Structure".

This chapter introduces the Frustrum functions; their interfaces are defined in Appendix A, "Frustrum Functions".

 

Note: You are strongly advised to look at the Getting Started With Parasolid manual before looking at the information in this manual.

[back to top]

1.1.1 Dummy frustrum

The code for a dummy frustrum is supplied with the release in the file frustrum.c . This example gives a feel for how a Frustrum might be implemented, although the complexity of a Frustrum is dependent on its application. The example Frustrum has three purposes:

 

Note: This frustrum contains the bare minimum required to be used, in order for it to remain clear and platform independent. Normally a Frustrum is written with a particular application in mind, and may make use of system calls rather than the C run-time library for enhanced performance.

To further help you write your own frustrum, the Parasolid Example Application also contains source code for a frustrum implementation on Windows NT. See the Getting Started With Parasolid manual for more details.

[back to top]


1.2 Summary of functions

This table summarizes the frustrum functions which you must provide.

 

Function

Description

FSTART

 

 

Initialize the frustrum

these functions require the Frustrum to be initialized:

 

FMALLO

 

Allocate a contiguous region of virtual memory

FMFREE

 

Free a region of virtual memory (from FMALLO)

FFOPRD

 

Open most guises of frustrum file for reading

FFOPWR

 

Open most guises of frustrum file for writing

UCOPRD

 

Open most guises of frustrum file for reading. The file has a Unicode filename.

UCOPWR

 

Open most guises of frustrum file for writing. The file has a Unicode filename.

these functions require the file to be opened:

 

FFREAD

Read from a file where permitted

FFWRIT

Write to a file where permitted

FFCLOS

Close a Frustrum file

FABORT

 

Tidy up/longjump following aborted operation

FTMKEY

 

Key name server required by TESTFR

FSTOP

 

 

Close down the frustrum

 

Note: If your application supports 16-bit Unicode filenames, then you must provide UCOPRD and UCOPWR functions in your frustrum in addition to FFOPRD and FFOPWR (which are still required for schemas and journals). If your application does not support Unicode filenames, then you must provide FFOPRD and FFOPWR functions. See Section 2.2, "Unicode filenames", for more information.

[back to top]

1.2.1 Initialization

The Frustrum is initialized by calling FSTART and is closed down by FSTOP.

The former is called by PK_SESSION_start and the latter by PK_SESSION_stop. Parasolid does not call any other Frustrum functions before the Frustrum has been initialized nor after it has been closed.

 

Note: The calls made by Parasolid to the start and stop functions can be nested within each other (e.g. FSTART, FSTART, FMALLO, FMFREE, FSTOP, FSTOP). Only the outermost calls are significant; the innermost calls must be ignored.

FSTART and FSTOP are assumed never to fail.

[back to top]

1.2.2 Memory management

Parasolid needs to be able to allocate and free virtual memory into which to put its model data. The Frustrum interface to this facility is provided by the FMALLO and FMFREE functions, and is similar to the C library functions malloc and free .

The amount of virtual memory that Parasolid requests depends on the complexity of the modeling operation. By default, the minimum is about 1/8 Mbyte. You can set and enquire the current value of this minimum block of memory using the functions PK_MEMORY_set_block_size and PK_MEMORY_ask_block_size, respectively. For complex cases, or those which require a lot of data storage, Parasolid may request more.

[back to top]


1.3 Abort recovery

Following an interrupt, the application has the option of calling KABORT before allowing Parasolid to continue processing. This causes it to abort the operation which was in progress. The call to KABORT would be made by an interrupt handler provided by the application.

Following such an abort, Parasolid normally returns through the PK in the normal way, giving error PK_ERROR_aborted. Before returning, Parasolid makes a call to Frustrum function FABORT, which gives the application developer an opportunity to do any generic tidying up and/or to do a long-jump to some special recovery-point within his code.

For further information on abort recovery, see Chapter 58, "Error Handling", of the Parasolid Functional Description manual.

[back to top]


1.4 Frustrum errors

If a Frustrum function detects an error, it returns an error code in its final argument ( ifail ), which otherwise is the code FR_no_errors. The error codes are divided into three categories - prediction, exception and illegal call.

[back to top]

1.4.1 Prediction errors

This category contains those errors which can be expected to occur during the ordinary course of a program run. Parasolid looks for this type of error return code explicitly and takes the appropriate action.

For example, the implementation must always check the key name arguments which are passed to FFOPRD and FFOPWR and the file size argument which is passed to FFOPRB, in case Parasolid is being run with argument validation having been switched off by PK_SESSION_set_check_arguments. These types of errors can be said to be predictable.

The range of prediction error codes which can be returned from a given function are documented as end of line comments to the ifail argument.

[back to top]

1.4.2 Exception errors

This category contains codes for unpredictable but plausible errors.

Where some particular remedial action is possible, Parasolid traps these cases explicitly. If no specific course of action is appropriate, Parasolid traps and handles such cases by a default action.

For example, some PK functions need to take special action in the event of running out of disk space whereas others handle such cases by a catch all error trap.

Exception codes are also added as end of line comments to the ifail argument in the documentation of each Frustrum function.

[back to top]

1.4.3 Illegal call errors

This category is used to report an erroneous call being made to a Frustrum function, such as trying to write to a file strid which has not been opened or to denote that an error has occurred in the Frustrum implementation.

The Frustrum should normally report illegal call errors by outputting a message describing what went wrong, before returning the generic code FR_unspecified.

This code should only be returned when an error has been detected; it should not be set in the normal course of events. For this reason, the ifail code FR_unspecified is not used in the documentation for the Frustrum functions.

If an error occurs which is not the result of an erroneous call being made to the Frustrum or of an internal error in the Frustrum code, the ifail should be set to one the mnemonic codes in the documentation which best describes the result.

Note that the code FR_unspecified is not trapped explicitly by Parasolid, so the resulting ifail code returned from the KI may be misleading.

[back to top]


1.5 Validation tests

The test function TESTFR is supplied with Parasolid to enable the customer to check that the behavior of his implementation of the Frustrum is consistent with the requirements of Parasolid and of file portability.

It is strongly recommended that TESTFR be linked and run every time the Frustrum is changed, and for every new version of Parasolid; Frustrum faults can cause obscure and serious problems in Parasolid.

Although the specification for TESTFR is included with the Frustrum documentation, TESTFR is not itself part of the Frustrum, and as such is not supplied by the customer, but is supplied with Parasolid.

However, the TESTFR function requires a key name server FTMKEY to be provided by the customer implementation, which returns sample names to be used as arguments in the test calls made to FFOPRD and FFOPWR. The key name server is not otherwise used by Parasolid.

[back to top]

1.5.1 TESTFR - invokes the verification tests for the frustrum

 

void TESTFR
(
                            /* received arguments */
int *number,       /* test number */
int *level,        /* trace level */
                            /* returned arguments */
int *code          /* completion code */
)

 

Argument

Synopsis

Values

Description

number

test number

0

run all tests

n

run test n (n>=1)

level

trace level

0

no tracing

1

number, purpose, result

2

+ receive/return args

3

+ diagnostics

4

+ debug trace

code

completion code

0

setup_error

1

test_success

2

test_failure

3

test_omitted

4

test_exceeded

5

test_warning

This function invokes a set of verification tests for customer implementations of the Frustrum. These are designed to confirm that the behavior of the Frustrum (with respect to file handling and memory management) is consistent with the requirements of Parasolid and of file portability.

The tests are not foolproof, and in particular, cannot detect cases where the Frustrum writes/reads files in a way not compatible with the C run time library. Nonetheless, the tests can detect many Frustrum faults which might otherwise cause obscure and catastrophic problems in Parasolid. It is therefore strongly recommended that a customer runs the tests after any modification to his Frustrum, and after receiving any new version of Parasolid.

In order to run the tests, the customer must provide a simple driver program to call TESTFR, which he then links with TESTFR and with his Frustrum. Once a test image has been linked, the following test strategy is recommended:

The association between a particular check and a test number will not necessarily be maintained between releases of Parasolid and/or releases of the Frustrum interface specification.

 

[back to top]

Chapters File Handling >>>