ValueFunctionConstant Class Reference

Provides an interface by which the caller can obtain the value of a given function at a given "position". More...

#include <valfunc.h>

Inheritance diagram for ValueFunctionConstant:

ValueFunction ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 ValueFunctionConstant (double Value=1.0)
 Constructor The Constant ValueFunction always returns the same value!
virtual double GetValue (double Position)
 To read the value of this function at a given position.
virtual ValueFunctionClone (void)
 Clone operator. Creates an exact copy of this object.
virtual BOOL IsDifferent (ValueFunction *pOther)
 Comparator. Determines if 2 different ValueFunction objects are considered different.
virtual CamelotFileRecordWriteFileRecord (INT32 RecordTag, INT32 ExtraBytes, BaseCamelotFilter *pFilter)
 Saves a ValueFunction object to a Xara file. This function will create a new variable-sized record with the given record tag, and will write out whatever data is needed to save this ValueFunction's state to the file.
virtual ValueFunctionID GetUniqueID (void)

Protected Member Functions

virtual ValueFunctionCreateAndReadFileRecord (CXaraFileRecord *pInputRecord)
 Loads a ValueFunction object from a record which was saved into a file using the WriteFileRecord call. This is called by the base class loader routine ReadFileRecord, which finds an appropriate instance of a derived class to call to load the data in question.

Protected Attributes

double Value1

Private Member Functions

 CC_DECLARE_DYNAMIC (ValueFunctionConstant)

Detailed Description

Provides an interface by which the caller can obtain the value of a given function at a given "position".

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
This derived class simply returns a constant value

Definition at line 269 of file valfunc.h.


Constructor & Destructor Documentation

ValueFunctionConstant::ValueFunctionConstant double  Value = 1.0  ) 
 

Constructor The Constant ValueFunction always returns the same value!

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Parameters:
Value - The value to be used at all positions [INPUTS]

Definition at line 468 of file valfunc.cpp.

00469 {
00470     Value1 = Value;
00471 }


Member Function Documentation

ValueFunctionConstant::CC_DECLARE_DYNAMIC ValueFunctionConstant   )  [private]
 

ValueFunction * ValueFunctionConstant::Clone void   )  [virtual]
 

Clone operator. Creates an exact copy of this object.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/1/97
Returns:
NULL if it failed, else an exact copy of this object

Implements ValueFunction.

Definition at line 512 of file valfunc.cpp.

00513 {
00514     ValueFunction *pClone = new ValueFunctionConstant(Value1);
00515     return(pClone);
00516 }

ValueFunction * ValueFunctionConstant::CreateAndReadFileRecord CXaraFileRecord pInputRecord  )  [protected, virtual]
 

Loads a ValueFunction object from a record which was saved into a file using the WriteFileRecord call. This is called by the base class loader routine ReadFileRecord, which finds an appropriate instance of a derived class to call to load the data in question.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Parameters:
pInputRecord - The file record to read [INPUTS]
Returns:
NULL if it failed, else a pointer to new ValueFunction object representing whatever was saved in that record.
This method creates a new instance of this particular ValueFunction class and then loads whatever information is necessary from the file to initialise itself properly. The record read-pointer is left pointing at the end of the ValueFunction-saved data so that the caller can continue reading their extra bytes of data after loading the ValueFunction.

See also:
ValueFunctionConstant::WriteFileRecord; ValueFunctionConstant::ReadFileRecord

Implements ValueFunction.

Definition at line 651 of file valfunc.cpp.

00652 {
00653     ERROR3IF(pInputRecord == NULL, "Illegal NULL param");
00654 
00655     float ConstValue = (float)1.0;
00656     pInputRecord->ReadFLOAT(&ConstValue);
00657 
00658     return(new ValueFunctionConstant((double) ConstValue));
00659 }

virtual ValueFunctionID ValueFunctionConstant::GetUniqueID void   )  [inline, virtual]
 

Implements ValueFunction.

Definition at line 282 of file valfunc.h.

00282 { return(ValueFunctionID_Constant); };

double ValueFunctionConstant::GetValue double  Position  )  [virtual]
 

To read the value of this function at a given position.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/12/96
Parameters:
Position - A value between 0.0 and 1.0 [INPUTS]
Returns:
A constant value (Value, as given in the constructor) representing the value of the function at the given Position.
Notes: Constant is a bit simple - it always returns the same value

Implements ValueFunction.

Definition at line 492 of file valfunc.cpp.

00493 {
00494     return(Value1);
00495 }

BOOL ValueFunctionConstant::IsDifferent ValueFunction pOther  )  [virtual]
 

Comparator. Determines if 2 different ValueFunction objects are considered different.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/1/97
Parameters:
pOther - Another ValueFunction object to compare this one to [INPUTS]
Returns:
TRUE if the objects are considered different, FALSE if they are considered identical
Notes: Calls the base class to see if they are different classes, and then compares identical classes by checking member vars

Reimplemented from ValueFunction.

Definition at line 541 of file valfunc.cpp.

00542 {
00543     if (ValueFunction::IsDifferent(pOther))
00544         return(TRUE);
00545     
00546     // Both objects are instances of this class, so compare them more carefully
00547     return(Value1 != ((ValueFunctionConstant *)pOther)->Value1);
00548 }

CamelotFileRecord * ValueFunctionConstant::WriteFileRecord INT32  RecordTag,
INT32  ExtraBytes,
BaseCamelotFilter pFilter
[virtual]
 

Saves a ValueFunction object to a Xara file. This function will create a new variable-sized record with the given record tag, and will write out whatever data is needed to save this ValueFunction's state to the file.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Parameters:
RecordTag - the tag to write this record under [INPUTS] ExtraBytes - The number of extra bytes of information the caller will write into the record after caling this function (Space for this many extra bytes will be reserved by this function when it creates the new file record) This may be 0 or more bytes. pFilter - The filter to write to
Returns:
NULL if it failed, else a pointer to a record which saves the state of this valueFunction object. Once the caller has written the record, they MUST DELETE it.
"ExtraBytes" bytes will be added to the record size to reserve space at the end of the record for the caller to add their own data. This is to allow ValueFunctions to be saved embedded in other object's record structures (e.g. inside different types of attributes).

All ValueFunction record data has 3 sections, whiich are recorded as follows: 1. ValueFunction header, identifying which type of VF is being saved INT32 ValueFunctionUniqueID (4 bytes) 2. Derived-class-data (0 or more bytes). This particular class adds: float ConstantValue (4 bytes) 3. Caller data. This is written by the caller to the returned record object. This data must be ExtraBytes (0 or more) bytes in length.

See also:
ValueFunctionConstant::CreateAndReadFileRecord

Implements ValueFunction.

Definition at line 594 of file valfunc.cpp.

00596 {
00597     ERROR3IF(pFilter == NULL, "Illegal NULL param");
00598     ERROR3IF(ExtraBytes < 0, "Stupid ExtraBytes request in ValueFunction::WriteFileRecord");
00599 
00600     // Calculate how many bytes of information this VF will write. We do not include
00601     // the header info written by the base class or the ExtraInfo desired by the caller -
00602     // the base class adds all that in for us.
00603     const INT32 MyRecordSize = 4;
00604 
00605     // Create an appropriate record, and write our data to it
00606     CamelotFileRecord *pRec = CreateAndWriteFileRecord(RecordTag, MyRecordSize, ExtraBytes, pFilter);
00607 
00608     if (pRec != NULL)
00609     {
00610         // Write out our ValueFunction's specific data. If it fails, then we'll return NULL
00611         if (!pRec->WriteFLOAT((float)Value1))
00612         {
00613             delete pRec;
00614             pRec = NULL;
00615         }
00616     }
00617 
00618     return(pRec);
00619 }


Member Data Documentation

double ValueFunctionConstant::Value1 [protected]
 

Definition at line 289 of file valfunc.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 04:02:46 2007 for Camelot by  doxygen 1.4.4