Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
(**
	Check basic elements for EXTENSION_SCHEMA
	Should compile with no errors	
*)
EXPRESS_EXTENSION_SCHEMA  EEX_1011 FOR IFC4;
GLOBAL
	gGeneric		: GENERIC;
	gGenericEntity	: GENERIC_ENTITY;
	geexEntity		: eexEntity;	
END_GLOBAL;

CONSTANT
	cInteger : INTEGER := 1;	
END_CONSTANT;

    ENTITY eexEntity;
        explicitAttr1 : INTEGER;
        explicitAttr2 : GENERIC_ENTITY;
	DERIVE
		derivedAttr1  : STRING := foo1(SELF);
		derivedAttr2  : STRING := foo2(SELF);		
    INVERSE
		cross_references : SET OF GENERIC_ENTITY FOR ALL_CROSS_MODEL_REFERENCES_TO_ME;
		local_refs: SET OF  GENERIC_ENTITY FOR ALL_LOCAL_REFS_TO_ME;		
    END_ENTITY;
 

    ENTITY eexTask SUBTYPE OF(ifcTask);
        explicitAttr1 : INTEGER;
    END_ENTITY;
 
    ENTITY_EXTENSION extToIfcSpace FOR  IfcSpace;
       (* Attribute name must be unique within the extended entity (ifcxx1), may be same as
          attribute names in super type Entity. When so, this extended attribute must be
          accessed by name using "full qualified attribute name".
          The attribute domains can be any domain in the actual schema or domain (instance type)
          defined in the current extension schema
       *)
       extendedExplicitAttr1 : STRING;           -- any simple data type can be used, not defined types
       extendedExplicitAttr2 : GENERIC_ENTITY;   --sdaiINSTANCE of any type. can be used as link to instance in any other model.
       extendedExplicitAttr3 : SET OF GENERIC_ENTITY;
    DERIVE
        extendedDeriveAttr : SET OF GENERIC_ENTITY := foo4(SELF);
    INVERSE
		cross_references 	: SET OF GENERIC_ENTITY FOR ALL_CROSS_MODEL_REFERENCES_TO_ME;
		local_refs			: SET OF GENERIC_ENTITY FOR ALL_LOCAL_REFS_TO_ME;		
		-- extendedInverseAttr 	: SET OF GENERIC_ENTITY FOR (entityx.explicitAttr1, entityx.explicitAttr2, ...entityz.explicitAttr5);
    END_ENTITY_EXTENSION;
	

    ENTITY_EXTENSION extToIfcElementSubtypes FOR SUBTYPE IfcElement;
       (* same as ENTITY_EXTENSION except that all extensions will be valid for all subtypes of the extended entity, i.e., all subtypes of IfcElement  *)
       extendedExplicitAttr1 : STRING;           -- any simple data type can be used, not defined types
--    INVERSE
--		extendedInverseAttr : SET OF GENERIC_ENTITY FOR (entityx.explicitAttr1, entityx.explicitAttr2, ...entityz.explicitAttr5);
    END_ENTITY_EXTENSION;
	
	FUNCTION foo1(arg : GENERIC) : STRING;
		RETURN('typename');
	END_FUNCTION;
	
	FUNCTION foo2(arg : GENERIC_ENTITY) : STRING;
		RETURN('typename');
	END_FUNCTION;


	FUNCTION foo4(arg : GENERIC_ENTITY) : SET OF GENERIC_ENTITY;
	LOCAL
		result : SET OF GENERIC_ENTITY := [];
	END_LOCAL;
		RETURN(?);
	END_FUNCTION;

	
	PROCEDURE poo1(arg1 : GENERIC;VAR arg2: GENERIC);
		arg1.explicitAttr1 := 2;
		arg2.explicitAttr1 := 2;
	END_PROCEDURE;

	PROCEDURE poo2(arg1 : GENERIC_ENTITY;VAR arg2: GENERIC_ENTITY);
		arg1.explicitAttr1 := 2;
		arg2.explicitAttr1 := 2;
	END_PROCEDURE;

-- AET 20181101 - proposal for methods in entities:
-- enhance DERIVE to allow parameters - then the "attribute" becomes a method:
-- there are several possible variants of syntax, see this as an example 


-- Example: add MOVE method to cartesian point 

    ENTITY_EXTENSION ext2IfcCartesianPointSpace FOR  IfcCartesianPoint;
    DERIVE
        -- move the point in direction given by x,y,z return the updated point
        Move(x,y,z: IfcLengthMeasure) : IfcCartesianPoint := IfcCartesianPoint_Move(SELF,x,y,z);
    END_ENTITY_EXTENSION;
    
   -- note that VAR must be allowed here, if no VAR we would just move a copy of the point
   FUNCTION IfcCartesianPoint_Move(VAR p: IfcCartesianPoint;  x,y,z: IfcLengthMeasure): IfcCartesianPoint; 
        p.Coordinates[1] := p.Coordinates[1] + x;
        p.Coordinates[2] := p.Coordinates[2] + y;
        p.Coordinates[3] := p.Coordinates[3] + z;
        RETURN(p);
   END_FUNCTION;


-- variant: declare method directly as "function" - the term "FOR <entity> indicates it is a method
   FUNCTION Move(x,y,z: IfcLengthMeasure) FOR IfcCartesianPoint: IfcCartesianPoint; 
        SELF.Coordinates[1] := SELF.Coordinates[1] + x;
        SELF.Coordinates[2] := SELF.Coordinates[2] + y;
        SELF.Coordinates[3] := SELF.Coordinates[3] + z;
        RETURN(SELF);
   END_FUNCTION;


-- easier to read but defines new operator "scope resolution" = '::'
-- Arnes Favourite :)
   FUNCTION IfcCartesianPoint::Move(x,y,z: IfcLengthMeasure): IfcCartesianPoint; 
        SELF.Coordinates[1] := SELF.Coordinates[1] + x;
        SELF.Coordinates[2] := SELF.Coordinates[2] + y;
        SELF.Coordinates[3] := SELF.Coordinates[3] + z;
        RETURN(SELF);
   END_FUNCTION;


-- variant: declare method inside entity - uses BEGIN and END keywords. Arne does not like it :(
    ENTITY_EXTENSION ext2IfcCartesianPointSpace FOR  IfcCartesianPoint;
    DERIVE
        Move : IfcCartesianPoint(x,y,z: IfcLengthMeasure) : IfcCartesianPoint;
			BEGIN
		        SELF.Coordinates[1] := SELF.Coordinates[1] + x;
        		SELF.Coordinates[2] := SELF.Coordinates[2] + y;
		        SELF.Coordinates[3] := SELF.Coordinates[3] + z;
        		RETURN(SELF);
 			END; 
    END_ENTITY_EXTENSION;

-- END_AET 20181101 - proposal for methods in entities:

END_EXPRESS_EXTENSION_SCHEMA;

...