NAME
Games::3D::Template - describe an object class and it's keys/settings
SYNOPSIS
use Games::3D::Template;
use Games::3D::Thingy;
Games::3D::Template->from_string($string);
Games::3D::Thingy->new( ... );
# check entire object
$template->validate($thingy);
# check only one key
$template->validate_key($thingy,'name');
EXPORTS
Exports nothing on default.
DESCRIPTION
This package provides a validation class for "things" in Games::3D. It defines what the valid keys are, and what their data should look like, and also how this data should be transformed into strings and back to internal data (for instance when saving/loading data).
METHODS
- new()
-
my $template = Games::3D::Template->new();
Creates a new, empty template.
- class()
-
$template->class();
Return the class of objects this template describes. For instance, 'Games::3D::Foo::Bar'.
- validate()
-
$template->validate($thingy);
Validate the entire object
$thingy
, e.g see if it still confirms to the template.Returns undef for ok, otherwise error message.
- validate_key()
-
$template->validate_key($thingy, $key);
Validate the key
$key
from object$thingy
, e.g see if it still confirms to the template.Returns undef for ok, otherwise error message.
- id()
-
Return the templates' unique id. They are independant from all other IDs.
- create_thing()
-
my $fresh = $template->create_thing();
Take your own blueprint and create a thing with default values.
AUTHORS
(c) 2004 Tels <http://bloodgate.com/>