annotate Lib/IMPL/DOM/Property.pm @ 75:915df8fcd16f

docs small fixes
author wizard
date Tue, 30 Mar 2010 20:31:36 +0400
parents 16ada169ca75
children a7efb3117295
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
1 package IMPL::DOM::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
4
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
5 use IMPL::Class::Property;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
6 require IMPL::Exception;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
8 use base qw(Exporter);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
9 our @EXPORT_OK = qw(_dom);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
11 sub _dom($) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
12 my ($prop_info) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
13 $prop_info->Implementor( 'IMPL::DOM::Property' );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
14 return $prop_info;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
15 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
16
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
17 sub Make {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
18 my ($self,$propInfo) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
20 my ($class,$name,$virt,$access,$mutators) = $propInfo->get qw(Class Name Virtual Access Mutators);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
21
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
22 die new IMPL::InvalidOperationException("DOM properties can be declared only for the DOM objects") unless $class->isa('IMPL::DOM::Node');
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
24 no strict 'refs';
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
25 die new IMPL::InvalidOperationException("Custom mutators are not allowed","${class}::$name") if ref $mutators;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
26 if (($mutators & prop_all) == prop_all) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
27 *{"${class}::$name"} = sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
28 $_[0]->nodeProperty($name,@_[1..$#_]);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
29 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
30 $propInfo->canGet(1);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
31 $propInfo->canSet(1);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
32 } elsif( $mutators & prop_get ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
33 *{"${class}::$name"} = sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
34 die new IMPL::InvalidOperationException("This is a readonly property", "${class}::$name") if @_>1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
35 $_[0]->nodeProperty($name);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
36 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
37 $propInfo->canGet(1);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
38 $propInfo->canSet(0);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
39 } elsif( $mutators & prop_set ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
40 *{"${class}::$name"} = sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
41 die new IMPL::InvalidOperationException("This is a writeonly property", "${class}::$name") if @_<2;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
42 $_[0]->nodeProperty($name,@_[1..$#_]);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
43 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
44 $propInfo->canGet(0);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
45 $propInfo->canSet(1);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
46 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
47 die new IMPL::InvalidOperationException("Invalid value for the property mutators","${class}::$name",$mutators);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
48 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
49 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
50
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
51 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
52 __END__
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
53 =pod
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
54
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
55 =head1 SYNOPSIS
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
57 package TypedNode;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
59 use base qw(IMPL::DOM::Node);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
60 use IMPL::DOM::Property qw(_dom);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
61
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
62 BEGIN {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
63 public _dom property Age => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
64 public _dom property Address => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
65 public property ServiceData => prop_all;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
66 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
67
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
68 =head1 DESCRIPTION
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
69
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
70 Позволяет объявлять свойства, которые будут храниться в списке динамических
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
71 свойств.
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
72
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 38
diff changeset
73 =cut