GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CLASS::MOP::INSTANCE (3)

.ds Aq ’

NAME

Class::MOP::Instance - Instance Meta Object

CONTENTS

VERSION

version 2.1605

DESCRIPTION

The Instance Protocol controls the creation of object instances, and the storage of attribute values in those instances.

Using this API directly in your own code violates encapsulation, and we recommend that you use the appropriate APIs in Class::MOP::Class and Class::MOP::Attribute instead. Those APIs in turn call the methods in this class as appropriate.

This class also participates in generating inlined code by providing snippets of code to access an object instance.

METHODS

    Object construction

<B>Class::MOP::Instance->new(%options)B> This method creates a new meta-instance object.

It accepts the following keys in %options:
o associated_metaclass

The Class::MOP::Class object for which instances will be created.

o attributes

An array reference of Class::MOP::Attribute objects. These are the attributes which can be stored in each instance.

    Creating and altering instances

<B>B>$metainstance<B>->create_instanceB> This method returns a reference blessed into the associated metaclass’s class.

The default is to use a hash reference. Subclasses can override this.

<B>B>$metainstance<B>->clone_instance($instance)B> Given an instance, this method creates a new object by making shallow clone of the original.

    Introspection

<B>B>$metainstance<B>->associated_metaclassB> This returns the Class::MOP::Class object associated with the meta-instance object.
<B>B>$metainstance<B>->get_all_slotsB> This returns a list of slot names stored in object instances. In almost all cases, slot names correspond directly attribute names.
<B>B>$metainstance<B>->is_valid_slot($slot_name)B> This will return true if $slot_name is a valid slot name.
<B>B>$metainstance<B>->get_all_attributesB> This returns a list of attributes corresponding to the attributes passed to the constructor.

    Operations on Instance Structures

It’s important to understand that the meta-instance object is a different entity from the actual instances it creates. For this reason, any operations on the $instance_structure always require that the object instance be passed to the method.
<B>B>$metainstance<B>->get_slot_value($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->set_slot_value($instance_structure, B>$slot_name<B>, B>$value<B>)B>
<B>B>$metainstance<B>->initialize_slot($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->deinitialize_slot($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->initialize_all_slots($instance_structure)B>
<B>B>$metainstance<B>->deinitialize_all_slots($instance_structure)B>
<B>B>$metainstance<B>->is_slot_initialized($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->weaken_slot_value($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->slot_value_is_weak($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->strengthen_slot_value($instance_structure, B>$slot_name<B>)B>
<B>B>$metainstance<B>->rebless_instance_structure($instance_structure, B>$new_metaclass<B>)B> The exact details of what each method does should be fairly obvious from the method name.

    Inlinable Instance Operations

<B>B>$metainstance<B>->is_inlinableB> This is a boolean that indicates whether or not slot access operations can be inlined. By default it is true, but subclasses can override this.
<B>B>$metainstance<B>->inline_create_instance($class_variable)B> This method expects a string that, when inlined, will become a class name. This would literally be something like $class, not an actual class name.

It returns a snippet of code that creates a new object for the class. This is something like bless {}, $class_name .

<B>B>$metainstance<B>->inline_get_is_lvalueB> Returns whether or not inline_get_slot_value is a valid lvalue. This can be used to do extra optimizations when generating inlined methods.
<B>B>$metainstance<B>->inline_slot_access($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_get_slot_value($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_set_slot_value($instance_variable, B>$slot_name<B>, B>$value<B>)B>
<B>B>$metainstance<B>->inline_initialize_slot($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_deinitialize_slot($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_is_slot_initialized($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_weaken_slot_value($instance_variable, B>$slot_name<B>)B>
<B>B>$metainstance<B>->inline_strengthen_slot_value($instance_variable, B>$slot_name<B>)B> These methods all expect two arguments. The first is the name of a variable, than when inlined, will represent the object instance. Typically this will be a literal string like $_[0].

The second argument is a slot name.

The method returns a snippet of code that, when inlined, performs some operation on the instance.

<B>B>$metainstance<B>->inline_rebless_instance_structure($instance_variable, B>$class_variable<B>)B> This takes the name of a variable that will, when inlined, represent the object instance, and the name of a variable that will represent the class to rebless into, and returns code to rebless an instance into a class.

    Introspection

<B>Class::MOP::Instance->metaB> This will return a Class::MOP::Class instance for this class.

It should also be noted that Class::MOP will actually bootstrap this module by installing a number of attribute meta-objects into its metaclass.

AUTHORS

o Stevan Little <stevan.little@iinteractive.com>
o Dave Rolsky <autarch@urth.org>
o Jesse Luehrs <doy@tozt.net>
o Shawn M Moore <code@sartak.org>
o XXXX XXXXX (Yuval Kogman) <nothingmuch@woobling.org>
o Karen Etheridge <ether@cpan.org>
o Florian Ragwitz <rafl@debian.org>
o Hans Dieter Pearcey <hdp@weftsoar.net>
o Chris Prather <chris@prather.org>
o Matt S Trout <mst@shadowcat.co.uk>

COPYRIGHT AND LICENSE

This software is copyright (c) 2006 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CLASS::MOP::INSTANCE (3) 2016-02-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.