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