Class Variable

VarSpace
ClassModule Variable

Storage wrapper for variants that provides tracing and readonly protection.
Developer Documentation
C:\AAA-Exchage\DocuPro6\VarSpace\Variable.cls

Description:
This class provides a useful wrapper around Visual Basic's Variant data type. Using this class, variables may be created with a ReadOnly property and provide for Read/Write/Destroy tracing capabilities.

Author:
Andrew F. Friedl

Copyright:
1997.04.10, BlackBox Software & Consulting


Variables
Public
Name As String
ReadOnly As Boolean
Private
m_Value As Variant
m_Traces As Collection
m_IsTracing As Boolean
mTraceID As Long

General Methods
object members
Value Public Property Let Value(Data As Variant)
        Sets the value of the Variable.
Value Public Property Set Value(Data As Variant)
        Sets the value of the Variable.
Value Public Property Get Value() As Variant
        Retrieves the value of the Variable.
TraceID Private Property Get TraceID() As Long
SetValue Public Function SetValue(Data As Variant) As Boolean
        Sets the current value of the Variable.
AddTrace Friend Function AddTrace() As VarTrace
        Adds a trace to the variable.
IsAnObject Friend Function IsAnObject() As Boolean
UnsetValue Friend Sub UnsetValue()
        Informs the Variable it is about to be deleted.
GetValue Public Sub GetValue(Data As Variant)
        Retrieves the current value of the Variable.
EndTrace Friend Sub EndTrace(Trace As VarTrace)
        Removes a trace from the trace list.
EndAllTraces Friend Sub EndAllTraces()
        Terminates all tracing on this variable.
TraceRead Private Sub TraceRead()
        Initiates a TraceRead event all traces within this variable.
TraceWrite Private Sub TraceWrite(Data)
        Initiates a TraceWrite event all traces within this variable.
TraceDestroy Private Sub TraceDestroy()
        Initiates a TraceDestroy event all traces within this variable.
Class_Initialize Private Sub Class_Initialize()

General Methods - Detail
object members

Value

Sets the value of the Variable.

Description:
This property attempts to set the value of the Variable. The value may not be an object type. This function will generate an error if the Variable has been marked ReadOnly. If the variable has traces assigned, they will be invoked.

Definition:
Public Property Let Value(Data As Variant)

Parameters:
Data The new value of the Variable.


Value

Sets the value of the Variable.

Description:
This property attempts to set the value of the Variable. The value must be an object type. This function will generate an error if the Variable has been marked ReadOnly. If the variable has traces assigned, they will be invoked.

Definition:
Public Property Set Value(Data As Variant)

Parameters:
Data The new value of the Variable.


Value

Retrieves the value of the Variable.

Description:
This property retrieves the current value of the variable. The value is placed in the Value parameter. If the value of this variable is an alias, or another variable, then the value of that variable is returned.

Definition:
Public Property Get Value() As Variant

Returns:
The current value of the Variable.


TraceID

Definition:
Private Property Get TraceID() As Long


SetValue

Sets the current value of the Variable.

Description:
This function attempts to set the value of the Variable. The value may be set regardless of type. This function will fail if the Variable has been marked ReadOnly. This function is independent of the data type being retrieved.

Definition:
Public Function SetValue(Data As Variant) As Boolean

Parameters:
Data The new value of the Variable.

Returns:
True, if the value was set, False otherwise.


AddTrace

Adds a trace to the variable.

Description:
This function adds a new trace to the variable. The newtrace is placed at the end of the trace list, and assuming a suitable definition was made, will provide Read/Write/Destroy event notifications.

Definition:
Friend Function AddTrace() As VarTrace

Returns:
A reference to a new VarTrace object.


IsAnObject

Definition:
Friend Function IsAnObject() As Boolean


UnsetValue

Informs the Variable it is about to be deleted.

Description:
This subroutine informs tha variable that it is about to be deleted. It is here that the variable then informs all traces about impending demise through the TraceDestroy event.

Definition:
Friend Sub UnsetValue()


GetValue

Retrieves the current value of the Variable.

Description:
This subrounting retrieves the current value of the variable. The value is placed in the Value parameter. If the value of this variable is an alias, or another variable, then the value of that variable is returned.

Definition:
Public Sub GetValue(Data As Variant)

Parameters:
Data The variant to store the value.


EndTrace

Removes a trace from the trace list.

Description:
This subroutine removes the trace from the variables trace list provided that it is a member of this objects trace list.

Definition:
Friend Sub EndTrace(Trace As VarTrace)

Parameters:
Trace A reference to the Trace that is to be removed from the list.


EndAllTraces

Terminates all tracing on this variable.

Definition:
Friend Sub EndAllTraces()


TraceRead

Initiates a TraceRead event all traces within this variable.

Description:
This subroutine causes the variable to cycle through its trace list and initiate TraceRead events. Each VarTrace object is passed a reference to the variable data in succession. Modification of the data by any of the traces, causes a data change to be passed to all subsequent traces, and to the actual data itself.

Definition:
Private Sub TraceRead()


TraceWrite

Initiates a TraceWrite event all traces within this variable.

Description:
This subroutine causes the variable to cycle through its trace list and initiate TraceWrite events. Each VarTrace object is passed a reference to the variable data in succession. Modification of the data by any of the traces, causes a data change to be passed to all subsequent traces, and to the actual data itself.

Definition:
Private Sub TraceWrite(Data)

Parameters:
Data The current value of this variables data.


TraceDestroy

Initiates a TraceDestroy event all traces within this variable.

Description:
This subroutine causes the variable to cycle through its trace list and initiate TraceDestroy events.

Definition:
Private Sub TraceDestroy()


Class_Initialize

Definition:
Private Sub Class_Initialize()


Generated by BlackBox Software's DocuPro for VB6
Software and Documentation Copyright 1999,2000 BlackBox Software, All Rights Reserved