summaryrefslogtreecommitdiff
path: root/fml/lib/FML/PCB.pm
diff options
context:
space:
mode:
authorfukachan <fukachan>2005-06-01 10:23:33 +0000
committerfukachan <fukachan>2005-06-01 10:23:33 +0000
commit627b6e11f092b3a6c3067da1385f954558999001 (patch)
tree1360865a15090829fb1d8d82880f3af9a6804356 /fml/lib/FML/PCB.pm
parent2363402810c5d9d75657c27c43f2523190139c33 (diff)
downloadfml8-627b6e11f092b3a6c3067da1385f954558999001.tar.gz
fml8-627b6e11f092b3a6c3067da1385f954558999001.tar.bz2
fml8-627b6e11f092b3a6c3067da1385f954558999001.zip
fix dump_variables() for context based switching.
define {set,get}_current_context().
Diffstat (limited to 'fml/lib/FML/PCB.pm')
-rw-r--r--fml/lib/FML/PCB.pm72
1 files changed, 68 insertions, 4 deletions
diff --git a/fml/lib/FML/PCB.pm b/fml/lib/FML/PCB.pm
index 52fe45d1..7fa755d3 100644
--- a/fml/lib/FML/PCB.pm
+++ b/fml/lib/FML/PCB.pm
@@ -4,7 +4,7 @@
# All rights reserved. This program is free software; you can
# redistribute it and/or modify it under the same terms as Perl itself.
#
-# $FML: PCB.pm,v 1.20 2004/07/23 15:59:00 fukachan Exp $
+# $FML: PCB.pm,v 1.21 2005/05/27 03:03:32 fukachan Exp $
#
package FML::PCB;
@@ -114,9 +114,17 @@ You must specify C<category>, C<key> and the C<value>.
# Return Value: none
sub dump_variables
{
- my ($k, $v);
- while (($k, $v) = each %_fml_PCB) {
- print "${k}: $v\n";
+ my $pcb = $_fml_PCB{ $current_context } || {};
+
+ my ($k, $v, $xk, $xv);
+ while (($k, $v) = each %$pcb) {
+ while (($xk, $xv) = each %$v) {
+ printf "%-21s => {\n", $current_context;
+ printf " %-18s => {\n", $k;
+ printf " %-15s => %-15s\n", $xk, $xv;
+ printf " }\n";
+ printf "}\n\n";
+ }
}
}
@@ -150,6 +158,62 @@ sub set
}
+=head1 CONTEXT SWITCH
+
+=head2 set_current_context($context)
+
+switch the current context.
+
+=head2 get_current_context()
+
+get the current context name.
+
+=cut
+
+
+# Descriptions: switch the current context.
+# Arguments: OBJ($self) STR($context)
+# Side Effects: overload $current_context.
+# Return Value: none
+sub set_current_context
+{
+ my ($self, $context) = @_;
+
+ $current_context = $context;
+}
+
+
+# Descriptions: get the current context.
+# Arguments: OBJ($self)
+# Side Effects: none
+# Return Value: none
+sub get_current_context
+{
+ my ($self) = @_;
+
+ return $current_context;
+}
+
+
+#
+# debug
+#
+if ($0 eq __FILE__) {
+ my $category = "category";
+ my $ml = 'elena@home.fml.org';
+ my $key = "key";
+ my $value = "value";
+
+ my $pcb = new FML::PCB;
+ $pcb->set($category, "ml_name", "test");
+ $pcb->dump_variables();
+
+ $pcb->set_current_context($ml);
+ $pcb->set($category, "ml_name", "elena");
+ $pcb->dump_variables();
+}
+
+
=head1 CODING STYLE
See C<http://www.fml.org/software/FNF/> on fml coding style guide.