CBAIS::Actions::Action - Base class for all CBAIS Actions
require CBAIS:Actions::Action;
$action = CBAIS::Actions::Action->new;
if ($action->check()
&& $action->execute())
{
print $action->toString(), " succeeded\n";
}
else
{
print "Error : ", $action->errormessage();
}
The CBAIS::Action::Actions class is the base class for all CBAIS Actions. It
defines an interface for checking, executing, verifying, and undoing an
action to a machine. All action methods (check, execute, verify, undo) return
1 on success and 0 on failure. The getErrorMessage method may be used to
obtain information text on the cause of the error.
The Action interface defines the following abstract following methods which
should be implemented derived classes.
check()
abstract
-
Check that the action is able to be executed. Returns 1 for success,
otherwise 0. The fact that an action passes its check test does not
necessarily mean it will complete successfully. Some conditions can only be
tested by executing the action. Implementors of this method should only
check conditions which do not depend on a live install (e.g the existence of
a source file in a copy, but not its target directory).
execute()
abstract
-
Carry out this action. This action should perform whatever tasks are required
to ``execute'' this action. If the action is succssfully executed, the value 1
should be returned. Otherwise the value 0 should be returned and the
ERROR_MESSAGE variable be set to some suiteable status text.
verify()
abstract
-
verify that this action has been performed. Return 1 if it has, otherwise
0. The getErrorMessage method may be used to get the error message if a 0
value is returned.
undo()
-
This method is optional. If implemented it should provide the ability to undo
whatever actions the execute method carries out. This base class method prints
an error message and returns a 0 value, indicating that the undo action was
not carried out.
The following methods are provided to help implementors of the
CBAISS::Actions::Action interface.
new()
-
Base class constructor. Sets up error message holder.
check_keys()
hashref, key list
-
check that all of the specified keys are defined in this object (this hash).
getErrorMessage()
-
return the current value of this actions error message.
setInstallRoot()
variable ..
-
Check if CBAIS_INSTALL_ROOT is set. If so prepend it to the specified variables
in this object. Placed here for utility reasons.
serialise()
-
returns a string suitable for subsequent evaling which stores the state of
this object.
deserialise()
string static (class) method
-
eval the specified string which is asumed to have been created with the
serialize method and attempt to create a CBAIS action object. Returns the
created object or 0;
loadFile()
filename static (class) method
-
Load the specified file and returns it. Handles text and binary
files. If the file is binary, a scalar is returned. If the file is text, it
is returned as an array.
toString()
-
return a string representation of this action suitable for printing.
end of documentation