classes and functions
Sponsored Links
Sponsored Links
Secleted [ 0 ] software to compare
Results 1 - 15 of about 5171
Database Functions 1.0
Database Functions is a PHP class that can be used to build and execute MySQL database queries. more>>
Database Functions is a PHP class that can be used to build and execute MySQL database queries.
It can build SELECT, INSERT, UPDATE and DELETE queries from lists of parameters and values.
The class can also execute the generated queries and retrieve the SELECT query results into associative arrays.
<<lessIt can build SELECT, INSERT, UPDATE and DELETE queries from lists of parameters and values.
The class can also execute the generated queries and retrieve the SELECT query results into associative arrays.
Download (MB)
Added: 2007-07-19 License: GPL (GNU General Public License) Price:
830 downloads
Data management and GTK functions 0.08
Data management and GTK functions is a package of various utility programs that were used in building applications. more>>
Data management and GTK functions is a package of various utility programs that were used in building the other applications on this web site.
The source code is already included with the other applications. This package includes documentation that will make it easier to use these programs for other projects. A menu-driven test program for most of the utilities is also included.
Main features:
- MatchWild compare a string to a string with multiple wildcards (* and ? characters)
- SearchWild search for files matching a pathname with wildcards anywhere
- convDS convert double to string with specified digits of precision
- bsearch binary search function
- HeapSort heapsort using a callback to compare records, allowing any kind of sort
- HashTab hash table C++ class (fast string store and search)
- Queue queue C++ class (push, pop newest, pop oldest) (thread safe)
- Tree C++ class, store and find data by set of names or numbers (sparse array)
- GTK menus build GTK menus and toolbars with 1/3 as much code
- zlock use GTK in threads more easily and safely
- wprintf printf interface to scrolling windows
- zdialog build GTK dialogs with 1/3 the code and 1/10 the reference docs
- pixbuf_rotate rotate a GDK pixbuf through any angle (like 56.7 degrees)
<<lessThe source code is already included with the other applications. This package includes documentation that will make it easier to use these programs for other projects. A menu-driven test program for most of the utilities is also included.
Main features:
- MatchWild compare a string to a string with multiple wildcards (* and ? characters)
- SearchWild search for files matching a pathname with wildcards anywhere
- convDS convert double to string with specified digits of precision
- bsearch binary search function
- HeapSort heapsort using a callback to compare records, allowing any kind of sort
- HashTab hash table C++ class (fast string store and search)
- Queue queue C++ class (push, pop newest, pop oldest) (thread safe)
- Tree C++ class, store and find data by set of names or numbers (sparse array)
- GTK menus build GTK menus and toolbars with 1/3 as much code
- zlock use GTK in threads more easily and safely
- wprintf printf interface to scrolling windows
- zdialog build GTK dialogs with 1/3 the code and 1/10 the reference docs
- pixbuf_rotate rotate a GDK pixbuf through any angle (like 56.7 degrees)
Download (0.21MB)
Added: 2007-07-26 License: GPL (GNU General Public License) Price:
821 downloads
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.
<<lessSYNOPSIS
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.
Download (0.16MB)
Added: 2006-10-31 License: Perl Artistic License Price:
1088 downloads
Bio::NEXUS::Functions 0.67
Bio::NEXUS::Functions is a Perl module that provides private utility functions for the module. more>>
Bio::NEXUS::Functions is a Perl module that provides private utility functions for the module.
This package provides private functions that are not object-specific.
<<lessThis package provides private functions that are not object-specific.
Download (0.15MB)
Added: 2006-12-19 License: Perl Artistic License Price:
1039 downloads
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.
<<lessThere 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.
Download (0.050MB)
Added: 2006-06-08 License: MIT/X Consortium License Price:
1235 downloads
Class::Accessor::Named 0.005
Class::Accessor::Named is a great way to automate the tedious task of generating accessors and mutators. more>>
Class::Accessor::Named is a great way to automate the tedious task of generating accessors and mutators. One small drawback is that due to the details of the implemenetation, you only get one "__ANON__" entry in profiling output.
That entry contains all your accessors, which can be a real pain if youre attempting to figure out _ w_ h_ i_ c_ h of your accessors is being called six billion times.
This module is a development aid which uses Hook::LexWrap and Sub::Name to talk your accessors into identifying themselves. While it shouldnt add much additional runtime overhead (as it acts only Class::Accessors generator functions), it has not been designed for production deployment.
<<lessThat entry contains all your accessors, which can be a real pain if youre attempting to figure out _ w_ h_ i_ c_ h of your accessors is being called six billion times.
This module is a development aid which uses Hook::LexWrap and Sub::Name to talk your accessors into identifying themselves. While it shouldnt add much additional runtime overhead (as it acts only Class::Accessors generator functions), it has not been designed for production deployment.
Download (0.020MB)
Added: 2006-09-06 License: Perl Artistic License Price:
1143 downloads
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.
<<lessSYNOPSIS
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.
Download (0.007MB)
Added: 2007-06-08 License: Perl Artistic License Price:
868 downloads
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.
<<lessSYNOPSIS
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.
Download (0.027MB)
Added: 2007-02-28 License: Perl Artistic License Price:
968 downloads
Class::Adapter::Builder 1.02
Class::Adapter::Builder is a Perl module that can generate Class::Adapter classes. more>>
Class::Adapter::Builder is a Perl module that can generate Class::Adapter classes.
SYNOPSIS
package My::Adapter;
use strict;
use Class::Adapter::Builder
ISA => Specific::API,
METHODS => [ qw{foo bar baz} ],
method => different_method;
1;
Class::Adapter::Builder is another mechanism for letting you create Adapter classes of your own.
It is intended to act as a toolkit for generating the guts of many varied and different types of Adapter classes.
For a simple base class you can inherit from and change a specific method, see Class::Adapter::Clear.
<<lessSYNOPSIS
package My::Adapter;
use strict;
use Class::Adapter::Builder
ISA => Specific::API,
METHODS => [ qw{foo bar baz} ],
method => different_method;
1;
Class::Adapter::Builder is another mechanism for letting you create Adapter classes of your own.
It is intended to act as a toolkit for generating the guts of many varied and different types of Adapter classes.
For a simple base class you can inherit from and change a specific method, see Class::Adapter::Clear.
Download (0.024MB)
Added: 2006-10-06 License: Perl Artistic License Price:
1114 downloads
Class::Maker 0.05.18
Class::Maker Perl module contains classes, reflection, schema, serialization, attribute- and multiple inheritance. more>>
Class::Maker Perl module contains classes, reflection, schema, serialization, attribute- and multiple inheritance.
SYNOPSIS
use Class::Maker qw(class);
class Human, { isa => [qw( ParentClass )],
public =>
{
string => [qw(name lastname)],
ref => [qw(father mother)],
array => [qw(friends)],
custom => [qw(anything)],
},
private =>
{
int => [qw(dummy1 dummy2)],
},
configure =>
{
ctor => create,
explicit => 0,
},
};
sub Human::greeting : method { my $this = shift;
printf This is %s (%d), $this->name, $this->uid;
}
class UnixUser, { isa => [qw( Human )],
public =>
{
int => [qw(uid gid)],
string => [qw(username)],
},
};
my $a = Human->new( uid => 1, gid => 2, name => Bart );
$a->father( Human->new( name => Houmer ) );
$a->greeting();
$a->uid = 12;
$a->_dummy1( bla );
Class::Maker introduces the concept of classes via a "class" function. It automatically creates packages, ISA, new and attribute-handlers. The classes can inherit from common perl-classes and class-maker classes. Single and multiple inheritance is supported.
This package is for everybody who wants to program oo-perl and does not really feel comfortable with the common way.
Java-like reflection is also implemented and allows one to inspect the class properties and methods during runtime. This is helpfull for implementing persistance and serialization. A Tangram (see cpan) schema generator is included to the package, so one can use Tangram object-persistance on the fly as long as he uses Class::Maker classes.
<<lessSYNOPSIS
use Class::Maker qw(class);
class Human, { isa => [qw( ParentClass )],
public =>
{
string => [qw(name lastname)],
ref => [qw(father mother)],
array => [qw(friends)],
custom => [qw(anything)],
},
private =>
{
int => [qw(dummy1 dummy2)],
},
configure =>
{
ctor => create,
explicit => 0,
},
};
sub Human::greeting : method { my $this = shift;
printf This is %s (%d), $this->name, $this->uid;
}
class UnixUser, { isa => [qw( Human )],
public =>
{
int => [qw(uid gid)],
string => [qw(username)],
},
};
my $a = Human->new( uid => 1, gid => 2, name => Bart );
$a->father( Human->new( name => Houmer ) );
$a->greeting();
$a->uid = 12;
$a->_dummy1( bla );
Class::Maker introduces the concept of classes via a "class" function. It automatically creates packages, ISA, new and attribute-handlers. The classes can inherit from common perl-classes and class-maker classes. Single and multiple inheritance is supported.
This package is for everybody who wants to program oo-perl and does not really feel comfortable with the common way.
Java-like reflection is also implemented and allows one to inspect the class properties and methods during runtime. This is helpfull for implementing persistance and serialization. A Tangram (see cpan) schema generator is included to the package, so one can use Tangram object-persistance on the fly as long as he uses Class::Maker classes.
Download (0.048MB)
Added: 2007-06-01 License: Perl Artistic License Price:
879 downloads
std_utils 0.7.5
std_utils is a small library of utility functions and classes. more>>
std_utils is a small library of utility functions and classes.
std_utils library supports string operations such as a stripper of leading or trailing characters and tokenizer, and a configuration file parser.
Enhancements:
- A type to throw exceptions on cConfig was added.
- An isKey() function was added to cConfig.
- The documentation was completed. cLog was removed as you can get the same behavior using fstream with "flush" at the end, which is more efficient.
- The deprecated gettok() was removed.
- A reentrant version of gettok was included to avoid copies.
- "stdu" was added as an alias to the "std_util" namespace.
<<lessstd_utils library supports string operations such as a stripper of leading or trailing characters and tokenizer, and a configuration file parser.
Enhancements:
- A type to throw exceptions on cConfig was added.
- An isKey() function was added to cConfig.
- The documentation was completed. cLog was removed as you can get the same behavior using fstream with "flush" at the end, which is more efficient.
- The deprecated gettok() was removed.
- A reentrant version of gettok was included to avoid copies.
- "stdu" was added as an alias to the "std_util" namespace.
Download (0.20MB)
Added: 2006-01-06 License: GPL (GNU General Public License) Price:
1390 downloads
MRP::BaseClass 1.0
MRP Base Class 1.0 is an efficient base class for Perl objects that generates the class interface from a definition more>>
MRP Base Class 1.0 is an efficient base class for Perl objects that generates the class interface from a definition.
The aim of this package is to allow you to define a classes interface, and have perl generate all of the standard functions for you.
Major Features:
- Fields: Member access functions are auto-generated so that nowhere in your code do you ever directly access member variables.
- Package variables: Class functions are auto-generated to make package variables work like static class members.
- Default variables: The package variable an be made to act as the default value for a field of the same name.
- Delegation support: Simply specify which field is a delegate and which functions to delegate to it, and the glue code is auto-generated.
- Provide dramatically better error messages when methods or static functions can not be found. Try invoking the < C -w > flag. It even lists possible correct spellings of misspelled function names!
- The class definition in a BEGIN block is included at the end of the package. This allows the interface to be checked, and the code to be generated at compile time. This has the additional benefit that these checks are performed during a < C -c > compilation.
Requirements: Perl
<<less Added: 2009-06-10 License: Perl Artistic License Price: FREE
14 downloads
NamespaceSim 0.5.0
NamespaceSim project can be used to emulate class namespaces under PHP 5. more>>
NamespaceSim project can be used to emulate class namespaces under PHP 5.
It parses PHP code to extract namespace definition statements. The code is rewritten to emulate the namespace support in a way similar to the Java language namespace support.
This package implements new commands named package and import. The package command defines the package that a class belongs. The package name is prepended to the class names using PEAR class naming and directory conventions.
The import command indicates that the package should be imported for use in the PHP script on which the import command is used. Classes that are not found in the current script are looked in the imported namespaces.
Error mapping has been added since 0.4.0, which requires that caching is enabled. This features makes php errors in rewritten files point to the right place in the original file.
As of version 0.5.0 nsim supports namespaces in:
- class definition (w/inheritance & interfaces implementation)
- interface definition (w/inheritance)
- static class vars & functions
- class constants
- instanceof operator
- type hinting
<<lessIt parses PHP code to extract namespace definition statements. The code is rewritten to emulate the namespace support in a way similar to the Java language namespace support.
This package implements new commands named package and import. The package command defines the package that a class belongs. The package name is prepended to the class names using PEAR class naming and directory conventions.
The import command indicates that the package should be imported for use in the PHP script on which the import command is used. Classes that are not found in the current script are looked in the imported namespaces.
Error mapping has been added since 0.4.0, which requires that caching is enabled. This features makes php errors in rewritten files point to the right place in the original file.
As of version 0.5.0 nsim supports namespaces in:
- class definition (w/inheritance & interfaces implementation)
- interface definition (w/inheritance)
- static class vars & functions
- class constants
- instanceof operator
- type hinting
Download (MB)
Added: 2007-08-08 License: LGPL (GNU Lesser General Public License) Price:
810 downloads
Extend For JavaScript 1.1
Extend For JavaScript allows you to use traditional single-class inheritance in your JavaScript applications. more>>
Extend For JavaScript allows you to use traditional single-class inheritance in your JavaScript applications. Extend For JavaScript also gives you many advanced features such as runtime class modification, introspection, and change.
It is simple, and does not depend on any other library. It works well with Prototype, jQuery, or MochiKit.
Main features:
- Can be used as a drop-in replacement to the current Prototype Class.create function
- Flexible and reliable super-like functionality
- Rich class-meta information, such as the list of methods defined in class, and for each other method, a link to the class which declared it, and links to all subclasses.
- Dynamic reparenting, which allows to change an existing class parent class.
- Dynamic class change, when you want an object to change its class on the fly.
<<lessIt is simple, and does not depend on any other library. It works well with Prototype, jQuery, or MochiKit.
Main features:
- Can be used as a drop-in replacement to the current Prototype Class.create function
- Flexible and reliable super-like functionality
- Rich class-meta information, such as the list of methods defined in class, and for each other method, a link to the class which declared it, and links to all subclasses.
- Dynamic reparenting, which allows to change an existing class parent class.
- Dynamic class change, when you want an object to change its class on the fly.
Download (0.006MB)
Added: 2006-11-21 License: BSD License Price:
1070 downloads
Class::Meta::Declare 0.04
Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express. more>>
Class::Meta::Declare is a Perl module deprecated in favor of Class::Meta::Express.
SYNOPSIS
This was a first attempt at making a saner interface for Class::Meta. It is nicer, but Class::Meta::Express is nicer still. Go use that one.
package MyApp::Thingy;
use Class::Meta::Declare :all;
use Data::UUID;
Class::Meta::Declare->new(
meta => [
key => thingy,
accessors => $ACC_SEMI_AFFORDANCE,
],
attributes => [
pi => {
context => $CTXT_CLASS,
authz => $AUTHZ_READ,
default => 3.1415927,
},
id => {
authz => $AUTHZ_READ,
type => $TYPE_STRING,
default => sub { Data::UUID->new->create_str },
},
name => {
required => 1,
type => $TYPE_STRING,
default => No Name Supplied,
},
age => { type => $TYPE_INTEGER, },
],
methods => [
some_method => {
view => $VIEW_PUBLIC,
code => sub {
my $self = shift;
return [ reverse @_ ];
},
}
]
);
my $object = MyApp::Thingy->new;
print MyApp::Thingy->pi; # prints 3.1415927
print $object->name; # prints "No Name Supplied;
$object->set_name("bob");
print $object->name; # prints "bob"
This class provides an alternate interface for Class::Meta.
Class::Meta is a useful module which allows one to create Perl classes which support introspection (also known as reflection). Typically Perl classes, when created, dont supply a lot of metadata. Imported helper functions show up when you call $object->can($method). Private, protected and trusted methods are not readily supported. Fetching a list of attributes or methods is a haphazard affair. Class::Meta overcomes these shortcomings by building the classes for you and allowing you to fetch a class object:
my $class_object = $object->my_class;
foreach my $attribute ( $class_object->attributes ) {
print $attribute->name, "n";
}
foreach my $method ( $class_object->methods ) {
print $method->name, "n";
}
If youve set up your class correctly, these properties are now easy to discover.
Unfortunately, many find the Class::Meta interface to be a bit clumsy. As an alternative, Class::Meta::Declare allows you to declare your entire class in a single argument list to the constructor and have the class built for you automatically. Further, reasonable defaults are provided for just about everything.
IMPORTANT: You want this class or Class::Meta if you need an introspection API for your classes. If you do not need introspection or dynamic class generation, these modules are overkill.
<<lessSYNOPSIS
This was a first attempt at making a saner interface for Class::Meta. It is nicer, but Class::Meta::Express is nicer still. Go use that one.
package MyApp::Thingy;
use Class::Meta::Declare :all;
use Data::UUID;
Class::Meta::Declare->new(
meta => [
key => thingy,
accessors => $ACC_SEMI_AFFORDANCE,
],
attributes => [
pi => {
context => $CTXT_CLASS,
authz => $AUTHZ_READ,
default => 3.1415927,
},
id => {
authz => $AUTHZ_READ,
type => $TYPE_STRING,
default => sub { Data::UUID->new->create_str },
},
name => {
required => 1,
type => $TYPE_STRING,
default => No Name Supplied,
},
age => { type => $TYPE_INTEGER, },
],
methods => [
some_method => {
view => $VIEW_PUBLIC,
code => sub {
my $self = shift;
return [ reverse @_ ];
},
}
]
);
my $object = MyApp::Thingy->new;
print MyApp::Thingy->pi; # prints 3.1415927
print $object->name; # prints "No Name Supplied;
$object->set_name("bob");
print $object->name; # prints "bob"
This class provides an alternate interface for Class::Meta.
Class::Meta is a useful module which allows one to create Perl classes which support introspection (also known as reflection). Typically Perl classes, when created, dont supply a lot of metadata. Imported helper functions show up when you call $object->can($method). Private, protected and trusted methods are not readily supported. Fetching a list of attributes or methods is a haphazard affair. Class::Meta overcomes these shortcomings by building the classes for you and allowing you to fetch a class object:
my $class_object = $object->my_class;
foreach my $attribute ( $class_object->attributes ) {
print $attribute->name, "n";
}
foreach my $method ( $class_object->methods ) {
print $method->name, "n";
}
If youve set up your class correctly, these properties are now easy to discover.
Unfortunately, many find the Class::Meta interface to be a bit clumsy. As an alternative, Class::Meta::Declare allows you to declare your entire class in a single argument list to the constructor and have the class built for you automatically. Further, reasonable defaults are provided for just about everything.
IMPORTANT: You want this class or Class::Meta if you need an introspection API for your classes. If you do not need introspection or dynamic class generation, these modules are overkill.
Download (0.015MB)
Added: 2006-09-27 License: Perl Artistic License Price:
1122 downloads
Secleted [ 0 ] software to compare
Copyright Notice:
Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future software development. The above classes and functions search only lists software in full, demo and trial versions for free download. Download links are directly from our mirror sites or publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed