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