TLeaf


Croquet-Teapot

Comment:

Main comment stating the purpose of this class and relevant relationship to other classes.

Possible useful expressions for doIt or printIt.

Structure:
 instVar1		type -- comment about the purpose of instVar1
 instVar2		type -- comment about the purpose of instVar2

Any further useful comments about the general approach of this implementation.

Hierarchy:

ProtoObject
Object
TObject
TLeaf

Summary:

instance variables:

childPrimitives isStatic parentPrimitives timeStamp valid

methods:

instance class
accessing construction initialize no messages

Detail:

instance variables:

childPrimitives
isStatic
parentPrimitives
timeStamp
valid

instance methods:

accessing
addChild: prim


"When we add a new primitive to this object, we need to add all of it's component primitive objects to ensure that their frameNumber is properly updated when we use this. Further, we need to tell the child primitives that they are being used somewhere else so that when they are invalidated, they can invalidate the entire tree."
	childPrimitives add: prim.
	prim addParent: self.
addParent: parent


"see #addChild: comment."
	parentPrimitives add: parent.
isStatic

	
	^ isStatic.
setStatic: static

	
	isStatic _ static.
valid


	^ valid.
valid: bool


	valid _ bool.

construction
createPrimitive: ogl


" override this method to specify how the object should be constructed."
destroyPrimitive: ogl

	
"override this method for destroying the object"
invalidate: ogl

"This can only attempt to invalidate this object - if it is being used by a parent ogl object, this will fail because the current object is still in use somewhere. We return false if the invalidate failed, true if it succeeded."
	| pprims |
	valid ifFalse:[ ^true.].
	ogl timeStamp = timeStamp ifTrue:[ ^ false]. "we just used this, and probably will again soon"
	pprims _ parentPrimitives copy.
"test to see if we have just used a parent that used this, so we can't remove."
	pprims do:[:pp | (pp invalidate: ogl) ifFalse:[^ false] ifTrue:[parentPrimitives remove:pp]]. 
"nobody cares, or we were able to invalidate all of the parents, so let's remove ourselves from the children. We don't invalidate the children because they could still be useful, and unlike the parents, the children do not depend upon us."
	childPrimitives do:[:cp | cp removeParent: self].
	self destroyPrimitive: ogl.
	valid _ false.
	^ true.	

initialize
initialize


	super initialize.
	childPrimitives _ OrderedCollection new.
	parentPrimitives _ OrderedCollection new.
	timeStamp _ 0.
	valid _ false.
	isStatic _ true.

class methods:

^top


- made by Dandelion -