NAME
Fry::List - Base class serving as a container for its subclass's objects.
DESCRIPTION
This base class provides to its sub classes class methods for storing and accessing its objects. It also comes with a &new constructor which creates a hash-based object and stores it in the container or list.
Here are a few key points you should know:
- All objects must have a unique 'id' in the list.
- For now only one list of objects can be created per class.
This list is stored in &list. You must create a &list in the subclass
namespace to have a unique list.
- One alias to an object's id is supported via an 'a' attribute in an
object. Use &findAlias to get the aliased id.
- Default values for required attributes can be set via
&_hash_default.They will only be made and set if the attribute isn't
defined.
- Warnings in this class can be turned on and off by the variable $Fry::List::Warn
CLASS METHODS
new(%attr_to_value): Given hash is blessed as an object after setting defaults.
manyNew(%id_to_obj): Makes several objects.
Get and Set methods
obj($id,$object): Get and set an obj by id.
setObj(%id_to_obj): Set multiple objects with a hash of id to object pairs.
getObj(@ids): Gets several objects by id.
unloadObj(@ids): Unload/delete objects from list.
get($id,$attr): Gets an attribute value of the object specified by id.
set($id,$attr,$value): Sets an attribute value of the object specified by id.
getMany($attr,@ids): Gets same attribute of several objects
setMany($attr,%id_to_values): Sets same attribute of objects via a hash of object to attribute-value pairs.
Other methods
listIds(): Returns list of all object id's.
listAlias (): Returns list of all aliases of all objects.
listAliasAndIds (): Returns list of all aliases and all ids.
findAlias($alias): Returns id that alias points to. Returns undef if no id found.
anyAlias($alias): Wrapper around &findAlias which returns $alias instead.
pushArray($id,$attr,@values): Pushes values onto array stored in object's attribute.
objExists($id): Checks to see if object exists. Throws warning if it doesn't.
Subclassable subs
list: Returns a hash reference for holding all objects.
_hash_default: Returns a hash reference with default attributes and values.
AUTHOR
Me. Gabriel that is. I welcome feedback and bug reports to cldwalker AT chwhat DOT com . If you like using perl,linux,vim and databases to make your life easier (not lazier ;) check out my website at www.chwhat.com.
COPYRIGHT & LICENSE
Copyright (c) 2004, Gabriel Horner. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.