perfSONAR_PS::DataModels::APIBuilder - builder utils to build binding perl objects collection


perfSONAR_PS-Services-PingER documentation  | view source Contained in the perfSONAR_PS-Services-PingER distribution.

Index


NAME

Top

 perfSONAR_PS::DataModels::APIBuilder - builder utils to build binding perl objects collection

DESCRIPTION

Top

      single call is here with several private ones
      the public call is:
      buildAPI(<top object name>, <top object>, <path>,<API root name>);

SYNOPSIS

Top

      ###
      use   perfSONAR_PS::DataModels::DataModel  qw($message); 
      use  perfSONAR_PS::DataModels::APIBuilderqw(&buildAPI  $API_ROOT $TOP_DIR $DATATYPES_ROOT) ;

      $API_ROOT = 'perfSONAR_PS';
      $TOP_DIR = "/tmp/API/" .$API_ROOT;   
      $DATATYPES_ROOT = 'Datatypes';

      buildAPI('message', $message, '','' );
      ####

API

Top

Exported variables

  $API_ROOT  - name of the  API  ( empty string by default)
  $TOP_DIR  - top dirname of the API location( /tmp/API by default)
  $DATATYPES_ROOT - dirname for schema datamodel files

buildAPI

   builds the whole API recursively

   accepts  four parameters
   - name of the root element - message by default
   - top hashref ( object to be built) 
   -   path ( empty by default )
   -   root API name ( empty by default )  

    


buildClass

   builds  single class on the filesystem and corresponded test file

   accepts  four parameters
     -   full  path to the class ( except for .pm extension)
     -   full  package  name  
     -   name of the   element 
     -   hashref with the element definition  
     -   hashref with parent definition if its not the root element

DESCRIPTION

Top

   Object representation of the $name element.
   Object fields are:
EOA
#------------------------------------------------------------------------------
map { print $fh   "    Scalar:     $_, \n"  }   @attributes ;
map { print $fh   "    Object reference:   " . $_->[0]  . " => type " . ref($_->[1]) . ",\n" }  @elements ;

  


   print $fh <<EOB;

   The constructor accepts only single parameter, it could be a hashref to parameters hash  or DOM with  '$name' element 

    


SYNOPSIS

Top

              use $className;

          my \$el =  $className->new(\$DOM_Obj);

METHODS

Top

new( )

      creates   object, accepts DOM with  element tree or hashref to the list of
      keyd parameters
EOD
map { print $fh   "         $_   => undef, \n"  }  @attributes ;
map { print $fh   "         " . $_->[0]  . " => " . ref($_->[1]) . ",\n"   }  @elementnodes;
print $fh "text => 'text'\n" if $element->{text};              

print $fh <<EOF;

getDOM (\$)

       accept parent DOM
       return $name object DOM, generated from object contents 

add$subname()

    if any of subelements can be an arrray then this method will provide
    facility to add another element to the  array and will return ref to such array
    or just set the element to a new one
=cut

sub add\u$subname { my \$self = shift; my \$new = shift; my \$logger = get_logger( \$CLASSPATH );

    \$self->$subname && ref(\$self->$subname) eq 'ARRAY'?push \@{\$self->$subname}, \$new:\$self->$subname([\$new]); 
    \$logger->debug("Added new to $subname"); 
    \$self->buildIdMap; ## rebuild index map 
    \$self->buildRefIdMap; ## rebuild ref index map  
    return \$self->$subname;
}

remove\u${subname}ById()

     remove specific element from the array of ${subname} elements by id ( if id is supported by this element )
     accepts single param - id - which is id attribute of the element
     if there is no array then it will return undef and warninig
     if it removed some id then \$id will be returned

get\u${subname}ById()

     get specific element from the array of ${subname} elements by id ( if id is supported by this element )
     accepts single param - id
     if there is no array then it will return just an object

querySQL ()

      depending on config  it will return some hash ref  to the initialized fields
    for example querySQL ()
    accepts one optional prameter - query hashref
    will return:
    { ip_name_src =>  'hepnrc1.hep.net' },}

merge

      merge with another $name ( append + overwrite if exists )
      we can do it differently
      method #1:
         convert to dom both objects and then get resulted object from combined dom 
      method #2 default:
         through the introspection of the object

buildIdMap()

    if any of subelements has id then get a map of it in form of
    hashref to { element}{id} = index in array and store in the idmap field

registerNamespaces ()

   will parse all subelements and register all namepspaces within the $name namespace

AUTHORS

Top

   Maxim Grigoriev (FNAL)  2007-2008, maxim\@fnal.gov


perfSONAR_PS-Services-PingER documentation  | view source Contained in the perfSONAR_PS-Services-PingER distribution.