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