|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:IntegerGenerator
class
Integer Generator base class.
This is a generic generator class. Its purpose is to take
an arbitrary initial value and produce a sequence of
values of indeterminate length. This roughly corresponds
to UF's native fractal formula type, except that it starts
with and produces integer values, not complex values. Compare
this to the Formula and Generator base classes.
class IntegerGenerator(Generic) { ; Integer Generator base class. ; <p> ; This is a generic generator class. Its purpose is to take ; an arbitrary initial value and produce a sequence of ; values of indeterminate length. This roughly corresponds ; to UF's native fractal formula type, except that it starts ; with and produces integer values, not complex values. Compare ; this to the Formula and Generator base classes. public: ; Constructor ; ; @param pparent a reference to the object creating the new object; typically, 'this' func IntegerGenerator(Generic pparent) Generic.Generic(pparent) endfunc ; Set up for a sequence of values ; <p> ; This function will be called at the beginning of each ; sequence of values (e.g. at the beginning of each fractal ; orbit). ; ; @param pz seed value for the sequence ; @return first value in the sequence int func Init(int pz) ; Base class implementation flags the sequence to end ; immediately. As long as you provide your own implementation ; of IsBailedOut(), this is irrelevant. We also clear the ; iteration counter. m_Iterations = 0 m_BailedOut = true return pz endfunc ; Set up for a sequence of values ; <p> ; This alternate form of Init will cause the Generator to ; start with its "default" sequence. This can be used if a ; generator allows a user to select a "seed" value itself. ; Such Generator classes should override this function. ; ; @return first value in the sequence int func InitDefault() return Init(0) endfunc ; Produce the next value in the sequence ; <p> ; As long as the sequence has not bailed out, this function ; will be continually called to produce sequence values. ; ; @param pz previous value in the sequence. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call. ; @return the next value in the sequence int func Iterate(int pz) ; Base class implentation automatically updates the ; iteration counter and returns an unmodified pz ; (that is, the default sequence is the same value ; repeated infinitely). m_Iterations = m_Iterations + 1 return pz endfunc ; Test whether the formula has bailed out (i.e. the sequence is complete) ; <p> ; This is typically called once per iteration to test whether ; the sequence has completed. If producing this result is ; difficult to do separately from the Iterate() processing, ; you should produce the result in Iterate() and set the ; m_BailedOut flag appropriately, and leave IsBailedOut() ; unimplemented in your class to inherit this behavior. ; ; @param pz last sequence value to test; this should be the value returned from the previous Iterate() call. Note that it is acceptable to ignore pz and use m_BailedOut, but any code calling IsBailedOut() should pass in the correct pz for Generator classes which do not use m_BailedOut. ; @return true if the sequence has bailed out (i.e. should be terminated) bool func IsBailedOut(int pz) return m_BailedOut endfunc protected: int m_Iterations ; count the number of iterations bool m_BailedOut ; flag indicating whether sequence has bailed out or not default: int param v_integergenerator caption = "Version (IntegerGenerator)" default = 100 hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used." visible = @v_integergenerator < 100 endparam }
Constructor Summary | |
---|---|
IntegerGenerator()
|
|
IntegerGenerator(Generic pparent)
Constructor |
Method Summary | |
---|---|
int |
Init(int pz)
Set up for a sequence of values |
int |
InitDefault()
Set up for a sequence of values |
boolean |
IsBailedOut(int pz)
Test whether the formula has bailed out (i.e. |
int |
Iterate(int pz)
Produce the next value in the sequence |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public IntegerGenerator(Generic pparent)
pparent
- a reference to the object creating the new object; typically, 'this'public IntegerGenerator()
Method Detail |
---|
public int Init(int pz)
This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).
pz
- seed value for the sequence
public int InitDefault()
This alternate form of Init will cause the Generator to start with its "default" sequence. This can be used if a generator allows a user to select a "seed" value itself. Such Generator classes should override this function.
public int Iterate(int pz)
As long as the sequence has not bailed out, this function will be continually called to produce sequence values.
pz
- previous value in the sequence. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
public boolean IsBailedOut(int pz)
This is typically called once per iteration to test whether the sequence has completed. If producing this result is difficult to do separately from the Iterate() processing, you should produce the result in Iterate() and set the m_BailedOut flag appropriately, and leave IsBailedOut() unimplemented in your class to inherit this behavior.
pz
- last sequence value to test; this should be the value returned from the previous Iterate() call. Note that it is acceptable to ignore pz and use m_BailedOut, but any code calling IsBailedOut() should pass in the correct pz for Generator classes which do not use m_BailedOut.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |