BOCL Evaluator#
- class bocl.Evaluator.Evaluator[source]#
Bases:
objectThe Evaluator class evaluates the OCL constraints based on the object model.
Args:
- debug = this attribute is used for debugging purposes and with default value false
- allObjSat = list of all objects that satisfy the contraint
- addToExp(item, logicalExp)[source]#
The addToExp function adds the item to logicalExpression.
- Parameters:
item – item to add in Logical Expression
logicalExp – logical Expression
- checkAndAdd(logicalExpTemplate, toAdd)[source]#
The checkAndAdd function checks and updates the logical expression.
- Parameters:
toAdd – item to add in the logical expression
logicalExpTemplate – Expression to evaluate at the end to get the result
- checkInLinkEnds(obj, source)[source]#
The checkInLinkEnds function identifies the source in the linkend of the object.
- Parameters:
obj – Object from object model
source – source of the current object in the CSTree
- checkInObj(obj, source)[source]#
The checkInObj function identifies the object that contains the source in slots.
- Parameters:
obj – Object from object model
source – source of the current object in the CSTree
- evaluate(rootHandler, objectModel)[source]#
the evaluate function is the main function to be called for evaluating any contraint.
- Parameters:
rootHandler – Object of class RootHandler that handles the tree
objectModel – Object Model from BUML models
- getID(slots)[source]#
The getID function gets the ID attribute from the Object.
- Parameters:
slots – slots of the object
- getValidObjects(contextName, objs)[source]#
the getValidObjects returns all the objects the constraint should be applied on
- Parameters:
contextName – name of the context of OCL constraint
objs – all objects from object model
- get_value(name, obj)[source]#
The get_value function to retrieve value of attribute from object.
- Parameters:
name – name of the attribute
object – Object from object model
- handle(source, obj, logicalExp, rightSide=False)[source]#
The handle function handles Property Call expression from OCL MM.
- Parameters:
source – one child in OCL CST
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
rightSide – to identify the side of logical expression
- handleCollect(tree, allObjs, logicalExp)[source]#
The handleCollect function handles collect construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
allObjs – all objects from object model
logicalExp – Expression to evaluate at the end to get the result
- handleExcludes(tree, obj, logicalExp)[source]#
The handleExcludes function handles excludes construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- handleExists(tree, allObjs, logicalExp)[source]#
The handleExists function handles exists construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
allObjs – all objects from object model
logicalExp – Expression to evaluate at the end to get the result
- handleForAll(tree, allObjs, logicalExp)[source]#
The handleForAll function handles forAll expression from OCL MM.
- Parameters:
tree – Tree that is constructed using OCL Parser
allObjs – all objects from object model
logicalExp – Expression to evaluate at the end to get the result
- handleIFExp(tree, obj, logicalExp)[source]#
The handleIFExp function handles the If construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- handleIncludes(tree, obj, logicalExp)[source]#
The handleIncludes function handles includes construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- handleOCLIsTypeOf(tree, obj, logicalExp)[source]#
The handleOCLIsTypeOf function handles the OCLIsTypeOf construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- handleSize(tree, obj, logicalExp)[source]#
The handleSize function handles the size construct.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- preprocessLogicalExp(exp)[source]#
the preprocessLogicalExp function preprocesses before evaluating to correct the syntax.
- Parameters:
exp – logical expression to be evaluated
- update_logical_exp(tree, logicalExp, obj)[source]#
The update_logical_exp function updates the logical expression.
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
- valid_object(contextName, object)[source]#
the valid_object verifies if the current object is the one constraint is applied on
- Parameters:
contextName – name of the context of OCL constraint
Object – Object from object model to check
- verifyBody(tree, obj, logicalExp, source, allObjs=None)[source]#
The verifyBody function verifies the body of different constructs (e.g., forAll, exists).
- Parameters:
tree – Tree that is constructed using OCL Parser
obj – one object from object model
logicalExp – Expression to evaluate at the end to get the result
source – source of the obj in CSTree