/[cvs]/nfo/php/libs/org.netfrag.glib/Data/Lift.php
ViewVC logotype

Diff of /nfo/php/libs/org.netfrag.glib/Data/Lift.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Sat Feb 22 16:20:04 2003 UTC revision 1.3 by joko, Mon Mar 3 21:28:11 2003 UTC
# Line 3  Line 3 
3  //    $Id$  //    $Id$
4  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
5  //    $Log$  //    $Log$
6    //    Revision 1.3  2003/03/03 21:28:11  joko
7    //    updated comments
8    //
9    //    Revision 1.2  2003/02/27 16:30:17  joko
10    //    + enhanced '_autodetect'
11    //    + added '_check'
12    //    + now throughout returning lifted values by reference
13    //
14  //    Revision 1.1  2003/02/22 16:20:04  joko  //    Revision 1.1  2003/02/22 16:20:04  joko
15  //    + initial commit  //    + initial commit
16  //  //
17  //    -------------------------------------------------------------------------  //    -------------------------------------------------------------------------
18    
19    
20  //    Data::Lift  -  Pass data around between locations doing operations on it  //    Data::Lift  -  Pass data around between various "actors".
21    //
22    //    These "actors" are kinda plugin-modules
23    //    lying at "locations" and actually mungle the data.
24    //
25    //    "Locations" are by now:
26    //      x local filesystem
27    //      o remote anything
28    //
29    //    The "actors" require (by now) to be native php classes
30    //    having a method "perform". Please have a look at others
31    //    lying in the Data::Lift namespace at org.netfrag.glib to
32    //    get a picture of how to implement own "actors".
33    //
34    //    @url: http://cvs.netfrag.org/php/libs/org.netfrag.glib
35    //
36    //    TODO:
37    //      o refactor Data::Deep to a plugin module
38    //      o refactor Data::Encode to a plugin module
39    //      o combine Data::Lift and Data::Container somehow
40    //      o integrate with Data::Driver somehow  --  proposal:
41    //          $lift = new Data::Lift($locator);
42    //          $lift->perform();     // talks to a Data::Driver
43    //
44    
45    
46  class Data_Lift {  class Data_Lift {
# Line 38  class Data_Lift { Line 69  class Data_Lift {
69        
70    function set(&$payload, $metatype = '') {    function set(&$payload, $metatype = '') {
71      $this->payload = &$payload;      $this->payload = &$payload;
72        
73      if ($metatype) { $this->metatype = $metatype; }      if ($metatype) { $this->metatype = $metatype; }
74      $this->_autodetect();      $this->_autodetect();
75        $this->_check();
76    }    }
77        
78    function _autodetect() {    function _autodetect() {
79    
80      // FIXME: distinguish between is_array and is_hash here!      // FIXME: distinguish between is_array and is_hash here!
81      if (is_array($this->payload)) {      if (is_object($this->payload)) {
82          $this->vartype = 'object';
83          $this->metatype = get_class($this->payload);
84          if ($parent_class = get_parent_class($this->payload)) {
85            $this->metatype = $parent_class;
86          }
87    
88        } elseif (is_array($this->payload)) {
89        $this->vartype = 'hash';        $this->vartype = 'hash';
90    
91        } else {
92          $this->vartype = 'scalar';
93        
94        }
95      }
96      
97      function _check() {
98    
99        $good = $this->vartype && $this->metatype;
100        
101        //print "metatype: " . $this->metatype . "<br>";
102        
103        if (!$good) {
104          print "Data::Lift cannot handle this payload: ";
105          print "(vartype=" . $this->vartype . ", metatype=" . $this->metatype . ")<br/>";
106          print Dumper($this->payload);
107      }      }
108        
109    }    }
110        
111    function to($level) {    function &to($level) {
112      $this->_resolve_location($level);      $this->_resolve_location($level);
113      //print Dumper($this->actor);      //print Dumper($this->actor);
114      //exit;      //exit;
115      //$result = array( name => 'abc', description => 'def' );      //$result = array( name => 'abc', description => 'def' );
116      $result = $this->_perform_actor();      $result = &$this->_perform_actor();
117      return $result;      return $result;
118    }    }
119        
# Line 74  class Data_Lift { Line 133  class Data_Lift {
133            
134    }    }
135    
136    function _perform_actor() {    function &_perform_actor() {
137      //$actor_file = join('/', $this->actor) . '.php';      //$actor_file = join('/', $this->actor) . '.php';
138      //include($actor_file);      //include($actor_file);
139      $actor_name = 'Data/Lift/' . join('/', $this->actor);      $actor_name = 'Data/Lift/' . join('/', $this->actor);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.3

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed