Ram�n Jim�nez wrote:
> Denver wrote:
> > Property ProcessMaxValue As %Integer [calculated];
> > Property ProcessMaxValueLocal As %Integer [private];
> >
> > ProcessMaxValueGet() will return ..ProcessMaxValueLocal if defined,
> > otherwise, ..Parent.ProcessMaxValueLocal.
> >
> > ProcessMaxValueSet() will set ProcessMaxValueLocal.
> 
> That is very good.
Okay, thanks.

> The interesting thing now is trying to develop abstract classes
> whose concrete subclasses can be generated to do this.
Not an abstract class.


> Otherwise, it's an awful lot of boring, error-prone coding.
Yes.

Remember my little problem with pMyPropertyNormalize() and pMyPropertyNormalizeExtra()
not so long ago?
Something like that might work here.
But it is not pretty.
If datatypes could have their own private properties, that would help a little.


/// Class to which a property, pMyProperty, of this type belongs must have:
///     Property pMyProperty As My.datatype.CalculatedOverridableInteger [calculated].
///     pMyPropertyActual As %Integer [private]. 
Class My.datatype.CalculatedOverridableInteger [ ClassType = datatype, ClientDataType 
= INTEGER, OdbcType = INTEGER, ProcedureBlock, SqlCategory = INTEGER ]
{

ClassMethod Set(%val As %Integer) As %Integer [ CodeMode = objectgenerator ]
{
        s zpn=$p($li(%compiledmethod.%Oid(),1),"|",3) ;name of property
        s:zpn="Set" zpn=""
        w " Generating method ",zpn,"Set... "
        d %code.WriteLine(" s %this."_zpn_"Actual=%val")
        d %code.WriteLine(" q %val")
        q $$$OK
}

/// Class CC must have properties ParentID [persistent], and ParentIDoref [transient, 
private],
/// and method OpenParent() that opens the Parent and saves the oref in transient 
ParentIDoref.
ClassMethod Get() As %Integer [ CodeMode = objectgenerator ]
{
        s zpn=$p($li(%compiledmethod.%Oid(),1),"|",3) ;name of property
        s:zpn="Get" zpn=""
        w " Generating method ",zpn,"Get... "
        d %code.WriteLine(" q:$d(%this."_zpn_"Actual) %this."_zpn_"Actual")
        if zpn]"" {
                d %code.WriteLine(" d:'..ParentIDoref ..OpenParent() q:'..ParentIDoref 
""""")
                d %code.WriteLine(" d:..ParentIDoref ..OpenParent() q 
..ParentIDoref."_zpn) ;here note
                ; that this is recursive rather than ..ParentIDoref."_zpn_"Actual".
                ; This way the parent can be either of class CC or of class BB.
        }
        q $$$OK
}
}



/*** This is mainly just to illustrate the concept.  It is untested. ***/

Reply via email to