Main > Free Download Search >

Free classes of camelot software for linux

classes of camelot

Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 2672
Class::Meta 0.53

Class::Meta 0.53


Class::Meta is a Perl class automation, introspection, and data validation. more>>
Class::Meta is a Perl class automation, introspection, and data validation.

SYNOPSIS

Generate a class:
package MyApp::Thingy;
use strict;
use Class::Meta;
use Class::Meta::Types::String;
use Class::Meta::Types::Numeric;

BEGIN {

# Create a Class::Meta object for this class.
my $cm = Class::Meta->new( key => thingy );

# Add a constructor.
$cm->add_constructor(
name => new,
create => 1,
);

# Add a couple of attributes with generated methods.
$cm->add_attribute(
name => uuid,
authz => Class::Meta::READ,
type => string,
required => 1,
default => sub { Data::UUID->new->create_str },
);
$cm->add_attribute(
name => name,
is => string,
required => 1,
default => undef,
);
$cm->add_attribute(
name => age,
is => integer,
default => undef,
);

# Add a custom method.
$cm->add_method(
name => chk_pass,
view => Class::Meta::PUBLIC,
);
$cm->build;
}
Then use the class:
use MyApp::Thingy;

my $thingy = MyApp::Thingy->new;
print "ID: ", $thingy->id, $/;
$thingy->name(Larry);
print "Name: ", $thingy->name, $/;
$thingy->age(42);
print "Age: ", $thingy->age, $/;
Or make use of the introspection API:
use MyApp::Thingy;

my $class = MyApp::Thingy->my_class;
my $thingy;

print "Examining object of class ", $class->package, $/;

print "nConstructors:n";
for my $ctor ($class->constructors) {
print " o ", $ctor->name, $/;
$thingy = $ctor->call($class->package);
}

print "nAttributes:n";
for my $attr ($class->attributes) {
print " o ", $attr->name, " => ", $attr->get($thingy), $/;
if ($attr->authz >= Class::Meta::SET && $attr->type eq string) {
$attr->get($thingy, hey there!);
print " Changed to: ", $attr->get($thingy), $/;
}
}

print "nMethods:n";
for my $meth ($class->methods) {
print " o ", $meth->name, $/;
$meth->call($thingy);
}

Class::Meta provides an interface for automating the creation of Perl classes with attribute data type validation. It differs from other such modules in that it includes an introspection API that can be used as a unified interface for all Class::Meta-generated classes. In this sense, it is an implementation of the "Facade" design pattern.

<<less
Download (0.060MB)
Added: 2006-10-05 License: Perl Artistic License Price:
1114 downloads
Class::InsideOut 1.02

Class::InsideOut 1.02


Class::InsideOut is a Perl module with a safe, simple inside-out object construction kit. more>>
Class::InsideOut is a Perl module with a safe, simple inside-out object construction kit.
SYNOPSIS
package My::Class;
use Class::InsideOut qw( public private register id );
public name => my %name; # accessor: name()
private age => my %age; # no accessor
sub new { register( shift ) }
sub greeting {
my $self = shift;
return "Hello, my name is $name{ id $self }";
}
This is a simple, safe and streamlined toolkit for building inside-out objects. Unlike most other inside-out object building modules already on CPAN, this module aims for minimalism and robustness:
- Does not require derived classes to subclass it
- Uses no source filters, attributes or CHECK blocks
- Supports any underlying object type including black-box inheritance
- Does not leak memory on object destruction
- Overloading-safe
- Thread-safe for Perl 5.8 or better
- mod_perl compatible
- Makes no assumption about inheritance or initializer needs
It provides the minimal support necessary for creating safe inside-out objects and generating flexible accessors.
<<less
Download (0.047MB)
Added: 2006-09-27 License: Perl Artistic License Price:
1122 downloads
Class::Agreement 0.02

Class::Agreement 0.02


Class::Agreement is a Perl module that add contracts to your Perl classes easily. more>>
Class::Agreement is a Perl module that add contracts to your Perl classes easily.

SYNOPSIS

package SomeClass;

use Class::Agreement;

# use base Class::Accessor or Class::MethodMaker,
# or roll your own:
sub new { ... }

invariant {
my ($self) = @_;
$self->count > 0;
};

precondition add_a_positive => sub {
my ( $self, $value ) = @_;
return ( $value >= 0 );
};
sub add_a_positive {
my ( $self, $value ) = @_;
...
}

sub choose_word {
my ( $self, $value ) = @_;
...
}
postcondition choose_word => sub {
return ( result >= 0 );
};

dependent increase_foo => sub {
my ( $self, $amount ) = @_;
my $old_foo = $self->foo;
return sub {
my ( $self, $amount ) = @_;
return ( $old_foo < $self->get_foo );
}
};
sub increase_foo {
my ( $self, $amount ) = @_;
$self->set_foo( $self->get_foo + $amount );
}

Class::Agreement is an implementation of behavioral contracts for Perl5. This module allows you to easily add pre- and postconditions to new or existing Perl classes.
This module provides contracts such as dependent contracts, contracts for higher-order functions, and informative messages when things fail.

At the time of this writing, Class::Agreement is one of only two contract implementations that blames contract-breaking components correctly. (See: "Object-oriented Programming Languages Need Well-founded Contracts" at http://citeseer.ist.psu.edu/findler01objectoriented.html.)
Using Class::Agreement lets you specify proper input and output of your functions or methods, thus strengthening your code and allowing you to spot bugs earlier.

<<less
Download (0.027MB)
Added: 2007-02-28 License: Perl Artistic License Price:
968 downloads
Rauls classes for PHP 0.6.3

Rauls classes for PHP 0.6.3


Rauls classes for PHP is an OOP database abstraction layer for PHP 5.1 or greater. more>>
Rauls classes for PHP is an OOP database abstraction layer for PHP 5.1 or greater. Rauls classes for PHP provides abstract classes to access database servers and traverse result sets.
There are several implementation classes to access different types of databases: SQLite, MySQL, PostgreSQL, and MSSQL.
The classes provide functions to establish connections, execute queries, traverse result sets with pagination support, and retrieve the list of databases, tables and fields. Any possible error is signaled by throwing exceptions with specific message and error code.
Enhancements:
- A quickref.txt file was added to the project.
- A totalRows get property was included for SQL result objects.
- A third optional parameter was added to the printPageSelect method in order to return the page < select > code as an string instead of printing it.
<<less
Download (0.050MB)
Added: 2006-06-08 License: MIT/X Consortium License Price:
1235 downloads
Class::Spiffy 0.15

Class::Spiffy 0.15


Class::Spiffy is a Spiffy Framework with No Source Filtering. more>>
Class::Spiffy is a Spiffy Framework with No Source Filtering.

SYNOPSIS

package Keen;
use strict;
use warnings;
use Class::Spiffy -base;
field mirth;
const mood => :-);

sub happy {
my $self = shift;
if ($self->mood eq :-() {
$self->mirth(-1);
print "Cheer up!";
}
super;
}

1;

"Class::Spiffy" is a framework and methodology for doing object oriented (OO) programming in Perl. Class::Spiffy combines the best parts of Exporter.pm, base.pm, mixin.pm and SUPER.pm into one magic foundation class. It attempts to fix all the nits and warts of traditional Perl OO, in a clean, straightforward and (perhaps someday) standard way.

Class::Spiffy borrows ideas from other OO languages like Python, Ruby, Java and Perl 6. It also adds a few tricks of its own.

If you take a look on CPAN, there are a ton of OO related modules. When starting a new project, you need to pick the set of modules that makes most sense, and then you need to use those modules in each of your classes. Class::Spiffy, on the other hand, has everything youll probably need in one module, and you only need to use it once in one of your classes. If you make Class::Spiffy the base class of the basest class in your project, Class::Spiffy will automatically pass all of its magic to all of your subclasses. You may eventually forget that youre even using it!

The most striking difference between Class::Spiffy and other Perl object oriented base classes, is that it has the ability to export things. If you create a subclass of Class::Spiffy, all the things that Class::Spiffy exports will automatically be exported by your subclass, in addition to any more things that you want to export. And if someone creates a subclass of your subclass, all of those things will be exported automatically, and so on. Think of it as "Inherited Exportation", and it uses the familiar Exporter.pm specification syntax.
To use Class::Spiffy or any subclass of Class::Spiffy as a base class of your class, you specify the -base argument to the use command.

use MySpiffyBaseModule -base;

You can also use the traditional use base MySpiffyBaseModule; syntax and everything will work exactly the same. The only caveat is that Class::Spiffy must already be loaded. Thats because Class::Spiffy rewires base.pm on the fly to do all the Spiffy magics.

Class::Spiffy has support for Ruby-like mixins with Perl6-like roles. Just like base you can use either of the following invocations:

use mixin MySpiffyBaseModule;
use MySpiffyBaseModule -mixin;

The second version will only work if the class being mixed in is a subclass of Class::Spiffy. The first version will work in all cases, as long as Class::Spiffy has already been loaded.

To limit the methods that get mixed in, use roles. (Hint: they work just like an Exporter list):

use MySpiffyBaseModule -mixin => qw(:basics x y !foo);

A useful feature of Class::Spiffy is that it exports two functions: field and const that can be used to declare the attributes of your class, and automatically generate accessor methods for them. The only difference between the two functions is that const attributes can not be modified; thus the accessor is much faster.

One interesting aspect of OO programming is when a method calls the same method from a parent class. This is generally known as calling a super method. Perls facility for doing this is butt ugly:

sub cleanup {
my $self = shift;
$self->scrub;
$self->SUPER::cleanup(@_);
}

Class::Spiffy makes it, er, super easy to call super methods. You just use the super function. You dont need to pass it any arguments because it automatically passes them on for you. Heres the same function with Class::Spiffy:

sub cleanup {
my $self = shift;
$self->scrub;
super;
}

Class::Spiffy has a special method for parsing arguments called parse_arguments, that it also uses for parsing its own arguments. You declare which arguments are boolean (singletons) and which ones are paired, with two special methods called boolean_arguments and paired_arguments. Parse arguments pulls out the booleans and pairs and returns them in an anonymous hash, followed by a list of the unmatched arguments.

Finally, Class::Spiffy can export a few debugging functions WWW, XXX, YYY and ZZZ. Each of them produces a YAML dump of its arguments. WWW warns the output, XXX dies with the output, YYY prints the output, and ZZZ confesses the output. If YAML doesnt suit your needs, you can switch all the dumps to Data::Dumper format with the - dumper option.

<<less
Download (0.024MB)
Added: 2007-06-19 License: Perl Artistic License Price:
857 downloads
classes::Test 0.942

classes::Test 0.942


classes::Test are functions to help with classes pragma testing. more>>
classes::Test are functions to help with classes pragma testing.

SYNOPSIS

can_new
can_set_get
has_decl
has_class_const
has_mixins
has_mixins_hash

is_classes MyClass;
is_classes main;

is_throwable X::Mine;
is_classes_exc X::Mine;

Generic tests based on Test::Builder designed to help write unit tests for code that uses the classes pragma.

<<less
Download (0.16MB)
Added: 2006-10-31 License: Perl Artistic License Price:
1088 downloads
Perl6::Classes 0.22

Perl6::Classes 0.22


Perl6::Classes project contains first class classes in Perl 5. more>>
Perl6::Classes project contains first class classes in Perl 5.

SYNOPSIS

use Perl6::Classes;

class Composer {
submethod BUILD { print "Giving birth to a new composern" }
method compose { print "Writing some music...n" }
}

class ClassicalComposer is Composer {
method compose { print "Writing some muzak...n" }
}

class ModernComposer is Composer {
submethod BUILD($) { $.length = shift }
method compose() { print((map { int rand 10 } 1..$.length), "n") }
has $.length;
}

my $beethoven = new ClassicalComposer;
my $barber = new ModernComposer 4;
my $mahler = ModernComposer->new(400);

$beethoven->compose; # Writing some muzak...
$barber->compose # 7214
compose $mahler; # 89275869347968374698756....

Perl6::Classes allows the creation of (somewhat) Perl 6-style classes in Perl 5. The following features are currently supported:

subs, methods, and submethods
And their respective scoping rules.

Attributes
Which are available through the has keyword, and look like $.this.

Inheritance
Both single and multiple inheritance are available through the is keyword.

Signatures
Signatures on methods, subs, and submethods are supported, but just the Perl 5 kind.

Data hiding
Using the public, protected, and private traits, you can enforce (run-time) data hiding. This is not supported on attributes, which are always private.

Anonymous classes
That respect closures. You can now nest them inside methods of other classes, even other anonymous ones!

The Perl6::Classes module augments Perls syntax with a new declarator: class. It offers the advantage over Perls standard OO mechanism that it is conceptually easier to see (especially for those from a C++/Java background). It offers the disadvantage, of course, of being less versatile.

<<less
Download (0.007MB)
Added: 2007-06-08 License: Perl Artistic License Price:
868 downloads
Class::Declare 0.08

Class::Declare 0.08


Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods. more>>
Class::Declare is a Perl module created to declare classes with public, private and protected attributes and methods.

SYNOPSIS

package My::Class;

use strict;
use warnings;
use base qw( Class::Declare );

__PACKAGE__->declare(

public => { public_attr => 42 } ,
private => { private_attr => Foo } ,
protected => { protected_attr => Bar } ,
class => { class_attr => [ 3.141 ] }
static => { static_attr => { a => 1 } } ,
restricted => { restricted_attr => string } ,
abstract => abstract_attr ,
friends => main::trustedsub ,
new => [ public_attr , private_attr ] ,
init => sub { # object initialisation
...
1;
} ,
strict => 0

);

sub publicmethod {
my $self = __PACKAGE__->public( shift );
...
}

sub privatemethod {
my $self = __PACKAGE__->private( shift );
...
}

sub protectedmethod {
my $self = __PACKAGE__->protected( shift );
...
}

sub classmethod {
my $self = __PACKAGE__->class( shift );
...
}

sub staticmethod {
my $self = __PACKAGE__->static( shift );
...
}

sub restrictedmethod {
my $self = __PACKAGE__->restricted( shift );
...
}

sub abstractmethod { __PACKAGE__->abstract }

1;

...

my $obj = My::Class->new( public_attr => fish );

MOTIVATION

One of Perls greatest strengths is its flexible object model. You can turn anything (so long as its a reference, or you can get a reference to it) into an object. This allows coders to choose the most appropriate implementation for each specific need, and still maintain a consistent object oriented approach.
A common paradigm for implementing objects in Perl is to use a blessed hash reference, where the keys of the hash represent attributes of the class. This approach is simple, relatively quick, and trivial to extend, but its not very secure. Since we return a reference to the hash directly to the user they can alter hash values without using the classs accessor methods. This allows for coding "short-cuts" which at best reduce the maintainability of the code, and at worst may introduce bugs and inconsistencies not anticipated by the original module author.

On some systems, this may not be too much of a problem. If the developer base is small, then we can trust the users of our modules to Do The Right Thing. However, as a modules user base increases, or the complexity of the systems our modules are embedded in grows, it may become desirable to control what users can and cant access in our module to guarantee our codes behaviour. A traditional method of indicating that an objects data and methods are for internal use only is to prefix attribute and method names with underscores. However, this still relies on the end user Doing The Right Thing.

Class::Declare provides mechanisms for module developers to explicitly state where and how their class attributes and methods may be accessed, as well as hiding the underlying data store of the objects to prevent unwanted tampering with the data of the objects and classes. This provides a robust framework for developing Perl modules consistent with more strongly-typed object oriented languages, such as Java and C++, where classes provide public, private, and protected interfaces to object and class data and methods.

<<less
Download (0.075MB)
Added: 2007-06-20 License: Perl Artistic License Price:
856 downloads
Class::MOP 0.35

Class::MOP 0.35


Class::MOP is a Meta Object Protocol for Perl 5. more>>
Class::MOP is a Meta Object Protocol for Perl 5.

SYNOPSIS

# ... This will come later, for now see
# the other SYNOPSIS for more information

This module is an attempt to create a meta object protocol for the Perl 5 object system. It makes no attempt to change the behavior or characteristics of the Perl 5 object system, only to create a protocol for its manipulation and introspection.

That said, it does attempt to create the tools for building a rich set of extensions to the Perl 5 object system. Every attempt has been made for these tools to keep to the spirit of the Perl 5 object system that we all know and love.

This documentation is admittedly sparse on details, as time permits I will try to improve them. For now, I suggest looking at the items listed in the "SEE ALSO" section for more information. In particular the book "The Art of the Meta Object Protocol" was very influential in the development of this system.

What is a Meta Object Protocol?

A meta object protocol is an API to an object system.

To be more specific, it is a set of abstractions of the components of an object system (typically things like; classes, object, methods, object attributes, etc.). These abstractions can then be used to both inspect and manipulate the object system which they describe.

It can be said that there are two MOPs for any object system; the implicit MOP, and the explicit MOP. The implicit MOP handles things like method dispatch or inheritance, which happen automatically as part of how the object system works. The explicit MOP typically handles the introspection/reflection features of the object system. All object systems have implicit MOPs, without one, they would not work. Explict MOPs however as less common, and depending on the language can vary from restrictive (Reflection in Java or C#) to wide open (CLOS is a perfect example).

<<less
Download (0.072MB)
Added: 2006-10-20 License: Perl Artistic License Price:
1099 downloads
Class::Contract 1.00

Class::Contract 1.00


Class::Contract - Design-by-Contract OO in Perl. more>>
Class::Contract - Design-by-Contract OO in Perl.

SYNOPSIS

package ClassName
use Class::Contract;

contract {
inherits BaseClass;

invar { ... };

attr data1;
attr data2 => HASH;

class attr shared => SCALAR;

ctor new;

method methodname;
pre { ... };
failmsg Error message;

post { ... };
failmsg Error message;

impl { ... };

method nextmethod;
impl { ... };

class method sharedmeth;
impl { ... };

# etc.
};

Background

Design-by-contract is a software engineering technique in which each module of a software system specifies explicitly what input (or data or arguments) it requires, and what output (or information or results) it guarantees to produce in response.

These specifications form the "clauses" of a contract between a module and the client software that uses it. If the client software abides by the input requirements, the module guarantees to produce the correct output. Hence by verifying these clauses at each interaction with a module, the overall behaviour of the system can be confidently predicted.
Design-by-contract reinforces the benefits of modular design techniques by inserting explicit compile-time or run-time checks on a contract. These checks are most often found in object-oriented languages and are typically implemented as pre-conditions and post-conditions on methods, and invariants on classes.

Note that these features differ from simple verification statements such as the C assert statement. Conditions and invariants are properties of a class, and are inherited by derived classes.

An additional capacity that is often provided in design-by-contract systems is the ability to selectively disable checking in production code. This allows the contractual testing to be carried out during implementation, without impinging on the performance of the final system.

Adding design-by-contract to Perl

The Class::Contract module provides a framework for specifying methods and attributes for a class (much like the existing class definition modules Class::Struct, Class::MethodMaker, and Class::Generate). Class::Contract allows both per-object and per-class methods and attributes to be defined. Attributes may be scalar-, array-, hash-, or object-based.

Class::Contract differs from other class-specification modules (except Class::Generate) in that it also provides the ability to specify invariant conditions on classes, and pre- and post-conditions on methods and attributes. All of these clauses are fully inheritable, and may be selectively disabled. It differs from all other modules in that it has a cleaner, simpler specification syntax, and -- more importantly -- it enforces encapsulation of object attributes, thereby ensuring that the class contract cannot be subverted.

Defining classes

Class::Contract provides an explicit syntax for defining the attributes, methods, and constructors of a class. The class itself is defined using the contract subroutine. contract takes a single argument -- a subroutine reference or a block. That block is executed once and the results used to construct and install the various components of the class in the current package:

package Queue;
contract {
# specification of class Queue attributes and methods here
};

<<less
Download (0.026MB)
Added: 2007-02-21 License: Perl Artistic License Price:
976 downloads
Class::Struct::FIELDS 1.1

Class::Struct::FIELDS 1.1


Class::Struct::FIELDS module combine Class::Struct, base and fields. more>>
Class::Struct::FIELDS module combine Class::Struct, base and fields.

SYNOPSIS

(This page documents Class::Struct::FIELDS v.1.1.)
use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name:
struct (CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });

use Class::Struct::FIELDS;
# declare struct, based on fields, explicit class name
# with inheritance:
struct (CLASS_NAME => [qw(BASE_CLASSES ...)],
{ ELEMENT_NAME => ELEMENT_TYPE, ... });

package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name:
struct (ELEMENT_NAME => ELEMENT_TYPE, ...);

package CLASS_NAME;
use Class::Struct::FIELDS;
# declare struct, based on fields, implicit class name
# with inheritance:
struct ([qw(BASE_CLASSES ...)], ELEMENT_NAME => ELEMENT_TYPE, ...);

package MyObj;
use Class::Struct::FIELDS;
# declare struct with four types of elements:
struct (s => $, a => @, h => %, x => &, c => My_Other_Class);

$obj = new MyObj; # constructor

# scalar type accessor:
$element_value = $obj->s; # element value
$obj->s (new value); # assign to element

# array type accessor:
$ary_ref = $obj->a; # reference to whole array
$ary_element_value = $obj->a->[2]; # array element value
$ary_element_value = $obj->a (2); # same thing
$obj->a->[2] = new value; # assign to array element
$obj->a (2, newer value); # same thing

# hash type accessor:
$hash_ref = $obj->h; # reference to whole hash
$hash_element_value = $obj->h->{x}; # hash element value
$hash_element_value = $obj->h (x); # same thing
$obj->h->{x} = new value; # assign to hash element
$obj->h (x, newer value); # same thing

# code type accessor:
$code_ref = $obj->x; # reference to code
$obj->x->(...); # call code
$obj->x (sub {...}); # assign to element

# regexp type accessor:
$regexp = $obj->r; # reference to code
$string =~ m/$obj->r/; # match regexp
$obj->r (qr/ ... /); # assign to element

# class type accessor:
$element_value = $obj->c; # object reference
$obj->c->method (...); # call method of object
$obj->c (My_Other_Class::->new); # assign a new object

Class::Struct::FIELDS exports a single function, struct. Given a list of element names and types, and optionally a class name and/or an array reference of base classes, struct creates a Perl 5 class that implements a "struct-like" data structure with inheritance.

The new class is given a constructor method, new, for creating struct objects.
Each element in the struct data has an accessor method, which is used to assign to the element and to fetch its value. The default accessor can be overridden by declaring a sub of the same name in the package. (See Example 2.)

Each elements type can be scalar, array, hash, code or class.

<<less
Download (0.018MB)
Added: 2007-07-11 License: Perl Artistic License Price:
835 downloads
Class::Inner 0.1

Class::Inner 0.1


Class::Inner is a perlish implementation of Java like inner classes. more>>
Class::Inner is a perlish implementation of Java like inner classes.

SYNOPSIS

use Class::Inner;

my $object = Class::Inner->new(
parent => ParentClass,
methods => { method => sub { ... } }, },
constructor => new,
args => [@constructor_args],
);

Yet another implementation of an anonymous class with per object overrideable methods, but with the added attraction of sort of working dispatch to the parent classs method.

METHODS

new HASH

Takes a hash like argument list with the following keys.

parent

The name of the parent class. Note that you can only get single inheritance with this or SUPER wont work.

methods

A hash, keys are method names, values are CODEREFs.

constructor

The name of the constructor method. Defaults to new.

args

An anonymous array of arguments to pass to the constructor. Defaults to an empty list.

Returns an object in an anonymous class which inherits from the parent class. This anonymous class has a couple of extra methods:

SUPER

If you were to pass something like

$obj = Class::Inner->new(
parent => Parent,
methods => { method => sub { ...; $self->SUPER::method(@_) } },
);

then $self-gtSUPER::method almost certainly wouldnt do what you expect, so we provide the SUPER method which dispatches to the parent implementation of the current method. There seems to be no good way of getting the full SUPER:: functionality, but Im working on it.

DESTROY

Because Class::Inner works by creating a whole new class name for your object, it could potentially leak memory if you create a lot of them. So we add a DESTROY method that removes the class from the symbol table once its finished with.

If you need to override a parents DESTROY method, adding a call to Class::Inner::clean_symbol_table(ref $self) to it. Do it at the end of the method or your other method calls wont work.

clean_symbol_table

The helper subroutine that DESTROY uses to remove the class from the symbol table.

new_classname

Returns a name for the next anonymous class.

<<less
Download (0.003MB)
Added: 2007-06-06 License: Perl Artistic License Price:
871 downloads
Class::Std 0.0.8

Class::Std 0.0.8


Class::Std is a Perl module to support for creating standard inside-out classes. more>>
Class::Std is a Perl module to support for creating standard "inside-out" classes.

SYNOPSIS

package MyClass;
use Class::Std;

# Create storage for object attributes...
my %name : ATTR;
my %rank : ATTR;
my %snum : ATTR;

my %public_data : ATTR;

# Handle initialization of objects of this class...
sub BUILD {
my ($self, $obj_ID, $arg_ref) = @_;

$name{$obj_ID} = check_name( $arg_ref->{name} );
$rank{$obj_ID} = check_rank( $arg_ref->{rank} );
$snum{$obj_ID} = _gen_uniq_serial_num();
}

# Handle cleanup of objects of this class...
sub DEMOLISH {
my ($self, $obj_ID) = @_;

_recycle_serial_num( $snum{$obj_ID} );
}

# Handle unknown method calls...
sub AUTOMETHOD {
my ($self, $obj_ID, @other_args) = @_;

# Return any public data...
if ( m/A get_(.*)/ ) { # Method name passed in $_
my $get_what = $1;
return sub {
return $public_data{$obj_ID}{$get_what};
}
}

warn "Cant call $method_name on ", ref $self, " object";

return; # The call is declined by not returning a sub ref
}

This module provides tools that help to implement the "inside out object" class structure in a convenient and standard way.

<<less
Download (0.030MB)
Added: 2006-09-26 License: Perl Artistic License Price:
1124 downloads
Class::Bits 0.05

Class::Bits 0.05


Class::Bits is a Perl module with class wrappers around bit vectors. more>>
Class::Bits is a Perl module with class wrappers around bit vectors.

SYNOPSIS

package MyClass;
use Class::Bits;

make_bits( a => 4, # 0..15
b => 1, # 0..1
c => 1, # 0..1
d => 2, # 0..3
e => s4 # -8..7
f => s1 # -1..0
);

package;

$o=MyClass->new(a=>12, d=>2);
print "o->b is ", $o->b, "n";

print "bit vector is ", unpack("h*", $$o), "n";

$o2=$o->new();
$o3=MyClass->new($string);

ABSTRACT

Class::Bits creates class wrappers around bit vectors.

Class::Bits defines classes using bit vectors as storage.
Object attributes are stored in bit fields inside the bit vector. Bit field sizes have to be powers of 2 (1, 2, 4, 8, 16 or 32).

There is a class constructor subroutine:

make_bits( field1 => size1, field2 => size2, ...)

exports in the calling package a ctor, accessor methods, some utility methods and some constants:

Sizes can be prefixed by s or u to define signedness of the field. Default is unsigned.

$class->new()

creates a new object with all zeros.

$class->new($bitvector)

creates a new object over $bitvector.

$class->new(%fields)

creates a new object and initializes its fields with the values in %fields.

$obj->new()

clones an object.

$obj->$field()
$obj->$field($value)

gets or sets the value of the bit field $field inside the bit vector.

$class->length
$obj->lenght

returns the size in bits of the bit vector used for storage.

$class->keys
$obj->keys

returns an array with the names of the object attributes

$obj->as_hash

returns a flatten hash with the object attributes, i.e.:
my %values=$obj->as_hash;

%INDEX

hash with offsets as used by vec perl operator (to get an offset in bits, the value has to be multiplied by the corresponding bit field size).

%SIZES

hash with bit field sizes in bits.

%SIGNED

hash with signedness of the fields

Bit fields are packed in the bit vector in the order specified as arguments to make_bits.

Bit fields are padded inside the bit vector, i.e. a class created like

make_bits(A=>1, B=>2, C=>1, D=>4, E=>8, F=>16);

will have the layout

AxBBCxxx DDDDxxxx EEEEEEEE xxxxxxxx FFFFFFFF FFFFFFFF

<<less
Download (0.004MB)
Added: 2007-07-30 License: Perl Artistic License Price:
816 downloads
Class::Classless 1.35

Class::Classless 1.35


Class::Classless is a Perl framework for classless OOP. more>>
Class::Classless is a Perl framework for classless OOP.

SYNOPSIS

use strict;
use Class::Classless;
my $ob1 = $Class::Classless::ROOT->clone;
$ob1->{NAME} = Ob1;
$ob1->{stuff} = 123;
$ob1->{Thing} = 789;

my $ob2 = $ob1->clone;
$ob2->{NAME} = Ob2;

printf "ob1 stuff: n", $ob1->{stuff};
printf "ob2 stuff: n", $ob2->{stuff};
printf "ob1 Thing: n", $ob1->{Thing};
printf "ob2 Thing: n", $ob2->{Thing};

$ob1->{METHODS}{zaz} = sub {
print "Zaz! on ", $_[0]{NAME}, "n";
};

$ob1->zaz;
$ob2->zaz;
$ob1->EXAMINE;
$ob2->EXAMINE;
This prints the following:
ob1 stuff: < 123 >
ob2 stuff: < 123 >
ob1 Thing: < 789 >
ob2 Thing: < >
Zaz! on Ob1
Zaz! on Ob2
< Class::Classless::X=HASH(0x200236f4) >
stuff, 123,
NAME, Ob1,
Thing, 789,
METHODS, { zaz, CODE(0x20068360) },
PARENTS, [ ROOT ],
< Class::Classless::X=HASH(0x2002cb48) >
stuff, 123,
NAME, Ob2,
METHODS, { },
PARENTS, [ Ob1 ],

In class-based OOP frameworks, methods are applicable to objects by virtue of objects belonging to classes that either provide those methods, or inherit them from classes that do.

In classless OOP frameworks (AKA delegation-and-prototypes frameworks), what methods an object is capable of is basically an attribute of that object. That is, in Perl terms: instead of methods being entries in the symbol table of the package/class the object belongs to, they are entries in a hash table inside the object. Inheritance is implemented not by having classes inheriting from other classes (via ISA lists), but by having objects inherit from other objects (via PARENTS lists).

In class-based OOP frameworks, you get new objects by calling constructors. In a classless framework, you get new objects by copying ("cloning") an existing object -- and the new clone becomes a child (inheritor) of the original object. (Where do you get the one original object? The language provides one, which has no parents, and which contains some general purpose methods like "clone".)

<<less
Download (0.023MB)
Added: 2007-07-19 License: Perl Artistic License Price:
827 downloads
Secleted [ 0 ] software to compare
  • Page: 1 of 5
  • 1
  • 2
  • 3
  • 4
  • 5