CATKBEExpressionEngineTypes Methods

Methods used to handle concepts objects, to force the evaluation in a rule and to handle the objects in error.

This page discusses:

BaseConcept.Finalize()

Method used to call the evaluation of an object. Once you have used the new function on a KML object, defined its inputs, you can use Finalize to execute the rules. This method proves useful if you must access an object in a Rule and the output attributes.

Note: This method may not evaluate the object if all logical inputs are not valuated when it is called.

Signature

BaseConcept.Finalize()

Example

Concept Adder : BaseConcept
{
                Object: VoidType;
                Attributes
                {
                                 Inputs
                                 {
                                            Integer a;
                                            Integer b;
                                 }
                }
}
Concept AdderOfAdder : BaseConcept
{
               Object : VoidType;
               Attributes
               {
                                Inputs
                                {
                                            Integer in1;
                                            Integer in2;
                                            Integer in3;
                                            Integer in4;
                                }
                                Outputs
                                {
                                             Integer outAdder;
                                }
               }
               Children
               {
                                Adder firstAdder;
                                Adder secondAdder;
               }
               Rules
               {
                                Rule
                                {
                                             /* First case, finalize is done automatically by "new" 
                                             because all inputs are valuated within the free arguments */
                                             firstAdder = new("Adder","firstAdder",this,in1,in2)

                                             secondAdder = new("Adder","secondAdder",this) 
                                             /* No input is given within the free arguments */ 
                                             secondAdder.a = in3
                                             secondAdder.b = in4

                                             secondAdder.Finalize() /* Necessary to compute the result if we 
                                             want to access it in this rule */ 

                                             outAdder = firstAdder.result + secondAdder.result
                                }
               }
} 

BaseConcept.GetErrorState()

Method used to determine if a given object is in error (true) or not (false).

Signature

BaseConcept.GetErrorState() : Boolean

ReturnType

Boolean

Example

Concept Division : BaseConcept
{
                   Attributes
                   {
                                 Inputs
                                 {
                                              Integer dividend;
                                              Integer divisor;
                                 }
                                 Outputs
                                 {
                                              Real quotient;
                                 }
                    }
                    Rules
                    {
                                  Rule
                                  {
                                               if divisor == 0
                                               {
                                                              this->PutInErrorState(TRUE)
                                                              quotient = -1
                                                              Message("Warning : Division by zero occurred !!!")
                                               }
                                   }
                    }
}
Concept Computer : BaseConcept
{
                  [...]
                  Children
                  {
                                   Divider MyDivider;
                  }
                  Rules
                  {
                                   Rule
                                   {
                                                     [...]
                                                     if MyDivider.GetInErrorState() == TRUE
                                                     {
                                                                        /* The divider result is not usable,
                                                                        we ignore it and put it back to OK state
                                                                        so that the engine can continue */
                                                                        resultOfDivision = 0
                                                                        MyDivider.PutInErrorState(FALSE)
                                                      }
                                                      else
                                                      {
                                                                        resultOfDivision = MyDivider.quotient      
                                                      }
                                  }
}

BaseConcept.PutInErrorState()

Method used to indicate that an object is in error (true). If the object is considered as "not in error" any longer, the evaluation can continue.

Signature

BaseConcept.PutInErrorState(iBoolValue: Boolean)

Arguments

NameInput / OutputRequired?TypeComment
iBoolValueInYesBooleantrue in error, false not in error.

Example

Concept Division : BaseConcept
{
                   Attributes
                   {
                                 Inputs
                                 {
                                              Integer dividend;
                                              Integer divisor;
                                 }
                                 Outputs
                                 {
                                              Real quotient;
                                 }
                    }
                    Rules
                    {
                                  Rule
                                  {
                                               if divisor == 0
                                               {
                                                              this->PutInErrorState(TRUE)
                                                              quotient = -1
                                                              Message("Warning : Division by zero occurred !!!")
                                               }
                                   }
                    }
}
Concept Computer : BaseConcept
{
                  [...]
                  Children
                  {
                                   Divider MyDivider;
                  }
                  Rules
                  {
                                   Rule
                                   {
                                                     [...]
                                                     if MyDivider.GetInErrorState() == TRUE
                                                     {
                                                                        /* The divider result is not usable,
                                                                        we ignore it and put it back to OK state
                                                                        so that the engine can continue */
                                                                        resultOfDivision = 0
                                                                        MyDivider.PutInErrorState(FALSE)
                                                      }
                                                      else
                                                      {
                                                                        resultOfDivision = MyDivider.quotient      
                                                      }
                                  }
}