VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Condition Evaluator

The MyEvaluator is a new class that will use the MySearch class to evaluate whether or not the entity in question is facing north


Header file:

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#pragma once
//class MyEvaluator:
//
//Instances of MyEvaluator are used to perform the evaluation for a
//MyConditionalExpression using a MySearch.
namespace vrfAddConditionalExample
{
class MyEvaluator : public DtEvalSimulationObject
{
public:
//constructor
//destructor
virtual ~MyEvaluator();
//copy constructor
MyEvaluator(const MyEvaluator& orig);
//assignment operator
//clone operator
virtual DtEvaluator* clone();
//Evaluate this conditional expression for the entity with the given
//entity name, in the context of the given DtSimulationServices,
//and return the current result. The condExpr passed in must be of type
//MyConditionalExpression.
//Checks to see if the entity in the MyConditionalExpression is
//facing north using a MySearch. If so, it returns true. The the modifier
//flag in MyConditionalExpression is passed to the search which optionally
//expands the test to return true if the entity and/or any of its
//subordinates are facing north.
virtual bool evaluate(DtSimCondExpr* condExpr,
DtLocalObject* owner, const DtSimulationServices* simManager, const DtPlan* plan = 0) const;
public:
//Returns a newly created MyEvaluator.
static DtEvaluator * creator();
};
}

Implementation:

/*******************************************************************************
** Copyright (c) 2015 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//Example includes
#include "northEvaluator.h"
#include "search.h"
//VR-Forces includes
#include "vrfplan/plan.h"
#include "vrfplan/plan.h"
//VR-Link includes
#include <vlutil/vlPrint.h>
namespace vrfAddConditionalExample
{
{
}
{
}
MyEvaluator::MyEvaluator(const MyEvaluator& orig) :
{
}
MyEvaluator& MyEvaluator::operator=(
const MyEvaluator& orig)
{
if (this == &orig)
{
return *this;
}
return *this;
}
DtEvaluator* MyEvaluator::clone()
{
return new MyEvaluator(*this);
}
bool MyEvaluator::evaluate(DtSimCondExpr* condExpr,
DtLocalObject* owner,
const DtSimulationServices* simManager,
const DtPlan* plan) const
{
MyConditionalExpression* conditional =
dynamic_cast<MyConditionalExpression*>(condExpr);
if (!conditional)
{
DtWarn("DtAndEvaluator::evaluate() : invalid conditional expression\n");
DtWarn("The expression must be of type MyConditionalExpression\n");
return false;
}
//Search the entity tree for a match.
MySearch search;
search.setModifier(conditional->modifier());
// initializeObjectToCheck will substitute and return variables into the base entity to check, if need be
return search.search(initializeObjectToCheck(condExpr, conditional->entity(), plan), owner, simManager);
}
DtEvaluator * MyEvaluator::creator()
{
return new MyEvaluator();
}
}

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)