Welcome, Guest. Please Login
Tinderbox
  News:
IMPORTANT MESSAGE! This forum has now been replaced by a new forum at http://forum.eastgate.com and no further posting or member registration is allowed. The forum is still accessible via read-only access for reference purposes. If you wish to discuss content here, please use the new forum. N.B. - posting in the new forum requires a fresh registration in the new forum (sorry - member data can't be ported).
  HomeHelpSearchLogin  
 
Pages: 1
Send Topic Print
Determine prototype ancestors (Read 4727 times)
rtalexander
Full Member
*
Offline



Posts: 37

Determine prototype ancestors
Dec 19th, 2012, 2:35pm
 
Suppose I have a note X, how do I determine if there is a prototype
path from X's prototype to some other prototype node Z?

To clarify (hopefully), given a note K whose container is J, is there
anyway to determine if the prototype of J, P, is a particular note N
(i.e. P = N), or there is a path of prototypes that can be traversed
from P to reach N?

For example, consider the following containment hierarchy of notes:

- Root
 - J
   - K
 - N
 - O
 - P

Assume these notes have the following prototype relationships:

* $Prototype(J) = P
* $Prototype(P) = O
* $Prototype(O) = N

Now suppose that K is the current note during export. What I want to
do is determine if the prototype of K's container, J, is N or any other
note that can be reached by traversing a path of prototype relationships
to reach N. For this particular example, the prototype of J is P, which
is not N, but I can bet to N by traversing from P to its prototype O, and
from O to its prototype N, something like $Prototype($Prototype($Prototype(P))).

As a concrete example, I'm using Tinderbox to capture software requirements.
Each requirement is either an aggregate that contains sub-requirements, or it
is a singleton requirement. At export time, for a given requirement, I need to
determine if it is a sub-requirement of some other requirement, namely its
containing note.

To boil it down to Tinderbox terms, roughly what I need is an operator that would
return a list having path of ancestor prototypes for a given node J, ordered
starting from the J's prototype, then J's prototype's prototype, and so on.
Something perhaps like the following:

   prototypeAncestors(J) would return the list [P,O,N]

which would allow something like the following to be expressed:

   if (prototypeAncestors($Prototype($Container))).contains(N)) {...}

Any thoughts or suggestions would be greatly appreciated!
Back to top
 
 
  IP Logged
Mark Bernstein
YaBB Administrator
*
Offline

designer of
Tinderbox

Posts: 2871
Eastgate Systems, Inc.
Re: Determine prototype ancestors
Reply #1 - Dec 19th, 2012, 3:12pm
 
This probably SHOULD be a primitive method.  I'm not sure there's a good way to do this right now.

You can extract the prototype of your prototype thusly:

     $Prototype($Path($Prototype))

This works because  $Path($Prototype) is the full path of the note’s prototype. So we're returning the prototype of the prototype.

Unless you have a vast number of prototypes -- a whole taxonomy -- or need to change prototypes all the time, you might be well served simply to add a set attribute to hold the prototype list, and enter this manually for each prototype.

Back to top
 
 
WWW   IP Logged
Mark Anderson
YaBB Administrator
*
Offline

User - not staff!

Posts: 5689
Southsea, UK
Re: Determine prototype ancestors
Reply #2 - Dec 19th, 2012, 5:05pm
 
@rtalexander - do you want a ordered list of prototypes names or a set of references ($Path) data for each? For what purpose will that data be used? Will the prototype chaining (or prototype names) change over the course of the project?

I ask because knowing these things might help with planning a practical solution (based on the latter part of Mark B's answer).
Back to top
 
 

--
Mark Anderson
TB user and Wiki Gardener
aTbRef v6
(TB consulting - email me)
WWW shoantel   IP Logged
Pages: 1
Send Topic Print