| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file contains the Data::Container class. |
| 4 |
* |
| 5 |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 6 |
* @package org.netfrag.glib |
| 7 |
* @name Data::Container |
| 8 |
* |
| 9 |
*/ |
| 10 |
|
| 11 |
/** |
| 12 |
* Cvs-Log: |
| 13 |
* |
| 14 |
* $Id: Container.php,v 1.3 2003/03/11 01:22:24 joko Exp $ |
| 15 |
* |
| 16 |
* $Log: Container.php,v $ |
| 17 |
* Revision 1.3 2003/03/11 01:22:24 joko |
| 18 |
* + fixed metadata for phpDocumentor |
| 19 |
* |
| 20 |
* Revision 1.2 2003/03/05 18:54:44 joko |
| 21 |
* updated docu - phpDocumentor is very strict about its 'blocks'... |
| 22 |
* |
| 23 |
* Revision 1.1 2003/03/03 21:27:28 joko |
| 24 |
* + initial commit |
| 25 |
* |
| 26 |
* Revision 1.2 2003/03/01 21:12:13 joko |
| 27 |
* new core methods |
| 28 |
* |
| 29 |
* Revision 1.1 2003/03/01 16:51:50 joko |
| 30 |
* + initial commit |
| 31 |
* |
| 32 |
* Revision 1.1 2003/03/01 15:31:18 joko |
| 33 |
* + initial commit |
| 34 |
* |
| 35 |
*/ |
| 36 |
|
| 37 |
|
| 38 |
/** |
| 39 |
* --- Data::Container |
| 40 |
* |
| 41 |
* |
| 42 |
* @author Andreas Motl <andreas.motl@ilo.de> |
| 43 |
* @copyright (c) 2003 - All Rights reserved. |
| 44 |
* @license GNU LGPL (GNU Lesser General Public License) |
| 45 |
* |
| 46 |
* @link http://www.netfrag.org/~joko/ |
| 47 |
* @link http://www.gnu.org/licenses/lgpl.txt |
| 48 |
* |
| 49 |
* @package org.netfrag.glib |
| 50 |
* @subpackage Data |
| 51 |
* @name Data::Container |
| 52 |
* |
| 53 |
*/ |
| 54 |
class Data_Container { |
| 55 |
|
| 56 |
var $_index; |
| 57 |
|
| 58 |
/** |
| 59 |
* The constructor ... |
| 60 |
* ... just does nothing. |
| 61 |
* |
| 62 |
* @param registry |
| 63 |
*/ |
| 64 |
function Data_Container() { |
| 65 |
} |
| 66 |
|
| 67 |
function get_address($entity) { |
| 68 |
return '_' . $entity; |
| 69 |
} |
| 70 |
|
| 71 |
function &push() { |
| 72 |
$args = &func_get_args(); |
| 73 |
$entity = array_shift($args); |
| 74 |
$name = $this->get_address($entity); |
| 75 |
// shrink array to single item? |
| 76 |
if (sizeof($args) == 1) { $args = $args[0]; } |
| 77 |
//$this->$entity[sizeof($this->$entity)] = &$args; |
| 78 |
if (!is_array($this->$name)) { |
| 79 |
php::array_cast_safe($this->$name); |
| 80 |
} |
| 81 |
array_push($this->$name, &$args); |
| 82 |
} |
| 83 |
|
| 84 |
function &slot($entity, $slot) { |
| 85 |
$name = $this->get_address($entity); |
| 86 |
return $this->$name[$slot]; |
| 87 |
} |
| 88 |
|
| 89 |
function &last($entity) { |
| 90 |
$name = $this->get_address($entity); |
| 91 |
$item = &$this->$name; |
| 92 |
return $item[sizeof($item) - 1]; |
| 93 |
} |
| 94 |
|
| 95 |
} |
| 96 |
|
| 97 |
?> |