AlStatusHandler
 
 
 

Augments the status codes of the Alias API.

Synopsis

#include <AlStatusHandler.h>
class AlStatusHandler
static const char* 	statusErrorString();
static int 	statusErrorNumber();	
static void 	clear();
static statusCode 	installHandler( \
		void (*)(int, const char *) );
static statusCode 	removeHandler( 
		void (*)(int, const char *) );

Description

There are methods in the Alias API where a standard error code is used in more than one method return statement. The return value is essentially overloaded and it becomes difficult for the API developer to figure out which error condition was actually hit. This class will assist the API developer by providing a text string message whenever the overloaded return value condition is hit. This class supports retrieving the current status error string and number. Clearing the state of the status handler and installing and removing callbacks which listen to changes of state in the status handler.

Notes:

1. The AlStatusHandler::clear() method is not called by the API. It is up to the programmer to ensure that the status handler has been cleared.

2. The text messages will only be set in cases where the return value is overloaded. Therefore it is possible for an API method to fail without any change to the state of the status handler.

3. The Alias API contains many internal checks that could cause a method to return with a failure condition. In this case, an "internal error" will be returned by the status handler. This condition should be rare.

4. The AlStatusHandler::clear() method does not generate a call to a status handler callback. Therefore it can be used in a status handler callback without running into recursion problems.

5. The overloaded errors handled by this class are sFailure, sInvalidArgument and sInvalidObject.

void AlStatusHandler::clear()

Description

Clears the current state of the status handler. It is possible to call this method from within an AlStatusHandler callback since the ::clear() method does not generate another call to the status handler callback.

const char* AlStatusHandler::statusErrorString()

Description

Returns the error string associated with the current state of the status handler.

int AlStatusHandler::statusErrorNumber()

Description

Returns the error number associated with the current state of the status handler.

statusCode AlStatusHandler::installHandler( void (*function)(int, const char *) )

Description

This method installs a callback handler that will be invoked when the status handler is set.

Arguments

< function - pointer to a void(int, const char* ) function

Return Codes

sSuccess - the method succeeded

sInvalidObject - the method failed to install the handler

sInvalidArgument - function parameter was NULL

statusCode AlStatusHandler::removeHandler( void (*function)(int, const char *) )

Description

This method removes a callback handler that was listening to status handler messages.

Arguments

< function - pointer to a void( int, const char * ) function

Return Codes

sSuccess - the method succeeded

sFailure - the handler failed to be removed

sInvalidArgument - function parameter was NULL