Taxi::Mysql::Base - Extendable full-text index using mysql: base class


(Back to Top)


NAME

Taxi::Mysql::Base - Extendable full-text index using mysql: base class

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Taxi::Mysql::Base;
 ##========================================================================
 ## Constructors etc.
 $thingy = $CLASS_OR_OBJ->new(%args);
 $obj2 = $obj->clone();
 ##========================================================================
 ## Trace
 undef = $obj->trace(@msg);
 undef = $obj->trace1(@msg);
 ##========================================================================
 ## Verbose Messages
 undef = $obj->vmsg($level, @msg);
 undef = $obj->vmsg1($level, @msg);
 ##========================================================================
 ## I/O: Perl
 $rc = $obj->saveFile($filename_or_fh, @args);
 $rc = $obj->saveString($filename_or_fh, @args);
 $obj = $CLASS_OR_OBJ->loadFile($filename_or_fh, %args);
 $obj = $CLASS_OR_OBJ->loadString($str,%args);
 $tmpData = $obj->preSaveHook();
 undef = $obj->postSaveHook($tmpData);
 undef = $obj->postLoadHook();
 ##========================================================================
 ## I/O: Storable
 ($serialied) = STORABLE_freeze($obj, $cloning_flag);
 undef = STORABLE_thaw($obj, $cloning, $serialized);
 $bool = $obj->saveBinFile($filename_or_fh);
 $bool = $obj->loadBinFile($filename_or_fh);

(Back to Top)


DESCRIPTION

Taxi::Mysql::Base is a generic base class for persistent Taxi::Mysql objects.

Constructors etc.

new
 $thingy = $CLASS_OR_OBJ->new(%args);

Object structure / keyword %args:

   {
    ##-- logging
    logger  => $loggerClassOrObj,     ##-- logger class or object: see Taxi::Mysql::Logger
    ##-- verbosity behavior
    verbose => $vlevel,               ##-- default: 'default'
    ##-- trace (?)
    tracefh => $fh,                   ##-- filehandle for trace
    tracefile=>$filename,             ##-- perl file spec for trace (undef for no trace)
   }
clone
 $obj2 = $obj->clone();

Returns a deep copy of the object. Uses the Storable module.

DESTROY

Destructor.

Trace

trace
 undef = $obj->trace(@msg);

Appends @msg to the selected tracefile, if any.

trace1
 undef = $obj->trace1(@msg);

Appends a 1-line @msg to the selected tracefile, if any.

Verbose Messages

vmsg
 undef = $obj->vmsg($level, @msg);

Logs a verbose message @msg at log-level $level. @msg is only printed if $obj->{verbose} is at least $level. See Taxi::Mysql::Logger for details.

vmsg1
 undef = $obj->vmsg1($level, @msg);

Logs a 1-line verbose message @msg at $level, prefixed with package name, terminated with newline. See Taxi::Mysql::Logger for details.

I/O: Perl

saveFile
 $rc = $obj->saveFile($filename_or_fh, @args);

Calls ``$obj->saveString(@args)''.

loadFile
 $obj = $CLASS_OR_OBJ->loadFile($filename_or_fh, %args);

Calls $CLASS_OR_OBJ->loadString(var=>undef,src=>$filename_or_fh, %args).

preSaveHook
 $tmpData = $obj->preSaveHook();

User hook. Sanitizes object for save, returns temprorary data.

postSaveHook
 undef = $obj->postSaveHook($tmpData);

User hook. Should restore any data changed or altered by preSaveHook().

saveString
 $str = $obj->saveString(%args)

Saves $obj as a string of perl code. Uses Data::Dumper.

postLoadHook
 undef = $obj->postLoadHook();

User hook. Should call methods to perform post-load object initialization.

loadString
 $obj = $CLASS_OR_OBJ->loadString($str,%args);

Load object contents from a string of perl code. Recognized %args:

 var=>$perl_var_name, ##-- perl variable containing object reference after {eval $str} [default='$obj']
 src=>$src_name,      ##-- source name for error reporting; [default=(substr($str,0,42).'...')]
 %more_obj_args,      ##-- keywords to be literally inserted into $obj

I/O: Storable

STORABLE_freeze
 ($serialied) = STORABLE_freeze($obj, $cloning_flag);

For binary storage, calls preSaveHook() and postSaveHook().

STORABLE_thaw
 undef = STORABLE_thaw($obj, $cloning, $serialized);

For binary restoration, probably should call postLoadHook(), but currently doesn't (and there is probably a more or less good reason for this).

saveBinString

Wrapper for Storable::freeze().

loadBinString

Wrapper for Storable::thaw().

saveBinFile
 $bool = $obj->saveBinFile($filename_or_fh);

Wrapper for Storable::store() / Storable::store_fd().

loadBinFilew
 $bool = $obj->loadBinFile($filename_or_fh);

Wrapper for Storable::retrieve() / Storable::fd_retrieve().

(Back to Top)


ACKNOWLEDGEMENTS

Perl by Larry Wall.

(Back to Top)


AUTHOR

Bryan Jurish <moocow@ling.uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2006 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)


SEE ALSO

perl(1), Taxi::Mysql(3perl), Taxi::Mysql::Logger(3perl).

(Back to Top)

 Taxi::Mysql::Base - Extendable full-text index using mysql: base class