KinoSearch::Obj - Base class for all KinoSearch objects.
package MyObj; use base qw( KinoSearch::Obj ); # Inside-out member var. my %foo; sub new { my ( $class, %args ) = @_; my $foo = delete $args{foo}; my $self = $class->SUPER::new(%args); $foo{$$self} = $foo; return $self; } sub get_foo { my $self = shift; return $foo{$$self}; } sub DESTROY { my $self = shift; delete $foo{$$self}; $self->SUPER::DESTROY; }
All objects in the KinoSearch:: hierarchy descend from KinoSearch::Obj. All classes are implemented as blessed scalar references, with the scalar storing a pointer to a C struct.
The recommended way to subclass KinoSearch::Obj and its descendants is to use the inside-out design pattern. (See Class::InsideOut for an introduction to inside-out techniques.)
Since the blessed scalar stores a C pointer value which is unique per-object, $$self can be used as an inside-out ID.
$$self
# Accessor for 'foo' member variable. sub get_foo { my $self = shift; return $foo{$$self}; }
Caveats:
Inside-out aficionados will have noted that the "cached scalar id" stratagem recommended above isn't compatible with ithreads -- but KinoSearch doesn't support ithreads anyway, so it doesn't matter.
Abstract constructor -- must be invoked via a subclass. Attempting to instantiate objects of class "KinoSearch::Obj" directly causes an error.
Takes no arguments; if any are supplied, an error will be reported.
All KinoSearch classes implement a DESTROY method; if you override it in a subclass, you must call $self->SUPER::DESTROY to avoid leaking memory.
$self->SUPER::DESTROY
Generic stringification: "ClassName@hex_mem_address".
Indicate whether two objects are the same. By default, compares the memory address.
other - Another Obj.
Return a representation of the object using only scalars, hashes, and arrays. Some implementations support JSON serialization via dump() and its companion method, load(); for others, dump() is only a debugging aid. The default simply calls to_string().
Convert the object to a 64-bit integer.
Convert the object to a double precision floating point number.
Create an object from the output of a call to dump(). Implementations should not reference the caller.
dump - The output of dump().
Copyright 2005-2009 Marvin Humphrey
See KinoSearch version 0.30.
To install KSx::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm KSx::Simple
CPAN shell
perl -MCPAN -e shell install KSx::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.