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