1 |
joko |
1.1 |
<? |
2 |
|
|
/** |
3 |
joko |
1.5 |
* This file contains the DesignPattern::AdapterProxy namespace. |
4 |
joko |
1.1 |
* |
5 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
6 |
joko |
1.2 |
* @package org.netfrag.glib |
7 |
joko |
1.6 |
* @name DesignPattern::AdapterProxy |
8 |
joko |
1.4 |
* |
9 |
|
|
* <b>Cvs-Log:</b> |
10 |
joko |
1.1 |
* |
11 |
joko |
1.4 |
* <pre> |
12 |
joko |
1.9 |
* $Id: AdapterProxy.php,v 1.8 2003/03/05 17:28:43 joko Exp $ |
13 |
joko |
1.2 |
* |
14 |
|
|
* $Log: AdapterProxy.php,v $ |
15 |
joko |
1.9 |
* Revision 1.8 2003/03/05 17:28:43 joko |
16 |
|
|
* updated docu (phpDocumentor testing....) |
17 |
|
|
* |
18 |
joko |
1.8 |
* Revision 1.7 2003/03/05 17:13:17 joko |
19 |
|
|
* updated docu (phpDocumentor testing....) |
20 |
|
|
* |
21 |
joko |
1.7 |
* Revision 1.6 2003/03/05 17:02:22 joko |
22 |
|
|
* updated docu (phpDocumentor testing....) |
23 |
|
|
* |
24 |
joko |
1.6 |
* Revision 1.5 2003/03/05 16:45:58 joko |
25 |
|
|
* updated docu (phpDocumentor testing....) |
26 |
|
|
* |
27 |
joko |
1.5 |
* Revision 1.4 2003/03/05 16:32:18 joko |
28 |
|
|
* updated docu (phpDocumentor testing....) |
29 |
|
|
* |
30 |
joko |
1.4 |
* Revision 1.3 2003/03/05 16:10:17 joko |
31 |
|
|
* updated docu (phpDocumentor testing....) |
32 |
|
|
* |
33 |
joko |
1.3 |
* Revision 1.2 2003/03/05 15:41:03 joko |
34 |
|
|
* updated docu (phpDocumentor testing....) |
35 |
|
|
* |
36 |
joko |
1.2 |
* Revision 1.1 2003/03/05 12:07:10 joko |
37 |
|
|
* + initial commit |
38 |
joko |
1.1 |
* |
39 |
|
|
* Revision 1.1 2003/03/03 22:11:08 joko |
40 |
|
|
* + initial commit |
41 |
joko |
1.4 |
* </pre> |
42 |
joko |
1.1 |
* |
43 |
|
|
* |
44 |
|
|
*/ |
45 |
joko |
1.6 |
// cvs-log |
46 |
joko |
1.1 |
|
47 |
|
|
|
48 |
|
|
/** |
49 |
joko |
1.4 |
* Make sure we have the required parent class |
50 |
|
|
*/ |
51 |
|
|
loadModule('DesignPattern::TransparentProxy'); |
52 |
|
|
|
53 |
|
|
|
54 |
|
|
/** |
55 |
joko |
1.5 |
* This tries to combine some DesignPatterns.... |
56 |
joko |
1.1 |
* |
57 |
joko |
1.5 |
* It combines features from both the standard Proxy |
58 |
|
|
* and the TransparentProxy adding some Adapter features. |
59 |
joko |
1.2 |
* |
60 |
joko |
1.7 |
* @name DesignPattern::AdapterProxy |
61 |
|
|
* @subpackage DesignPattern |
62 |
|
|
* @package org.netfrag.glib |
63 |
joko |
1.8 |
* |
64 |
joko |
1.7 |
* @link http://www.gnu.org/licenses/lgpl.txt |
65 |
joko |
1.2 |
* @license GNU LGPL (GNU Lesser General Public License) |
66 |
joko |
1.8 |
* |
67 |
joko |
1.7 |
* @link http://www.netfrag.org/~joko/ |
68 |
|
|
* @copyright (c) 2003 - All Rights reserved. |
69 |
|
|
* @author Andreas Motl <andreas.motl@ilo.de> |
70 |
joko |
1.1 |
* |
71 |
joko |
1.7 |
* @todo Learn TransparentProxy to do procedural calls ... <br> |
72 |
|
|
* ... instead of instantiating a component and even less code could be in here<br> |
73 |
joko |
1.3 |
* benefit: the TransparentProxy would be become even more powerful |
74 |
|
|
* eeäähhh, to the master Proxy it goes......!!! This one calls the handler(s)! |
75 |
|
|
* |
76 |
|
|
*/ |
77 |
joko |
1.1 |
class DesignPattern_AdapterProxy extends DesignPattern_TransparentProxy { |
78 |
|
|
|
79 |
|
|
var $_adapter; |
80 |
|
|
var $_adapter_module; |
81 |
|
|
var $_adapter_options; |
82 |
|
|
|
83 |
|
|
function &get_adapter() { |
84 |
|
|
return $this->_adapter; |
85 |
|
|
} |
86 |
|
|
|
87 |
|
|
function &set_adapter(&$adapter) { |
88 |
|
|
$this->_adapter = &$adapter; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
// move this code to php::call_func!!! and wrap here!!! |
92 |
|
|
function &create_adapter($m, $f, $a, $options = array()) { |
93 |
|
|
|
94 |
|
|
// load required module |
95 |
|
|
php::loadModule($m); |
96 |
|
|
|
97 |
|
|
// V0: call-handler tests |
98 |
|
|
//$m::$f(); |
99 |
|
|
//$res = call_user_func(array($m, $f)); |
100 |
|
|
//call_user_func("$m::$f"); |
101 |
|
|
//$m->$f(); |
102 |
|
|
|
103 |
|
|
// V1: |
104 |
|
|
//$res = call_user_func( array( $m, $f ) ); |
105 |
|
|
|
106 |
|
|
// V2: |
107 |
|
|
//return call_user_func( array( $m, $f ), $a ); |
108 |
|
|
|
109 |
|
|
if ($options[object]) { |
110 |
|
|
$m = php::mkInstance($m); |
111 |
|
|
} |
112 |
|
|
|
113 |
|
|
// V3: |
114 |
|
|
$this->set_adapter( call_user_func( array( &$m, $f ), $a ) ); |
115 |
|
|
return $this->get_adapter(); |
116 |
|
|
|
117 |
|
|
//print Dumper($res); |
118 |
|
|
//exit; |
119 |
|
|
|
120 |
|
|
// FIXME: use TransparentProxy for this! |
121 |
|
|
// V1: |
122 |
|
|
//$this = $res; |
123 |
|
|
// V2: |
124 |
|
|
//$this->make_transparent(); |
125 |
|
|
|
126 |
|
|
//return $res; |
127 |
|
|
|
128 |
|
|
} |
129 |
|
|
|
130 |
|
|
function set_adapter_module($name) { |
131 |
|
|
$this->_adapter_module = $name; |
132 |
|
|
} |
133 |
|
|
function get_adapter_module() { |
134 |
|
|
return $this->_adapter_module; |
135 |
|
|
} |
136 |
|
|
function set_adapter_options(&$options) { |
137 |
|
|
$this->_adapter_options = &$options; |
138 |
|
|
} |
139 |
|
|
function get_adapter_options() { |
140 |
|
|
return $this->_adapter_options; |
141 |
|
|
} |
142 |
|
|
|
143 |
|
|
} |
144 |
|
|
|
145 |
|
|
?> |