Class ::xotcl::RecreationClass (public)
::xotcl::Class ::xotcl::RecreationClass
Defined in /var/www/openacs.org/packages/xotcl-core/tcl/10-recreation-procs.tcl
This meta-class controls the behavior of classes (and optionally their instances), when the classes (or their instances) are overwritten by same named new objects; we call this situation a recreate of an object.
Normally, when files with e.g. class definitions are sourced, the classes and objects are newly defined. When e.g. class definitions exists already in this file, these classes are deleted first before they are newly created. When a class is deleted, the instances of this class are changed into instances of class ::xotcl::Object.
This can be a problem when the class instances are not reloaded and when they should survife the redefinition with the same class relationships. Therefore, we define a meta class RecreationClass, which can be used to parameterize the behavior on redefinitions. Alternatively, Classes or objects could provide their own recreate methods.
Per default, this meta-class handles only the class redefinition case and does only a reconfigure on the class object (in order to get e.g. ad_doc updated).
The following parameters are defined:
- reconfigure: reconfigure class (default 1)
- reinit: run init after configure for this class (default unset)
- instrecreate: handle recreate of class instances (default unset) When this flag is set to 0, instreconfigure and instreinit are ignored.
- instreconfigure: reconfigure instances of this class (default 1)
- instreinit: re-init instances of this class (default unset)
- Testcases:
- No testcase defined.
Source code: namespace eval ::xotcl {} ::nsf::object::alloc ::xotcl::Class ::xotcl::RecreationClass {set :__default_metaclass ::xotcl::Class set :__default_superclass ::xotcl::Object} ::xotcl::RecreationClass proc recreate {obj args} { #:log "### recreateclass proc $obj <$args>" # the minimal reconfiguration is to set the class and remove methods $obj class [self] foreach p [$obj info instprocs] {$obj instproc $p {} {}} if {[info exists :reconfigure]} { # before we set defaults, we must unset vars foreach var [$obj info vars] {$obj unset $var} # set defaults and run configure $obj set_instance_vars_defaults $obj configure {*}$args } if {[info exists :reinit]} { $obj init } } ::xotcl::RecreationClass instproc recreate {obj args} { #:log "### recreateclass instproc $obj <$args>" # the minimal reconfiguration is to set the class and remove methods $obj class [self] foreach p [$obj info procs] {$obj proc $p {} {}} if {![info exists :instrecreate]} { #:log "### no instrecreate for $obj <$args>" next return } if {[info exists :instreconfigure]} { # before we set defaults, we must unset vars foreach var [$obj info vars] {$obj unset $var} # set defaults and run configure $obj set_instance_vars_defaults $obj configure {*}$args #:log "### instproc recreate $obj + configure $args ..." } if {[info exists :instreinit]} { #:log "### instreinit for $obj <$args>" $obj init #:log "### instproc recreate $obj + init ..." } } ::xotcl::RecreationClass instparametercmd instrecreate ::xotcl::RecreationClass instparametercmd reconfigure ::xotcl::RecreationClass instparametercmd instreinit ::xotcl::RecreationClass instparametercmd reinit ::xotcl::RecreationClass instparametercmd instreconfigure ::nsf::relation::set ::xotcl::RecreationClass superclass ::xotcl::Class ::nx::slotObj -container slot ::xotcl::RecreationClass ::xotcl::RecreationClass::slot eval {set :__parameter { {reconfigure 1} {reinit} {instrecreate} {instreconfigure 1} {instreinit} }} ::nsf::object::alloc ::xotcl::Attribute ::xotcl::RecreationClass::slot::instreconfigure {set :accessor public set :configurable true set :convert false set :default 1 set :defaultmethods {} set :disposition alias set :domain ::xotcl::RecreationClass set :incremental 0 set :manager ::xotcl::RecreationClass::slot::instreconfigure set :methodname instreconfigure set :multiplicity 1..1 set :name instreconfigure set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xotcl::RecreationClass::slot::reinit {set :accessor public set :configurable true set :convert false set :defaultmethods {} set :disposition alias set :domain ::xotcl::RecreationClass set :incremental 0 set :manager ::xotcl::RecreationClass::slot::reinit set :methodname reinit set :multiplicity 1..1 set :name reinit set :per-object false set :position 0 set :required false set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xotcl::RecreationClass::slot::instreinit {set :accessor public set :configurable true set :convert false set :defaultmethods {} set :disposition alias set :domain ::xotcl::RecreationClass set :incremental 0 set :manager ::xotcl::RecreationClass::slot::instreinit set :methodname instreinit set :multiplicity 1..1 set :name instreinit set :per-object false set :position 0 set :required false set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xotcl::RecreationClass::slot::reconfigure {set :accessor public set :configurable true set :convert false set :default 1 set :defaultmethods {} set :disposition alias set :domain ::xotcl::RecreationClass set :incremental 0 set :manager ::xotcl::RecreationClass::slot::reconfigure set :methodname reconfigure set :multiplicity 1..1 set :name reconfigure set :per-object false set :position 0 set :required false set :substdefault 0b111 set :trace none : init} ::nsf::object::alloc ::xotcl::Attribute ::xotcl::RecreationClass::slot::instrecreate {set :accessor public set :configurable true set :convert false set :defaultmethods {} set :disposition alias set :domain ::xotcl::RecreationClass set :incremental 0 set :manager ::xotcl::RecreationClass::slot::instrecreate set :methodname instrecreate set :multiplicity 1..1 set :name instrecreate set :per-object false set :position 0 set :required false set :trace none : init} namespace eval ::xotcl {::namespace export Object Class Attribute myproc myvar my self next @}XQL Not present: Generic, PostgreSQL, Oracle