[Classes] [Prev] [Next] [Methods]

CTdiValue

Methods Index

Heritage
Description
Usage
Enum
Protected Data Members
Public Methods
Constructor, Destructor, and Operator Methods
Utility Methods
Conversion Methods
Access Methods
Override

CTdiValue


Heritage

Superclass: CModel

Subclasses: CTdiBooleanValue, CTdiCommandTranslator, CTdiDateValue, CTdiFloatValue, CTdiIntegerValue, CTdiListValue, CTdiStringValue, CTdiTimeValue


Description

CTdiValue is an abstract class that provides an interface for converting its value to a set of basic common types described by the CTdiValue::Type enum. (See the Enum section.) XVT provides this interface in order to simplify and optimize the use of CTdiValues as carriers of common data types over TDI connections. You can define CTdiValues that represent data of other types as well, using the Power++ RTTI [ interface to determine type for usage purposes at run-time. (See CTypeInfo and CTypeBaseIterator for more information.) The CTdiValue conversion methods (i.e., ToString(), FromString(), etc.) perform no conversions. Derived classes should provide implementations of these methods where necessary.

CTdiValue provides methods for a wide interface for iteration, allowing you to treat a CTdiValue as a collection of values. By default, these methods treat a CTdiValue as the only element in the collection, but derived classes that represent an aggregation of values can implement the iteration methods as needed.


Usage

All CTdiValue subclasses have a basic form that provides a constructor, destructor, copy constructor, and assignment operator. In addition, these classes support cloning through the Copy( and newSpecies() methods. All CTdiValue subclasses support a wide range of conversion methods, such as ToString() and FromString().

Instances of derived CTdiValue classes are used to represent a change of data in a TDI connection. A TDI message consists of four primary parts:

Sending a TDI message requires the creation of a value. For example, the following code is taken from a view object sending information about its changed title:

if(GetPrimaryController() != NULL)
{
CTdiStringValue aValue( this, GetTitle() );
GetPrimaryController()->DoChange(
this, TDIReplaceCmd, &aValue);
}
CTdiValues are also used when receiving TDI messages. For example, the following code is taken from CView and shows the handling of TDI messages for changing its title:

void CView::DoUpdateModel(
long theControllerId,
long theCommand,
const CModel* theModel)
{
BOOLEANhandled = FALSE;
if(theControllerId == CTdiController::kID)
{
CTdiValue*model = PtrCast(
CTdiValue, theModel);

if(model != NULL)
{
switch(theCommand)
{
case TDIClearCmd:
SetTitle( CStringRW() );
handled = TRUE;
break;
case TDIReplaceCmd:
SetTitle( model->ToString() );
handled = TRUE;
break;
case TDIAppendCmd:
SetTitle( CStringRW(
GetTitle()) + model->ToString() );
handled = TRUE;
break;
}
}
else
{
// Check for other types of acceptable
CTdiValues
...
}
}
}

Enum

Type

STRING_TYPE,
INTEGER_TYPE,
FLOAT_TYPE,
BOOLEAN_TYPE,
USER_TYPE

These are provided to simplify and optimize the use of CTdiValues as carriers of common data types. An object is of USER_TYPE if it is none of those above.


Protected Data Members

const CNotifier* itsOriginator; Object sending CTdiValue in a TDI message.
long itsContext; TDI command associated with value
size_t itsCurrentIndex; Iteration index
BOOLEAN itIsReset; State between Reset() and first Next()


Public Methods

Constructor, Destructor, and Operator Methods

CTdiValue(const CNotifier* theOriginator = NULL,
long theContext = NULLcmd);
CTdiValue(const CTdiValue& copy);
const CTdiValue& operator=(const CTdiValue& copy);
virtual ~CTdiValue();

Utility Methods

long GetContext(void) const;
void SetContext(long theContext);
const CNotifier* GetOriginator() const;

Conversion Methods

virtual BOOLEAN Copy(const CTdiValue& prototype) = 0;
virtual BOOLEAN IsConvertible(
CTdiValue::Type theType) const;
virtual CTdiValue::Type GetType() const;
virtual CStringRW ToString() const;
virtual int ToInteger() const;
virtual float ToFloat() const;
virtual BOOLEAN ToBoolean() const;
virtual BOOLEAN FromString(const CStringRW& theValue);
virtual BOOLEAN FromInteger(int theValue);
virtual BOOLEAN FromFloat(float theValue);
virtual BOOLEAN FromBoolean(BOOLEAN theValue);

Access Methods

virtual void Reset() const;
virtual BOOLEAN Next() const;
virtual BOOLEAN GoTo(size_t theIndex);
virtual size_t Entries() const;
virtual BOOLEAN Clear();
virtual BOOLEAN Append(CTdiValue* theValue);
virtual BOOLEAN Set(
size_t theIndex, CTdiValue* theValue);
virtual BOOLEAN Change(
long theCommand, const CModel* theModel);
Overridden CModel method, rendered inactive: you should not need to operate on CTdiValue objects through this interface.


Override

Each derived class must define the following:

virtual const CTdiValue*Copy(
const CTdiValue& prototype) = 0;
In addition, the conversion methods can be provided when possible.

If your CTdiValue-derived class implements collection support, you can also implement the collection wide-interface methods.



[Classes] [Prev] [Next] [Methods]

support@xvt.com


Visit our online help desk for tech support

Copyright © 2009, Providence Software Solutions Inc. All rights reserved.