common
Class IntegerGenerator

Object
  extended by common:Generic
      extended by common:IntegerGenerator

class 
Generic:IntegerGenerator

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.


Ultra Fractal Source

Toggle UF Source Code Display

 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

IntegerGenerator

public IntegerGenerator(Generic pparent)
Constructor

Parameters:
pparent - a reference to the object creating the new object; typically, 'this'

IntegerGenerator

public IntegerGenerator()
Method Detail

Init

public int Init(int pz)
Set up for a sequence of values

This function will be called at the beginning of each sequence of values (e.g. at the beginning of each fractal orbit).

Parameters:
pz - seed value for the sequence
Returns:
first value in the sequence

InitDefault

public int InitDefault()
Set up for a sequence of values

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.

Returns:
first value in the sequence

Iterate

public int Iterate(int pz)
Produce the next value in the sequence

As long as the sequence has not bailed out, this function will be continually called to produce sequence values.

Parameters:
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.
Returns:
the next value in the sequence

IsBailedOut

public boolean IsBailedOut(int pz)
Test whether the formula has bailed out (i.e. the sequence is complete)

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.

Parameters:
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.
Returns:
true if the sequence has bailed out (i.e. should be terminated)