1oometa(n)             Data registry for TclOO frameworks             oometa(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       oometa - oo::meta A data registry for classess
9

SYNOPSIS

11       oo::meta::info
12
13       oo::meta::info branchget ?key? ?...?
14
15       oo::meta::info branchset ?key...? key value
16
17       oo::meta::info dump class
18
19       oo::meta::info class is type ?args?
20
21       oo::meta::info class merge ?dict? ?dict? ?...?
22
23       oo::meta::info class rebuild
24
25       oo::meta::metadata class
26
27       oo::define meta
28
29       oo::class method meta
30
31       oo::object method meta
32
33       oo::object method meta cget ?field? ?...? field
34
35______________________________________________________________________________
36

DESCRIPTION

38       The  oo::meta  package  provides  a  data  registry  service  for TclOO
39       classes.
40

USAGE

42              oo::class create animal {
43                meta set biodata animal: 1
44              }
45              oo::class create mammal {
46                superclass animal
47                meta set biodata mammal: 1
48              }
49              oo::class create cat {
50                superclass mammal
51                meta set biodata diet: carnivore
52              }
53
54              cat create felix
55              puts [felix meta dump biodata]
56              > animal: 1 mammal: 1 diet: carnivore
57
58              felix meta set biodata likes: {birds mice}
59              puts [felix meta get biodata]
60              > animal: 1 mammal: 1 diet: carnivore likes: {bird mice}
61
62              # Modify a class
63              mammal meta set biodata metabolism: warm-blooded
64              puts [felix meta get biodata]
65              > animal: 1 mammal: 1 metabolism: warm-blooded diet: carnivore likes: {birds mice}
66
67              # Overwrite class info
68              felix meta set biodata mammal: yes
69              puts [felix meta get biodata]
70              > animal: 1 mammal: yes metabolism: warm-blooded diet: carnivore likes: {birds mice}
71
72

CONCEPT

74       The concept behind oo::meta is that each class contributes a snippet of
75       local  data.   When  oo::meta::metadata  is  called,  the  system walks
76       through the linear ancestry produced by oo::meta::ancestors, and recur‐
77       sively  combines  all  of that local data for all of a class' ancestors
78       into a single dict.  Instances of oo::object  can  also  combine  class
79       data with a local dict stored in the meta variable.
80

COMMANDS

82       oo::meta::info
83              oo::meta::info is intended to work on the metadata of a class in
84              a manner similar to if the aggregate pieces where assembled into
85              a  single  dict. The system mimics all of the standard dict com‐
86              mands, and addes the following:
87
88       oo::meta::info branchget ?key? ?...?
89              Returns a dict representation of the element at args,  but  with
90              any trailing : removed from field names.
91
92
93              ::oo::meta::info $myclass set option color {default: green widget: colorselect}
94              puts [::oo::meta::info $myclass get option color]
95              > {default: green widget: color}
96              puts [::oo::meta::info $myclass branchget option color]
97              > {default green widget color}
98
99
100       oo::meta::info branchset ?key...? key value
101              Merges   dict  with  any  other  information  contaned  at  node
102              ?key...?, and adding a trailing : to all field names.
103
104
105              ::oo::meta::info $myclass branchset option color {default green widget colorselect}
106              puts [::oo::meta::info $myclass get option color]
107              > {default: green widget: color}
108
109
110       oo::meta::info dump class
111              Returns the complete snapshot of a class metadata, as  producted
112              by oo::meta::metadata
113
114       oo::meta::info class is type ?args?
115              Returns  a  boolean  true  or  false if the element ?args? would
116              match string is type value
117
118
119              ::oo::meta::info $myclass set constant mammal 1
120              puts [::oo::meta::info $myclass is true constant mammal]
121              > 1
122
123
124       oo::meta::info class merge ?dict? ?dict? ?...?
125              Combines all of the arguments into a single dict, which is  then
126              stored as the new local representation for this class.
127
128       oo::meta::info class rebuild
129              Forces the meta system to destroy any cached representation of a
130              class' metadata before the next access to oo::meta::metadata
131
132       oo::meta::metadata class
133              Returns an aggregate picture of the metadata for class,  combin‐
134              ing its local data with the local data from its ancestors.
135
136       oo::define meta
137              The  package  injects  a command oo::define::meta which works to
138              provide  a  class  in  the  process  of  definition  access   to
139              oo::meta::info, but without having to look the name up.
140
141
142              oo::define myclass {
143                meta set foo bar: baz
144              }
145
146
147       oo::class method meta
148              The package injects a new method meta into oo::class which works
149              to provide a class instance access to oo::meta::info.
150
151       oo::object method meta
152              The  package  injects  a  new  method  meta   into   oo::object.
153              oo::object  combines  the  data  for  its  class (as provided by
154              oo::meta::metadata), with a local variable  meta  to  produce  a
155              local  picture  of metadata.  This method provides the following
156              additional commands:
157
158       oo::object method meta cget ?field? ?...? field
159              Attempts to locate a singlar leaf, and  return  its  value.  For
160              single  option  lookups,  this  is  faster  than my meta getnull
161              ?field? ?...? field],  because  it  performs  a  search  instead
162              directly  instead  of  producing  the  recursive  merge  product
163              between the class metadata, the local meta  variable,  and  THEN
164              performing the search.
165

BUGS, IDEAS, FEEDBACK

167       This  document,  and the package it describes, will undoubtedly contain
168       bugs and other problems.  Please report such in the category  tcloo  of
169       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
170       also report any ideas for enhancements you may have for either  package
171       and/or documentation.
172
173       When proposing code changes, please provide unified diffs, i.e the out‐
174       put of diff -u.
175
176       Note further that  attachments  are  strongly  preferred  over  inlined
177       patches.  Attachments  can  be  made  by  going to the Edit form of the
178       ticket immediately after its creation, and  then  using  the  left-most
179       button in the secondary navigation bar.
180

KEYWORDS

182       TOOL, TclOO
183

CATEGORY

185       TclOO
186
188       Copyright (c) 2015 Sean Woods <yoda@etoyoc.com>
189
190
191
192
193tcllib                               0.7.1                           oometa(n)
Impressum