NAME

SIAM::Object - the base class for all SIAM object (including the root).

SYNOPSIS

INSTANCE METHODS

new

$new_object = new SIAM::Object($driver, $id)

Instantiates a new object. The method expects a driver object and an Object ID.

instantiate_object

Expects the object class and ID. Returns an object retrieved from the driver.

get_contained_objects

my $list = $object->get_contained_objects($classname, $options);

Fetches the list of contained objects of a given class. Returns arrayref of SIAM::Object instances. This is the preferred method of instantiating new objects instead of manually calling the new method.

It is assumed that the class name is already known to Perl, and the corresponding module was loaded with use or require.

Without the options, the method retrieves all available objects. Options may define a filter criteria as follows:

my $list =
  $siam->get_contained_objects('SIAM::Contract', {
      'match_attribute' => [ 'siam.object.access_scope_id',
                                ['SCOPEID01', 'SCOPEID02'] ]
    });

Currently only one filter condition is supported.

get_objects_by_attribute

my $list = $siam->get_objects_by_attribute(
     'SIAM::Device', 'siam.device.inventory_id', $id);

The method takes 3 arguments: class name, attribute name, and attribute value. It returns an arrayref of objects matching the attribute. Empty arrayref is returned if no objects match the criteria.

id

Returns a value of siam.object.id attribute

attr

$val = $contract->attr('siam.contract.inventory_id');

Returns a value of an attribute.

attributes

Returns a hashref with copies of all object attributes.

computable

$val = $contract->computable('siam.contract.content_md5hash');

Returns a value of a computable.

set_condition

$dataelement->set_condition('torrus.import_successful', 1);

The SIAM client application may use this method to send a (key, value) pair to the driver and tell it about some state update. The condition names and accepted values are defined by the driver and are driver-specific. This is a one-way communication, and there is no way to read the condition value.

is_root

Returns true if the object is a root.

is_predefined

Returns true if the object is a predefined object (the one with the ID starting with SIAM.)

contained_in

Returns the object that contains this object. Returns undef if container is the root object.

CLASS METHODS

validate_driver

Takes a driver object as an argument and verifies if it implements all required methods. returns true if all required methods are present. It issues error messages in case of missing methods.

set_log_manager

Sets a log manager for SIAM objects. Note that it does not set the log manager for the driver. The default log manager is a Log::Handler object with STDERR output of warnings and errors. The method expects one argument, an object which implements the following methods:

  • debug

  • info

  • warn

  • error

Classes that suit as log managers: Log::Handler, Log::Log4perl, ...

get_log_manager

Returns the current logger object.

debug, info, warn, error

These methods dispatch a message to the log manager. If the log manager is undefined, all except debug() print the message to STDERR with a preceeding timestamp.

PRIVATE METHODS

_driver

Returns the driver object

_print_stderr

Prints a message to STDERR with a preceeding timestamp