NAME

Clownfish::Class - Class.

SYNOPSIS

my $class = Clownfish::Class->fetch_class('Foo::Bar');
my $subclass = Clownfish::Class->singleton('Foo::Bar::Jr', $class);

DESCRIPTION

Classes, which are the first element in any Clownfish object, are actually objects themselves. (Their first element is a Class which describes the behavior of Classes.)

CONSTRUCTORS

fetch_class

my $class = Clownfish::Class->fetch_class($class_name);

Find a registered class. May return undef if the class is not registered.

singleton

my $class = Clownfish::Class->singleton(
    class_name => $class_name,
    parent     => $parent,
);

Return a singleton. If a Class can be found in the registry based on the supplied class name, it will be returned. Otherwise, a new Class will be created using parent as a base.

If parent is undef, an attempt will be made to find it. If the attempt fails, an error will result.

METHODS

make_obj

$class->make_obj();

Create an empty object of the type defined by the Class: allocate, assign its class and give it an initial refcount of 1. The caller is responsible for initialization.

get_name

$class->get_name();

Return the name of the class.

get_parent

$class->get_parent();

Return the parent class, or undef for a root of the class hierarchy.

get_obj_alloc_size

$class->get_obj_alloc_size();

Return the number of bytes needed to hold an object the class.

INHERITANCE

Clownfish::Class isa Clownfish::Obj.