CS::Math::Noise::Module::Cache Class Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes
CS::Math::Noise::Module::Cache Class Reference
Miscellaneous Modules

Noise module that caches the last output value generated by a source module. More...

`#include <cstool/noise/module/cache.h>`

Inheritance diagram for CS::Math::Noise::Module::Cache:

List of all members.

## Public Member Functions
| Cache ()
| Constructor.
virtual int | GetSourceModuleCount () const
| Returns the number of source modules required by this noise module.
virtual double | GetValue (double x, double y, double z) const
| Generates an output value given the coordinates of the specified input value.
virtual void | SetSourceModule (int index, const Module &sourceModule)
| Connects a source module to this noise module.
## Protected Attributes
double | m_cachedValue
| The cached output value at the cached input value.
double | m_isCached
| Determines if a cached output value is stored in this noise module.
double | m_xCache
| x coordinate of the cached input value.
double | m_yCache
| y coordinate of the cached input value.
double | m_zCache
| z coordinate of the cached input value.

## Detailed Description

Noise module that caches the last output value generated by a source module.

If an application passes an input value to the GetValue() method that differs from the previously passed-in input value, this noise module instructs the source module to calculate the output value. This value, as well as the ( x, y, z ) coordinates of the input value, are stored (cached) in this noise module.

If the application passes an input value to the GetValue() method that is equal to the previously passed-in input value, this noise module returns the cached output value without having the source module recalculate the output value.

If an application passes a new source module to the SetSourceModule() method, the cache is invalidated.

Caching a noise module is useful if it is used as a source module for multiple noise modules. If a source module is not cached, the source module will redundantly calculate the same output value once for each noise module in which it is included.

This noise module requires one source module.

Definition at line 66 of file cache.h.

## Constructor & Destructor Documentation

CS::Math::Noise::Module::Cache::Cache | ( |  | ) |

Constructor.

## Member Function Documentation

virtual int CS::Math::Noise::Module::Cache::GetSourceModuleCount | ( |  | ) | const`[inline, virtual]`

Returns the number of source modules required by this noise module.

Returns:
  The number of source modules required by this noise module.

Implements CS::Math::Noise::Module::Module.

Definition at line 74 of file cache.h.

virtual double CS::Math::Noise::Module::Cache::GetValue | ( | double | x,
|  | double | y,
|  | double | z
| ) |  | const`[virtual]`

Generates an output value given the coordinates of the specified input value.

Parameters:

  x | The x coordinate of the input value.
  y | The y coordinate of the input value.
  z | The z coordinate of the input value.

Returns:
  The output value.

Precondition:
  All source modules required by this noise module have been passed to the SetSourceModule() method.

Before an application can call this method, it must first connect all required source modules via the SetSourceModule() method. If these source modules are not connected to this noise module, this method raises a debug assertion.

To determine the number of source modules required by this noise module, call the GetSourceModuleCount() method.

Implements CS::Math::Noise::Module::Module.

virtual void CS::Math::Noise::Module::Cache::SetSourceModule | ( | int | index,
|  | const Module & | sourceModule
| ) |  | `[inline, virtual]`

Connects a source module to this noise module.

Parameters:

  index | An index value to assign to this source module.
  sourceModule | The source module to attach.

Precondition:
  The index value ranges from 0 to one less than the number of source modules required by this noise module.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information.

A noise module mathematically combines the output values from the source modules to generate the value returned by GetValue().

The index value to assign a source module is a unique identifier for that source module. If an index value has already been assigned to a source module, this noise module replaces the old source module with the new source module.

Before an application can call the GetValue() method, it must first connect all required source modules. To determine the number of source modules required by this noise module, call the GetSourceModuleCount() method.

This source module must exist throughout the lifetime of this noise module unless another source module replaces that source module.

A noise module does not modify a source module; it only modifies its output values.

Reimplemented from CS::Math::Noise::Module::Module.

Definition at line 81 of file cache.h.

## Member Data Documentation

double CS::Math::Noise::Module::Cache::m_cachedValue`[mutable, protected]`

The cached output value at the cached input value.

Definition at line 90 of file cache.h.

double CS::Math::Noise::Module::Cache::m_isCached`[mutable, protected]`

Determines if a cached output value is stored in this noise module.

Definition at line 94 of file cache.h.

double CS::Math::Noise::Module::Cache::m_xCache`[mutable, protected]`

x coordinate of the cached input value.

Definition at line 97 of file cache.h.

double CS::Math::Noise::Module::Cache::m_yCache`[mutable, protected]`

y coordinate of the cached input value.

Definition at line 100 of file cache.h.

double CS::Math::Noise::Module::Cache::m_zCache`[mutable, protected]`

z coordinate of the cached input value.

Definition at line 103 of file cache.h.

The documentation for this class was generated from the following file:

- cstool/noise/module/cache.h