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