VR-Forces 4.1 Class Documentation
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) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: northEvaluator.h,v $ $Revision: 1.4 $ $State: Exp $
*******************************************************************************/
#ifndef MyEvaluator_H_
#define MyEvaluator_H_
//class MyEvaluator:
//
//Instances of MyEvaluator are used to perform the evaluation for a
//MyConditionalExpression using a MySearch.
namespace vrfAddConditionalExample
{
class MyEvaluator : public DtEvaluator
{
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 DtSimManager,
//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,
const DtString& echelonId, DtSimManager* simManager) const;
public:
//Returns a newly created MyEvaluator.
static DtEvaluator * creator();
};
#endif
}

Implementation:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: northEvaluator.cxx,v $ $Revision: 1.4 $ $State: Exp $
*******************************************************************************/
//Example includes
#include "northEvaluator.h"
#include "search.h"
//VR-Forces includes
#include "vrfplan/plan.h"
#include "vrfcore/simMgr.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;
}
{
return new MyEvaluator(*this);
}
const DtString& echelonId,
DtSimManager* simManager) 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;
}
if (simManager == NULL)
{
DtWarn("MyEvaluator::evaluate called without valid DtSimManager!");
return false;
}
DtVrfObjectManager* objectManager = simManager->vrfObjectManager();
if (objectManager == NULL)
{
DtWarn("MyEvaluator::evaluate cannot access DtVrfObjectManager\n");
return false;
}
//Search the entity tree for a match.
MySearch search;
search.setModifier(conditional->modifier());
return search.search(conditional->entityName(), echelonId, simManager);
}
DtEvaluator * MyEvaluator::creator()
{
return new MyEvaluator();
}
}

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)