# Generated by Pod::WikiDoc version 0.18

=pod

=head1 NAME

Class::Dot::Registry - Class registry.

=head1 VERSION

This document describes Class::Dot version 2.0.0_15

=head1 SYNOPSIS

     use Class::Dot::Registry;
 
     my $REGISTRY = Class::Dot::Registry->new();

=head1 DESCRIPTION

B<WARNING>:
This is a module used internally by L<Class::Dot>. If you are not hacking on
any internals you are most likely better off using the interfaces that uses
this module than using it directly.

Please see L<Class::Dot> and L<Class::Dot::Manual>.

Ok. Now that we got that out of the way; If you are still here you probably
wonder what this module do? This module keeps track of metadata for the
classes that is under L<Class::Dot>'s control. Metadata include things like
class options, attribute settings, class finalization status, ISA caches and
so on. L<Class::Dot> uses this module to store and manipulate this information

=head1 SUBROUTINESE<sol>METHODS

=head2 CLASS CONSTRUCTOR

=head3 C<<< new() >>>

This will return the global class registry as the registry is a singleton

Example:

     my $REGISTRY = Class::Dot::Registry->new();

=head2 INSTANCE METHODS

=head3 C<<< is_class_registered($class >>>)

Returns true if the class is a L<Class::Dot> class.

=head3 C<<< register_class($class) >>>

Register the class as a L<Class::Dot> class.

=head3 C<<< get_metaclass_for($class) >>>

Returns the metaclass instance for C<<< $class >>>.

This is a instance of the class that was set with the
C<<< -metaclass >>> class option.

If the class is not a C<<< Class::Dot >>> class it will still return
an instance of the default metaclass, this is for interoperability with
other object systems (or no object system at all).

If you want to see if a class is a C<<< Class::Dot >>> class first you can
do this:

     my $is_dotified = $REGISTRY->is_class_registered($class);

Examples:

     # Get the metaclass instance for $class
     my $metaclass = $REGISTRY->get_metaclass_for($class);
 
     # Get the class name of the metaclass for $class
     my $metaclass_name = ref $REGISTRY->get_metaclass_for($class);

=head3 C<<< init_metaclass_for($class, $metaclass, $class_options) >>>

Init the metaclass for C<<< $class >>> by creating a new instance of C<<< $metaclass >>>
with options C<<< $class_options >>>.

This is done when you import L<Class::Dot> to your package, so unless
you are working on the internals of Class::Dot or (my god) changing
metaclasses at runtime, you should probably leave this alone.

=head3 C<<< get_options_for($class) >>>

Get the global class options for C<<< $class >>> as a hash reference.

Remember that attributes can overwrite these options in
C<<< $self->__meta__($attribute_name) >>> to specify separate options
for a single attribute. These are just the class defaults.

Examples:

     my $class_options = $REGISTRY->get_options_for($class);
 
     my $is_constrained = $class_options->{'-constrained'};

=head3 C<<< set_options_for($class, $options_ref) >>>

Set the options for C<<< $class >>> to the new hash reference C<<< $options_ref >>>.
This will not merge with the previous options, but B<overwrite the previous
options with the new ones>.

=head3 C<<< get_meta_for($class) >>>

Returns the data structure containing the meta data
for C<<< $class >>>.

=head3 C<<< get_isa_cache_for($class) >>>

Returns the current isa cache for C<<< $class >>>, but B<only if
the class is finalized>.

Returns nothing if C<<< $class >>> is not finalized,
else it returns the isa cache as a hash reference.

=head3 C<<< update_isa_cache_for($class, $isa_cache) >>>

Update the isa cache for C<<< $class >>> with the new isa cache C<<< $isa_cache >>>.
This will not fetch the isa cache, you will have to do that manually.
See C<<< finalize_class($class, $isa_cache) >>>.

You probably want L<Class::Dot|finalize_class($class)>.

=head3 C<<< is_finalized($class) >>>

Returns true if C<<< $class >>> is finalized.

=head3 C<<< finalize_class($class, $isa_cache) >>>

Finalizes the class. You must also give the isa cache, if not
there is not much point in finalizing the class.

You probably want L<Class::Dot|finalize_class($class)> instead.

Example finalizing the class C<<< $class >>>:

     my $REGISTRY  = Class::Dot::Registry->new();
     my $metaclass = $REGISTRY->get_metaclass_for($class);
     my $isa_cache = $metaclass->property->traverse_isa_for_property($class);
     $REGISTRY->finalize_class($class, $isa_cache);

=head2 PRIVATE CLASS METHODS

These are very private methods, and are very likely to change
in the near future, so please stay away from these. They are
only used internally in this class, and it will violate
data privacy and coupling if any of these methods are used
outside of this class.

=head3 C<<< _get_class_meta() >>>

Get direct access to the meta registry for all classes.

=head3 C<<< _get_finalized() >>>

Get direct access to the status of which classes are finalized.

=head3 C<<< _get_isa_cache() >>>

Get direct access to the isa cache for all classes.

=head3 C<<< _get_metaclasses() >>>

Get direct access to the map of metaclasses.

=head3 C<<< _get_options() >>>

Get direct access to all classes options.

=head3 C<<< _get_registered_classes) >>>

Get direct access to the list of which classes are registered.

=head1 DIAGNOSTICS

=head2 C<<< !!! COULD NOT LOAD METACLASS %s FOR CLASS %s !!! >>>

You have probably set a custom metaclass for the class with the C<<< -metaclass >>>
option, but when we tried to load this class it could not be found.

Maybe you have a typo in the metaclass name? Or the class is not installed, or
is not in the path where perl looks for modules. (C<<< @INC >>>).

=head1 CONFIGURATION AND ENVIRONMENT

This module requires no configuration file or environment variables.

=head1 DEPENDENCIES

=over

=item *

L<version>

=back

=over

=item *

L<Class::Plugin::Util>

=back

=head1 INCOMPATIBILITIES

None known.

=head1 BUGS AND LIMITATIONS

No bugs have been reported.

=head1 SEE ALSO

=head2 L<Class::Dot>

=head1 AUTHOR

Ask Solem, L<asksh@cpan.org>.

=head1 LICENSE AND COPYRIGHT

Copyright (c), 2007 Ask Solem L<ask@0x61736b.net|mailto:ask@0x61736b.net>.

C<<< Class::Dot >>> is distributed under the Modified BSD License.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this
list of conditions and the following disclaimer in the documentation andE<sol>or
other materials provided with the distribution.

3. The name of the author may not be used to endorse or promote products
derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED                        
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF                                
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO                          
EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,                              
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,                        
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR                      
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER                       
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)                          
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE                          
POSSIBILITY OF SUCH DAMAGE.

=head1 DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
STATED IN WRITING THE COPYRIGHT HOLDERS ANDE<sol>OR OTHER PARTIES PROVIDE THE
SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY
COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY ANDE<sol>OR REDISTRIBUTE THE
SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO
LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER
SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.


=for stopwords expandtab shiftround

# Local Variables:
#   mode: cperl
#   cperl-indent-level: 4
#   fill-column: 78
# End:
# vim: expandtab tabstop=4 shiftwidth=4 shiftround
    
