HP LoadRunner Protocol SDK Test Run API Reference  12.02
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CApiFunction Class Referenceabstract

The base class for handling API execution. More...

#include <ApiFunctions.h>

Inheritance diagram for CApiFunction:
CApiFunctionWithNamedArguments

Public Member Functions

 CApiFunction (const char *mDisplayName="", int mIconId=-1)
 Instantiates a CApiFunction with icon and display name. More...
 
virtual ~CApiFunction ()
 Destructor.
 
int Run (const char *mStepName, va_list mVaList=0)
 Executes this API function for one step. More...
 
void WastedTime (long mMilliSeconds)
 Adds to the wasted time of all open transactions Every call to this method increases the wasted time of all open transactions, including the automatic transaction per step, if any. More...
 
void ThinkTime (long mSeconds)
 Adds to the think time of all open transactions. More...
 
void SetResultMessage (int mMessageID,...)
 Sets the message for the test result report. More...
 

Protected Member Functions

virtual void Init ()=0
 Initializations for this API function. More...
 
virtual void HandleArguments (va_list mVaList)
 Validates arguments and checks for completeness. More...
 
virtual void Invoke ()=0
 Performs the logic of the API function.
 
virtual void Terminate ()=0
 Normal termination of the API function. More...
 
virtual void Abort ()=0
 Halts the API function when an unrecoverable exception is raised. More...
 

Protected Attributes

char * m_stepName
 The display name for the step in which this API function is called.
 
char * m_displayName
 The API function display name used in log messages and in the result report.
 
int m_iconId
 The API function icon id. The icon is used in the test result report.
 
char * m_fullName
 The name used in log messages.
 

Detailed Description

The base class for handling API execution.

Class CApiFunction is the base class for API functions. Create a class derived from CApiFunction to implement each API function with positional arguments. For example,

PROTOCOL_REPLAY_DECL_C_API int
my_function(const char * stepName, const char *hostName, int Retries);

You can add data members for storing the step data to the derived class, and add the function-specific arguments to the constructor. The scope of this data is one step, that is, one invocation of this API function from a script.

Note
To implement API functions declared with named arguments ("key=value"), create a class derived from CApiFunctionWithNamedArguments. To implement API functions declared with positional arguments, use CApiFunction directly, adding the function-specific arguments to the constructor.

Constructor & Destructor Documentation

CApiFunction::CApiFunction ( const char *  mDisplayName = "",
int  mIconId = -1 
)

Instantiates a CApiFunction with icon and display name.

On UNIX platforms, the icon is not supported; pass the default ID, -1.

Parameters
mDisplayNameThe API function display name used in log messages and in the result report
mIconIdThe API function icon ID from resource.h. The icon is used in the test result report

Member Function Documentation

virtual void CApiFunction::Abort ( )
protectedpure virtual

Halts the API function when an unrecoverable exception is raised.

Implement Abort to perform any necessary clean-up such as freeing resources allocated during the API function call, sending log messages, and so on.

virtual void CApiFunction::HandleArguments ( va_list  mVaList)
protectedvirtual

Validates arguments and checks for completeness.

Do not implement this method for API functions declared with named arguments. Implementation is optional for API functions declared with positional arguments.

Parameters
mVaListThe list of arguments to be validated

Reimplemented in CApiFunctionWithNamedArguments.

virtual void CApiFunction::Init ( )
protectedpure virtual

Initializations for this API function.

Set up to invoke the function by allocating resources and so on.

int CApiFunction::Run ( const char *  mStepName,
va_list  mVaList = 0 
)

Executes this API function for one step.

For an API function declared with positional arguments, the default value for mVaList is used. The actual arguments are passed in the constructor.

Returns
LR_PASS or LR_FAIL
Parameters
mStepNamestep name
mVaListvariable-length argument list
void CApiFunction::SetResultMessage ( int  mMessageID,
  ... 
)

Sets the message for the test result report.

The message is displayed in the details column of the report. If this method is not called, a default message is displayed. The default message may be the last error or warning message. Pass the parameters of the message in the variable-length argument list.

Parameters
mMessageIDmessage id in resource file
virtual void CApiFunction::Terminate ( )
protectedpure virtual

Normal termination of the API function.

Release resources, write log messages, and so on.

void CApiFunction::ThinkTime ( long  mSeconds)

Adds to the think time of all open transactions.

Every call to this method increases the think time of all open transactions, including the automatic transaction per step, if any.

Exceptions
SDK_INTERNAL_ERRORFailed to report think time
Parameters
mSecondsthink time in seconds
void CApiFunction::WastedTime ( long  mMilliSeconds)

Adds to the wasted time of all open transactions Every call to this method increases the wasted time of all open transactions, including the automatic transaction per step, if any.

Exceptions
SDK_INTERNAL_ERRORFailed to report wasted time
Parameters
mMilliSecondswasted time in milliseconds

The documentation for this class was generated from the following file:


Send documentation feedback to HP.


© 1995-2015 Hewlett-Packard Development Company, L.P.