Dominique Dumont > Puppet-Body > Puppet::Body

Download:
Puppet-Body-1.018.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.015   Source  

NAME ^

Puppet::Body - Utility class to handle has-a relations and logs

SYNOPSIS ^

 use Puppet::Body ;

 package myClass ;
 sub new
  {
    my $type = shift ;
    my $self = {};
    $self->{body} = new Puppet::Body(cloth => $self, @_) ;
    bless $self,$type ;
  }

 sub body { return shift->{body} ;}

 package main ;

 # create a class with no persistent data
 my $foo = new myClass (Name => 'foo') ;

 # foo now has baz and buz
 $foo->body->acquire(body => $baz);
 $foo->body->acquire(body => $buz);

 # foo no longer has $baz
 $foo->body->drop($baz);

DESCRIPTION ^

Puppet::Body is a utility class that is used (and not inherited like the deprecated Puppet::Any) to manage dynamic has-a relations between objects.

This class provides the following features :

Constructor ^

new(...)

Creates new Puppet object. New() parameters are:

name

The name of your object (defaults to "anonymous1" or "anonymous2" ...)

cloth

The ref of your object

how

Specify how logs are to be handled. See "Constructor" in Puppet::LogBody

Generic methods ^

getName()

Returns the name of this object.

HAS-A relations management methods ^

acquire(...)

Acquire the object ref as a child. Parameters are:

body

Reference of the Puppet::Body object that is to be acquired.

name

Name to refer to the acquired Puppet::Body. Defaults to the name of the acquired Puppet::Body object.

For instance if object foo acquires object bar, bar becomes part of foo's content and foo is one of the container of bar.

drop('name')

Does the opposite of acquire(), i.e. drop the object named 'name'.

getContent('name',...)

In scalar context, it returns the Puppet::Body ref of the object 'name'. Returns undef if 'name' is not part of the content (i.e if it has not been 'acquired' before)

In array context, it returns an array of all Puppet::Body references of all passed names. Returns () if the object has no content.

getContainer('name',...)

Same as getContent for the container.

contentNames()

Returns all names of the content, i.e. of all 'acquired' objects.

containerNames()

Returns all names of the containers, i.e. of all objects that 'acquired' this object

Log management. ^

printDebug(text)

Will log the passed text into the debug and events log object.

printEvent(text)

Will log the passed text into the events log object.

About Puppet framework ^

Puppet framework is made of a set of utility classes. I currently use this framework for a major application Tk application.

If you use directly the Puppet::Body class, you get the plain functionnality. And if you use the Puppet::Show class, you can get the same functionnality and a Tk Gui to manage it.

AUTHOR ^

Dominique Dumont, Dominique_Dumont@grenoble.hp.com

Copyright (c) 1998-1999 Dominique Dumont. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO ^

perl, Puppet::Log, Puppet::Storage, Puppet::Show

syntax highlighting: