ValueFunction Class Reference

Abstract Base class 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 ValueFunction:

ListItem CCObject SimpleCCObject ValueFunctionBlip ValueFunctionConstant ValueFunctionPressure ValueFunctionRamp ValueFunctionRandom ValueFunctionSmoothStroke ValueFunctionEllipse ValueFunctionTeardrop ValueFunctionTeardropCurvedEnd ValueFunctionThumbtack ValueFunctionPressureS ValueFunctionBevelEnds ValueFunctionDecay ValueFunctionDoubleRampS ValueFunctionIntestine ValueFunctionPropeller ValueFunctionRampL ValueFunctionRampL2 ValueFunctionRampLinear ValueFunctionRampS ValueFunctionRampS2 ValueFunctionSawTooth ValueFunctionSS_Barb ValueFunctionSS_Cigar ValueFunctionSS_Cigar2 ValueFunctionSS_Cigar3 ValueFunctionSS_Comet ValueFunctionSS_Concave ValueFunctionSS_Convex ValueFunctionSS_Fallout ValueFunctionSS_Goldfish ValueFunctionSS_Iron ValueFunctionSS_Meteor ValueFunctionSS_Missile ValueFunctionSS_OceanLiner ValueFunctionSS_Petal ValueFunctionSS_Reed ValueFunctionSS_SlimBlip ValueFunctionSS_Torpedo ValueFunctionSS_Yacht List of all members.

Public Member Functions

virtual double GetValue (double Position)=0
virtual ValueFunctionClone (void)=0
virtual BOOL IsDifferent (ValueFunction *pOther)
 Comparator. Determines if 2 different ValueFunction objects are considered different.
virtual CamelotFileRecordWriteFileRecord (INT32 RecordTag, INT32 ExtraBytes, BaseCamelotFilter *pFilter)=0
virtual ValueFunctionID GetUniqueID (void)=0
virtual INT32 GetMinimumRecursionDepth ()

Static Public Member Functions

static BOOL Init (void)
 Initialises all valueFunction classes defined in valfunc.cpp.
static void DeInit (void)
 Initialises all valueFunction classes defined in valfunc.cpp.
static ValueFunctionReadFileRecord (CXaraFileRecord *pInputRecord)
 Main entry point for loading ValueFunctions from files. The caller record handler passes the record in to this static function, and the saved VF is re-constituted from the saved information. On return the caller can read any extra values that they saved in the record.

Protected Member Functions

CamelotFileRecordCreateAndWriteFileRecord (INT32 RecordTag, INT32 DerivedBytes, INT32 ExtraBytes, BaseCamelotFilter *pFilter)
 Creates an output record containing an embedded ValueFunction description.
virtual ValueFunctionCreateAndReadFileRecord (CXaraFileRecord *pInputRecord)=0

Static Protected Attributes

static List RegisteredFunctions

Private Member Functions

 CC_DECLARE_DYNAMIC (ValueFunction)

Detailed Description

Abstract Base class 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
The function may be whatever you desire. Likely derived classes might return a functional result such as a Sine, or interpolate between 2 other values, or possibly look the position up in a table.

This is quite a generic class, but it is mainly used by the stroke provider system for handling variable line width functions.

Notes: Positions passed into these functions will always be within the range 0.0 to 1.0.

Generally, outputs from these functions will lie between -1.0 and 1.0, although there is no reason why the derived classes cannot be passed ranges (e.g. see the Ramp classes below)

Definition at line 196 of file valfunc.h.


Member Function Documentation

ValueFunction::CC_DECLARE_DYNAMIC ValueFunction   )  [private]
 

virtual ValueFunction* ValueFunction::Clone void   )  [pure virtual]
 

Implemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRampLinear, ValueFunctionRampS, ValueFunctionRampS2, ValueFunctionRampL, ValueFunctionRampL2, ValueFunctionSawTooth, ValueFunctionPropeller, ValueFunctionDoubleRampS, ValueFunctionBevelEnds, ValueFunctionIntestine, ValueFunctionDecay, ValueFunctionBlip, ValueFunctionPressure, ValueFunctionSS_Yacht, ValueFunctionSS_Iron, ValueFunctionSS_Reed, ValueFunctionSS_Meteor, ValueFunctionSS_Petal, ValueFunctionSS_Comet, ValueFunctionSS_Fallout, ValueFunctionSS_Torpedo, ValueFunctionSS_Missile, ValueFunctionSS_Convex, ValueFunctionSS_Concave, ValueFunctionSS_Cigar, ValueFunctionSS_Cigar2, ValueFunctionSS_Cigar3, ValueFunctionSS_SlimBlip, ValueFunctionSS_OceanLiner, ValueFunctionSS_Goldfish, and ValueFunctionSS_Barb.

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

Implemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRampLinear, ValueFunctionRampS, ValueFunctionRampS2, ValueFunctionRampL, ValueFunctionRampL2, ValueFunctionSawTooth, ValueFunctionPropeller, ValueFunctionDoubleRampS, ValueFunctionBevelEnds, ValueFunctionIntestine, ValueFunctionDecay, ValueFunctionBlip, ValueFunctionPressure, and ValueFunctionSmoothStroke.

CamelotFileRecord * ValueFunction::CreateAndWriteFileRecord INT32  RecordTag,
INT32  DerivedBytes,
INT32  ExtraBytes,
BaseCamelotFilter pFilter
[protected]
 

Creates an output record containing an embedded ValueFunction description.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Parameters:
RecordTag - the tag to write this record under [INPUTS]
DerivedBytes- The number of bytes of information the derived VF class wishes to write to save its state. Space for this infomation will be reserved in the new record

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.
This base-class function only writes the ValueFunction header for the record data. The caller must append its own state information to this header - see the record description below.

The record will be (4 + DerivedBytes + ExtraBytes) bytes in length, and on return from this function, the first 4 bytes (only) will have been written. The caller(s) must fill in the remainder.

All ValueFunction record data has 3 sections, whiich are recorded as follows: 1. ValueFunction header, identifying which type of VF is being saved. This is written by the base class CreateAndWriteFileRecord INT32 ValueFunctionUniqueID (4 bytes)

2. Derived-class-data (0 or more bytes). This is written by the derived class WriteFileRecord function, into the record returned from here. This data must be DerivedBytes (0 or more) bytes in length.

3. Caller data. This is written by the caller of the derived function. This data must be ExtraBytes (0 or more) bytes in length.

See also:
ValueFunctionConstant::CreateAndReadFileRecord

Definition at line 416 of file valfunc.cpp.

00419 {
00420     ERROR3IF(pFilter == NULL, "Illegal NULL param");
00421     ERROR3IF(ExtraBytes < 0, "Stupid ExtraBytes request in ValueFunction::CreateAndWriteFileRecord");
00422 
00423     // Calculate how many bytes of information this VF will write.
00424     // We write a 4-byte "header", followed by the derived class data and the caller data
00425     const INT32 RecordSize = 4 + DerivedBytes + ExtraBytes;
00426 
00427     // Create an appropriate record, and write the header info to it
00428     CamelotFileRecord *pRec = new CamelotFileRecord(pFilter, RecordTag, RecordSize);
00429 
00430     // If that worked, then we now init & add our own data to the record
00431     if (pRec != NULL)
00432     {
00433         BOOL ok    = pRec->Init();
00434         if (ok) ok = pRec->WriteUINT32(GetUniqueID());
00435 
00436         if (!ok)        // If we failed, then clean up & return NULL
00437         {
00438             delete pRec;
00439             pRec = NULL;
00440         }
00441     }
00442 
00443     return(pRec);
00444 }

void ValueFunction::DeInit void   )  [static]
 

Initialises all valueFunction classes defined in valfunc.cpp.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Returns:
TRUE if it initialises successfully

Definition at line 281 of file valfunc.cpp.

00282 {
00283     RegisteredFunctions.DeleteAll();
00284 }

virtual INT32 ValueFunction::GetMinimumRecursionDepth  )  [inline, virtual]
 

Reimplemented in ValueFunctionRampS, ValueFunctionRampS2, ValueFunctionRampL, ValueFunctionRampL2, ValueFunctionSawTooth, ValueFunctionPropeller, ValueFunctionDoubleRampS, ValueFunctionBevelEnds, ValueFunctionIntestine, ValueFunctionDecay, ValueFunctionTeardropCurvedEnd, and ValueFunctionSmoothStroke.

Definition at line 230 of file valfunc.h.

00230 { return 0; };

virtual ValueFunctionID ValueFunction::GetUniqueID void   )  [pure virtual]
 

Implemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRampLinear, ValueFunctionRampS, ValueFunctionRampS2, ValueFunctionRampL, ValueFunctionRampL2, ValueFunctionSawTooth, ValueFunctionPropeller, ValueFunctionDoubleRampS, ValueFunctionBevelEnds, ValueFunctionIntestine, ValueFunctionDecay, ValueFunctionBlip, ValueFunctionTeardrop, ValueFunctionTeardropCurvedEnd, ValueFunctionEllipse, ValueFunctionThumbtack, ValueFunctionPressure, ValueFunctionPressureS, ValueFunctionSS_Yacht, ValueFunctionSS_Iron, ValueFunctionSS_Reed, ValueFunctionSS_Meteor, ValueFunctionSS_Petal, ValueFunctionSS_Comet, ValueFunctionSS_Fallout, ValueFunctionSS_Torpedo, ValueFunctionSS_Missile, ValueFunctionSS_Convex, ValueFunctionSS_Concave, ValueFunctionSS_Cigar, ValueFunctionSS_Cigar2, ValueFunctionSS_Cigar3, ValueFunctionSS_SlimBlip, ValueFunctionSS_OceanLiner, ValueFunctionSS_Goldfish, and ValueFunctionSS_Barb.

virtual double ValueFunction::GetValue double  Position  )  [pure virtual]
 

Implemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRampLinear, ValueFunctionRampS, ValueFunctionRampS2, ValueFunctionRampL, ValueFunctionRampL2, ValueFunctionSawTooth, ValueFunctionPropeller, ValueFunctionDoubleRampS, ValueFunctionBevelEnds, ValueFunctionIntestine, ValueFunctionDecay, ValueFunctionBlip, ValueFunctionTeardrop, ValueFunctionTeardropCurvedEnd, ValueFunctionEllipse, ValueFunctionThumbtack, ValueFunctionPressure, ValueFunctionPressureS, and ValueFunctionSmoothStroke.

BOOL ValueFunction::Init void   )  [static]
 

Initialises all valueFunction classes defined in valfunc.cpp.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Returns:
TRUE if it initialises successfully
Adds an instance of each ValueFunction to a dynamic list, which is used to create new ValueFunctions as they are loaded from files. Any dynamically added ValueFunction-derived class should add an instance to the RegistreredFunctions list in order to properly handle being re-loaded.

Reimplemented from SimpleCCObject.

Definition at line 212 of file valfunc.cpp.

00213 {
00214 #define VFINIT(TYPE)                                \
00215     {                                               \
00216         TYPE *pFunc = new TYPE;                     \
00217         if (!pFunc)                                 \
00218             return(FALSE);                          \
00219         RegisteredFunctions.AddTail(pFunc);         \
00220     }
00221 
00222     VFINIT(ValueFunctionConstant);
00223     VFINIT(ValueFunctionRandom);
00224     VFINIT(ValueFunctionRampLinear);
00225     VFINIT(ValueFunctionRampS);
00226     VFINIT(ValueFunctionPressure);
00227     VFINIT(ValueFunctionPressureS);
00228     VFINIT(ValueFunctionBlip);
00229     VFINIT(ValueFunctionTeardrop);
00230     VFINIT(ValueFunctionEllipse);
00231     VFINIT(ValueFunctionThumbtack);
00232     VFINIT(ValueFunctionRampL);
00233     VFINIT(ValueFunctionRampS2);
00234     VFINIT(ValueFunctionRampL2);
00235     VFINIT(ValueFunctionTeardropCurvedEnd);
00236     VFINIT(ValueFunctionSawTooth);
00237     VFINIT(ValueFunctionPropeller);
00238     VFINIT(ValueFunctionDoubleRampS);
00239     VFINIT(ValueFunctionIntestine);
00240     VFINIT(ValueFunctionDecay);
00241     VFINIT(ValueFunctionBevelEnds);
00242     VFINIT(ValueFunctionSS_Reed);
00243     VFINIT(ValueFunctionSS_Meteor);
00244     VFINIT(ValueFunctionSS_Petal);
00245     VFINIT(ValueFunctionSS_Comet);
00246     VFINIT(ValueFunctionSS_Barb);
00247     VFINIT(ValueFunctionSS_Concave);
00248     VFINIT(ValueFunctionSS_Convex);
00249     VFINIT(ValueFunctionSS_Iron);
00250     VFINIT(ValueFunctionSS_Torpedo);
00251     VFINIT(ValueFunctionSS_Missile);
00252     VFINIT(ValueFunctionSS_Goldfish);
00253     VFINIT(ValueFunctionSS_OceanLiner);
00254     VFINIT(ValueFunctionSS_Yacht);
00255     VFINIT(ValueFunctionSS_SlimBlip);
00256     VFINIT(ValueFunctionSS_Cigar);
00257     VFINIT(ValueFunctionSS_Cigar2);
00258     VFINIT(ValueFunctionSS_Cigar3);
00259     VFINIT(ValueFunctionSS_Fallout);
00260 
00261 #undef VFINIT
00262 
00263     return(TRUE);
00264 }

BOOL ValueFunction::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: The base class simply checks if they are of the same runtime class and returns TRUE if they are not. Derived classes which can differ in content between instances must override this method.

Reimplemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRamp, ValueFunctionBlip, ValueFunctionPressure, and ValueFunctionSmoothStroke.

Definition at line 310 of file valfunc.cpp.

00311 {
00312     ERROR3IF(pOther == NULL, "Illegal NULL param");
00313     return(GetRuntimeClass() != pOther->GetRuntimeClass());
00314 }

ValueFunction * ValueFunction::ReadFileRecord CXaraFileRecord pInputRecord  )  [static]
 

Main entry point for loading ValueFunctions from files. The caller record handler passes the record in to this static function, and the saved VF is re-constituted from the saved information. On return the caller can read any extra values that they saved in the record.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
27/1/97
Parameters:
pInputRecord - The file record to read from [INPUTS]
Returns:
NULL if it fails, else a pointer to a new object initialised from the given file record.
Notes: This scans the member RegisteredFunction list to see if it can find a ValueFunction of the appropriate type, and asks it to create a new ValueFunction to be initialised from the given record (by calling the virtual CreateAndReadFileRecord())

Definition at line 342 of file valfunc.cpp.

00343 {
00344     ERROR3IF(pInputRecord == NULL, "Illegal NULL params");
00345 
00346     INT32 ID;
00347     pInputRecord->ReadINT32(&ID);
00348 
00349     ValueFunction *pFunc = (ValueFunction *) RegisteredFunctions.GetHead();
00350     while (pFunc != NULL)
00351     {
00352         if (pFunc->GetUniqueID() == ID)
00353             return(pFunc->CreateAndReadFileRecord(pInputRecord));
00354 
00355         pFunc = (ValueFunction *) RegisteredFunctions.GetNext(pFunc);
00356     }
00357 
00358     return(NULL);
00359 }

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

Implemented in ValueFunctionConstant, ValueFunctionRandom, ValueFunctionRamp, ValueFunctionBlip, ValueFunctionPressure, and ValueFunctionSmoothStroke.


Member Data Documentation

List ValueFunction::RegisteredFunctions [static, protected]
 

Definition at line 245 of file valfunc.h.


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