SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Protected Member Functions
RWDBDatabaseCallbackImp Class Reference

Abstract base class from which all custom database callbacks derive. More...

#include <rw/db/dbasecbi.h>

Inherits RWDBReference.

Inherited by RWDBDatabaseDefaultCallbackImp.

Public Member Functions

virtual void connParams (const RWCString &serverName, const RWCString &userName, RWCString &password, const RWCString &databaseName, const RWCString &propertyString)
 
RWDBEnvironmentHandleenvironmentHandle () const
 
virtual void postEnvAllocate ()
 
virtual void preEnvAllocate ()
 
virtual void preEnvDestroy ()
 
virtual RWDBConnCallback produceConnCallback ()
 
RWCString serverType () const
 
void setError (RWDBStatus::ErrorCode code, const RWCString &message, const RWCString &vendorMessage1=RWCString(), const RWCString &vendorMessage2=RWCString(), long vendorError1=0, long vendorError2=0, bool isTerminal=false, bool invokeErrorHandler=true, bool invalidateDatabase=false)
 
RWDBStatus status () const
 

Protected Member Functions

 RWDBDatabaseCallbackImp ()
 

Detailed Description

RWDBDatabaseCallbackImp is a reference-counted implementation class that is the abstract base class for implementing database callbacks. Derive from this class to implement your custom database callbacks.

This class provides three database callback methods: preEnvAllocate(), postEnvAllocate() and preEnvDestroy(). It also provides a connection callback producer method produceConnCallback(). Please refer to the DB Interface Module User's Guide and applicable DB Access Module User's Guide for more information on these methods. You need to redefine the methods to implement database callbacks and/or produce connection callback instances.

Synopsis
#include <rw/db/dbasecbi.h>
class MyDBaseCallbackImp : public RWDBDatabaseCallbackImp {
public:
// PostEnvAllocate callback
virtual void postEnvAllocate();
// Connection callback producer
};
RWDBDatabase dBase =
RWDBManager::database("accessLib", "Servername",
"Username", "Password",
"DatabaseName",
RWDBDATABASECALLBACK(MyDBaseCallbackImp) );

Constructor & Destructor Documentation

RWDBDatabaseCallbackImp::RWDBDatabaseCallbackImp ( )
inlineprotected

The default protected constructor.

Member Function Documentation

virtual void RWDBDatabaseCallbackImp::connParams ( const RWCString serverName,
const RWCString userName,
RWCString password,
const RWCString databaseName,
const RWCString propertyString 
)
virtual

This callback is invoked just before opening a connection to the database. It passes to the callback function the parameters used to establish a database connection. All the parameters, except password, are passed as const and so cannot be modified. The password set during this call will be used to open a connection to the database. To implement connParams() callback, derive from this class and redefine this method.

RWDBEnvironmentHandle* RWDBDatabaseCallbackImp::environmentHandle ( ) const

Returns a pointer to the RWDBEnvironmentHandle of the RWDBDatabase object to which self is associated. If self is not associated with any RWDBDatabase object, returns 0.

virtual void RWDBDatabaseCallbackImp::postEnvAllocate ( )
virtual

This callback is invoked after the allocation of database-specific-environment/context handle. It is defined as a no-op. To implement postEnvAllocate callback, derive from this class and redefine this method.

virtual void RWDBDatabaseCallbackImp::preEnvAllocate ( )
virtual

This callback is invoked just before the allocation of database-specific environment/context handle. It is defined as a no-op. To implement preEnvAllocate callback, derive from this class and redefine this method.

virtual void RWDBDatabaseCallbackImp::preEnvDestroy ( )
virtual

This callback is invoked just before the deallocation of environment/context handle. It is defined as a no-op. To implement preEnvDestroy callback, derive from this class and redefine this method. This callback is typically called from the destructor of the RWDBDatabase object and, hence, applications should refrain from throwing an exception.

virtual RWDBConnCallback RWDBDatabaseCallbackImp::produceConnCallback ( )
virtual

This method must produce a new instance of a connection callback implementation.

An RWDBDatabase object invokes this method when producing a new RWDBConnection object. The RWDBConnCallback object produced by this method is then associated with the new RWDBConnection.

Note that this method produces an uninitialized connection callback object with all connection callbacks as no-ops. To produce custom connection callbacks, derive from this class and redefine this method to produce new instances of connection callbacks using the macro RWDBCONNCALLBACK(CALLBACK).

For example:

MyDBaseCallbackImp::produceConnCallback()
{
return RWDBCONNCALLBACK(MyConnCallbackImp);
}
RWCString RWDBDatabaseCallbackImp::serverType ( ) const

Returns the serverType of the RWDBDatabase object to which self is associated. If self is not associated with any RWDBDatabase object, returns an empty string.

void RWDBDatabaseCallbackImp::setError ( RWDBStatus::ErrorCode  code,
const RWCString message,
const RWCString vendorMessage1 = RWCString(),
const RWCString vendorMessage2 = RWCString(),
long  vendorError1 = 0,
long  vendorError2 = 0,
bool  isTerminal = false,
bool  invokeErrorHandler = true,
bool  invalidateDatabase = false 
)

Sets an error on self. Optionally, invalidates the RWDBDatabase object to which self is associated.

Parameters
codeRWDBStatus attribute used to set the error on self's RWDBStatus object.
messageRWDBStatus attribute used to set the error on self's RWDBStatus object.
vendorMessage1RWDBStatus attribute used to set the error on self's RWDBStatus object.
vendorMessage2RWDBStatus attribute used to set the error on self's RWDBStatus object.
vendorError1RWDBStatus attribute used to set the error on self's RWDBStatus object.
vendorError2RWDBStatus attribute used to set the error on self's RWDBStatus object.
isTerminalRWDBStatus attribute used to set the error on self's RWDBStatus object.
invokeErrorHandlerIndicates if the associated error handler should be invoked.
invalidateDatabaseIndicates if the RWDBDatabase object to which self is associated should be invalidated. If invalidated, the RWDBDatabase object has an error code of RWDBStatus::applicationError.
RWDBStatus RWDBDatabaseCallbackImp::status ( ) const
inline

Returns the current status of self.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.