gtpc2me0C/C++ Language Support User's Guide

TO2_getCollectionAccessMode -- Retrieve the Access Mode of a Collection

This function returns the current access mode of a collection.

Format

#include <c$to2.h>
TO2_COLLECT_MODE TO2_getCollectionAccessMode (const TO2_PID_PTR pid_ptr;
                                                    TO2_ENV_PTR env_ptr);

pid_ptr
A pointer to the persistent identifier (PID) of the collection whose access mode value will be retrieved.

env_ptr
The pointer to the environment as returned by the TO2_createEnv function.

Normal Return

The normal return is an enumerated value of the type TO2_COLLECT_MODE. For more information, see TO2_setCollectionAccessMode -- Set the Access Mode of a Collection.

Error Return

An error return is indicated by a zero. When zero is returned, use the TO2_getErrorCode function to determine the specific error code. For more information, see Error Handling.

The following error codes are common for this function:

TO2_ERROR_DELETED_PID

TO2_ERROR_NOT_INIT

TO2_ERROR_PID

TO2_ERROR_ZERO_PID

Programming Considerations

TPFCS defaults the access mode of a collection to TO2_COLLECT_MODE_NORMAL. To change the access mode of a collection, use the TO2_setCollectionAccessMode function.

Examples

The following example tests to see if a collection can be deleted and returns a TRUE (1) value if it can be deleted or a FALSE (0) value if it cannot be deleted.

#include <c$to2.h>             /* Needed for TO2 API functions    */
 
long   deleteAllowed(const TO2_PID_PTR   pid_ptr,
                           TO2_ENV_PTR   env_ptr);
 

  ·
  ·
  ·
/* */ /* retrieve the collections access mode and test it for */ /* deletion allowed. */ /* */ long deleteAllowed(const TO2_PID_PTR pid_ptr, TO2_ENV_PTR env_ptr) { TO2_COLLECT_MODE accessMode, if ((accessMode = TO2_getCollectionAccessMode(pid_ptr, env_ptr)) == TO2_ERROR) { process_error(env_ptr); return -1; } else if ((accessMode == TO2_COLLECT_MODE_NODELETE) || (accessMode == TO2_COLLECT_MODE_READONLY)) return 0; /* collection cannot be deleted. */ else return 1; /* collection can be deleted. */ }

Related Information