Tcl Library Source Code

EuroTcl/OpenACS 11 - 12 JULY 2024, VIENNA

[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]


oometa - oo::meta A data registry for classess

Table Of Contents


oo::meta::info branchget ?key? ?...?
oo::meta::info branchset ?key...? key value
oo::meta::info dump class
oo::meta::info class is type ?args?
oo::meta::info class merge ?dict? ?dict? ?...?
oo::meta::info class rebuild
oo::meta::metadata class
oo::define meta
oo::class method meta
oo::object method meta
oo::object method meta cget ?field? ?...? field


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


oo::class create animal {
  meta set biodata animal: 1
oo::class create mammal {
  superclass animal
  meta set biodata mammal: 1
oo::class create cat {
  superclass mammal
  meta set biodata diet: carnivore

cat create felix
puts [felix meta dump biodata]
> animal: 1 mammal: 1 diet: carnivore

felix meta set biodata likes: {birds mice}
puts [felix meta get biodata]
> animal: 1 mammal: 1 diet: carnivore likes: {bird mice}

# Modify a class
mammal meta set biodata metabolism: warm-blooded
puts [felix meta get biodata]
> animal: 1 mammal: 1 metabolism: warm-blooded diet: carnivore likes: {birds mice}

# Overwrite class info
felix meta set biodata mammal: yes
puts [felix meta get biodata]
> animal: 1 mammal: yes metabolism: warm-blooded diet: carnivore likes: {birds mice}


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


Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category tcloo of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.






Copyright © 2015 Sean Woods