Building VBinaryLink subclass in RB

Ed Kleban Ed at Kleban.com
Mon Dec 12 13:02:47 CST 2005


Ok...

I've made a subclass of VBinaryLink named CBLnkItemTms

I have created an instance variable dbBLnkItmTms in the database class
instance to hold the link, just as is done for tables, and I instantiated
the link from a call in my database initialization method:


  dbTblItems = new CTblItems( self, "TblItems" )
  dbTblTimeStamp = new CTblTimeStamp( self, "TblTimeStamp" )
  dbBLnkItmTms = _
    new CBLnkItmTms( dbTblItems, dbTblTimeStamp, "BLnkItmTms" )
  
I'm now attempting to define the constructor method, which I've also named
CBLnkItmTms.

Presumably, just as for contructors of VTable subclasses, all of the
instance variables will initially get default values and it is up to my
constructor to change any of those it cares about.  So just like for a
Vtable subclass constructor I include assignment of the linkname

    
  Sub CBLnkItmTms( TLeft as VTable, TRight as VTable, linkName as String )
    
    self.name = linkName
    ...

If I wanted to I could change the table owner for example since owner is
inhereited by VBinaryLink from VLink:

    self.owner = someVTableOfMyChoice

I also see that VBinaryLink inherits LeftType and RightType, so I could
change those also if I want something different from the defaults.

But what do I do with my two table arguments?

Unfortunately the V4RB reference includes no documentation of the properties
of VBinaryLink.  Fortunately however, autocomplete allows me to cheat a bit
and discover that I have access to all of the same property and method names
inherited from VLink2 plus the constructor method VBinaryLink.

I see there is a "Table" property.  My guess is that this is always used for
the LeftLink side, i.e. the so called parent.  So I can assign:

    self.Table = TLeft

But what do I do with "right"?

One of the reasons that I'm beginning to like this approach is that I want
to a) Simplify syntax and b) Cache my tables in one place so I can hand them
directly to the FindLinked command without having to cache them in every
routine that needs to use FindLinked.

Thus I want to define for CBLnkItmTms:

    Function FindTimesForItem( anItemRid ) as VArraySet
    Function FindItemsForTime( aTmsRid ) as VArraySet

Should I simply cache TRight in a new property I declare for CBlnkItmTms so
that to implement the above to Find commands I can use:

    self.FindLinked( anRid, Tleft, TRight ) ?

Or is there some mysterious undocumented, unnamed, or possibly inaccessible
instance variable that VBinaryLink instances have that would allow me to
use:

    self.undocumentedRightTablePropertyName = TRight

If it is really the case that VBinaryLink instances do not retain the
RightTable argument when the CreateBinaryLink or VBinaryLink methods are
used, then I can well understand why there's yet another good reason that
the FindLinked command requires the user to specify both tables... but I'll
have more words to say on that in a separate email.


 


    





  self.name = tableName
 
I've defined my constructor to have two arguments, just as is shown for
VTable subclass constructors in the Classes Way examples.

So, in my Database constructor I have:
   
  dbBLnkItemTms = new VBinaryLink( _
  "BLnkItemTms", dbTblItems, dbTblTimeStamp, EVLinkType.kMany,
EVLinkType.kOne )
  




More information about the Valentina mailing list