annotate Lib/IMPL/Class/PropertyInfo.pm @ 103:c289ed9662ca

Schema beta 2 More strict validation, support for inflating a simple nodes and properties
author wizard
date Fri, 07 May 2010 18:17:40 +0400
parents b0c068da93ac
children 44977efed303
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: 27
diff changeset
1 package IMPL::Class::PropertyInfo;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
3
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
4 use base qw(IMPL::Class::MemberInfo);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
5
60
b0c068da93ac Lazy activation for the configuration objects (final concept)
wizard
parents: 49
diff changeset
6 __PACKAGE__->mk_accessors(qw(Type Mutators canGet canSet ownerSet));
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
7 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
8
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
9 my %LoadedModules;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
11 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
12 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
14 if ( my $type = $this->Attributes ? delete $this->Attributes->{type} : undef ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
15 $this->Type($type);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
16 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
18 $this->Mutators(0) unless defined $this->Mutators;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
19 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
20
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
21 sub Implementor {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
22 my $this = shift;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
24 my $implementor;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
26 if (@_) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
27 $this->SUPER::Implementor(@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
28 } else {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
29 my $implementor = $this->SUPER::Implementor;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
30 return $implementor if $implementor;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
32 $implementor = $this->SelectImplementor();
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
34 if (my $class = ref $implementor ? undef : $implementor) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
35 if (not $LoadedModules{$class}) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
36 (my $package = $class.'.pm') =~ s/::/\//g;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
37 require $package;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
38 $LoadedModules{$class} = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
39 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
40 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
41
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
42 $this->Implementor($implementor);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
43 return $implementor;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
44 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
45
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
46 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
48 sub SelectImplementor {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
49 my ($this) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
50
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
51 if ($this->Class->can('_PropertyImplementor')) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
52 return $this->Class->_PropertyImplementor;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
53 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
54 die new IMPL::Exception('Can\'t find a property implementor for the specified class',$this->Class);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
55 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
56
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 27
diff changeset
57 1;