  
  [1X13 [5Xsimpcomp[1X internals[0X
  
  The  package [5Xsimpcomp[0m works with simplicial complexes for which a [5XGAP[0m object
  type  [10XSCSimplicialComplex[0m  is  defined  and  calculates  properties of these
  objects  via  so  called  property  handlers.  This chapter describes how to
  extend [5Xsimpcomp[0m by writing own property handlers.
  
  By   writing  own  property  handlers,  [5Xsimpcomp[0m  can  be  extended  in  its
  functionality.  If  you  extended  [5Xsimpcomp[0m and want to share your extension
  with  other  users  please  send your extension to one of the authors and we
  will  consider  including  it  (of  course  with  giving credit) in a future
  release of [5Xsimpcomp[0m.
  
  
  [1X13.1 Example of a common property handler[0X
  
  In  this  section  we  will have a look at the property handler [10XSCFVector[0m in
  oder to explain the inner workings of property handlers. This is the code of
  the property handler for calculating the f-vector of a complex in [5Xsimpcomp[0m:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4XInstallGlobalFunction(SCFVector,[0X
    [4X	function(complex)[0X
    [4X[0X
    [4X	local f, faces;[0X
    [4X	[0X
    [4X	if(not SCIsSimplicialComplex(complex)) then[0X
    [4X		SCError()("SCFVector: first argument must be of type[0X
    [4X		SCSimplicialComplex.\n");[0X
    [4X		return fail;[0X
    [4X	fi;[0X
    [4X[0X
    [4X	f:=SCPropertyByName(complex,"F");[0X
    [4X	if f<>fail and not SCIntFunc.ForceRecalcEnabled(complex) and  IsList(f)[0X
    [4X		and	ForAll(f,x->IsInt(x) and x>=0) then[0X
    [4X		return f;[0X
    [4X	else[0X
    [4X		SCPropertyDrop(complex,"F");[0X
    [4X		faces:=SCFaceLatticeEx(complex);[0X
    [4X		if faces=fail then[0X
    [4X			return fail;[0X
    [4X		fi;[0X
    [4X		f:=List(faces,x->Size(x));[0X
    [4X		SCPropertySet(complex,"F",f);[0X
    [4X		return f;[0X
    [4X	fi;[0X
    [4Xend);[0X
  [4X------------------------------------------------------------------[0X
  
  When  looking  at the code one already see the structure that such a handler
  needs to have:
  
  (1)   The arguments are checked for validity -- in case of invalid arguments
        an  error  is  signaled  with [10XSCError()("Error message")[0m. [10XSCError[0m then
        displays the error message and optionally enters a break loop.
  
  (2)   It  is  checked  whether  the  property  was computed already with the
        function  [10XSCPropertyByName[0m -- it takes a complex (as [10XSCPropertyObject[0m)
        and  a property name (as [10XString[0m) as arguments and returns the property
        or [9Xfail[0m if that property does not exist.
  
  (3)   If       [10XSCPropertyByName[0m       did       not       return       [9Xfail[0m,
        [10XSCIntFunc.ForceRecalcEnabled(complex)[0m  did return false and the cached
        property passes a validity check the cached property is returned.
  
  (4)   Otherwise   the   property   is   first   dropped   via  the  function
        [10XSCPropertyDrop[0m  --  it  takes  a  complex  (as [10XSCPropertyObject[0m) and a
        property  name (as [10XString[0m) as arguments -- then recomputed and finally
        written back to the complex via the function [10XSCPropertySet[0m (that takes
        a complex, a property name and a property as arguments) and returned.
  
  
  [1X13.2 Writing a property handler[0X
  
  This  section  provides  the skeleton of a property handler that can be used
  when writing own property handlers:
  
  [4X---------------------------  Example  ----------------------------[0X
    [4XDeclareGlobalFunction("SCMyPropertyHandler");[0X
    [4X[0X
    [4XInstallGlobalFunction(SCMyPropertyHandler,[0X
    [4X	function(complex[, further arguments])[0X
    [4X[0X
    [4X	local myprop,....;[0X
    [4X	[0X
    [4X	# test arguments[0X
    [4X	if(not SCIsSimplicialComplex(complex)) then[0X
    [4X		SCError()("SCMyPropertyHandler: first argument must be of type[0X
    [4X					SCSimplicialComplex.\n");[0X
    [4X		return fail;[0X
    [4X	fi;[0X
    [4X[0X
    [4X	# check if the property that you want to compute is cached[0X
    [4X	myprop:=SCPropertyByName(complex,"MyProperty");[0X
    [4X[0X
    [4X	if myprop<>fail and not SCIntFunc.ForceRecalcEnabled(complex) and [0X
    [4X		[check for validity of myprop here] then[0X
    [4X		#return the cached property[0X
    [4X		return myprop;[0X
    [4X	else[0X
    [4X		# first drop the property[0X
    [4X		SCPropertyDrop(complex,"MyProperty");[0X
    [4X		[0X
    [4X		# now (re)compute the property  [0X
    [4X		[ do property computation here][0X
    [4X		[0X
    [4X		# set the newly created property and return it[0X
    [4X		SCPropertySet(complex,"MyProperty",myprop);[0X
    [4X		return myprop;[0X
    [4X	fi;[0X
    [4Xend);[0X
  [4X------------------------------------------------------------------[0X
  
