NAME

NetSDS::Class::Abstract - superclass for all NetSDS APIs

SYNOPSIS

package MyClass;
use base 'NetSDS::Class::Abstract';

__PACKAGE__->mk_accessors(qw/my_field/);

sub error_sub {
	my ($this) = @_;
	if (!$this->my_field) {
		return $this->error("No my_field defined");
	}
}

1;

DESCRIPTION

NetSDS::Class::Abstract is a superclass for all other NetSDS classes, containing the following functionality:

  • common class constructor

  • safe modules inclusion

  • class and objects accessors and cloning;

  • error handling;

All other class/object APIs should inherit this class to use it's functionality in standard way.

CONSTRUCTOR, INITIALIZATION, APPLICATION

new([...])

Common constructor for NetSDS classes.

my $object = NetSDS::SomeClass->new(%options);

Constructor may be overwriten in inherited classes and usually is. Parameters for constructor may be given as hash or hash reference.

mk_class_var(@variables)
Class->mk_class_var(@variables);

This creates accessor/mutator methods for each named class variable.

use_modules(ARRAY)

Invoke modules from list given in parameters.

Return TRUE in case of success or FALSE if failed.

unbless()

Return non object copy of object data structure.

$copy = $obj->unbless();
$same = $obj->unbless( 1 );
serialize() - returns serialized object

This method returns serialized copy of object.

deserialize($serialized) - returns deserialized object

Paramters: serialized object as string

Returns: object

my $obj = NetSDS::SomeClass->deserialize($str);
nstore($file_name) - store serialized object

Save serialized object to file

logger() - set logger handler

This method allows to set class logger (NetSDS::Logger object)

log($level, $message) - write log message

Paramters: log level, log message

$obj->log("info", "We still alive");
error_code($new_code) - set/get error code
if (error_occured()) {

	$this->error_code(1234); # secret error status
	return $this->error("Oops! We have a 1234 error!");

}

EXAMPLES

See samples directory and other NetSDS moduleis for examples of code.

BUGS

Unknown yet

SEE ALSO

Class::Accessor, Class::Accessor::Class, Clone, Class::ErrorHandler

TODO

None

AUTHOR

Michael Bochkaryov <misha@rattler.kiev.ua>