![]() |
VR-Forces 4.0.4 Class Documentation
|
The MySimCommand Executor is a new class the implements a simulation command executor that uses the contents of the MySimCommand to print a message to the back-end console.
/******************************************************************************* ** Copyright (c) 2006 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: mySimCommandExecutor.h,v $ $Revision: 1.2 $ $State: Exp $ *******************************************************************************/ //\file mySimCommandExecutor.h //\brief MySimCommandExecutor. #ifndef MySimCommandExecutor_h_ #define MySimCommandExecutor_h_ #include "vrfobjcore/simCommandExecutor.h" //\brief Executor for the MySimCommand DtSimCommand. //Prints the text specified in the command to the console. class MySimCommandExecutor : public DtSimCommandExecutor { public: MySimCommandExecutor(DtSimManager* simManager); virtual ~MySimCommandExecutor(); //Prints message to the sim engine console. virtual bool execute(const DtSimCommand* command); //Prints message to the objectConsole for the named object. virtual bool execute(const DtSimCommand* command, const DtString& objectName); //\return A new instance of this class. static DtSimCommandExecutor* create(DtSimManager* simManager); private: //Not implemented. MySimCommandExecutor(); //Not implemented. MySimCommandExecutor(const MySimCommandExecutor& orig); //Not implemented. MySimCommandExecutor& operator=(const MySimCommandExecutor& orig); }; #endif
/******************************************************************************* ** Copyright (c) 2006 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: mySimCommandExecutor.cxx,v $ $Revision: 1.2 $ $State: Exp $ *******************************************************************************/ #include "mySimCommandExecutor.h" #include "vrftasks/radioMsgTypes.h" #include "vrfcore/simMgr.h" #include "vrfobjcore/vrfObjMgr.h" #include "assert.h" #include "mySimCommand.h" #include <vlutil/vlPrint.h> #include "vrfobjcore/vrfObject.h" #include "vrfobjcore/objectConsole.h" MySimCommandExecutor::MySimCommandExecutor(DtSimManager* simManager) : DtSimCommandExecutor(simManager) { } MySimCommandExecutor::~MySimCommandExecutor() { } bool MySimCommandExecutor::execute(const DtSimCommand* command) { assert(command->type() == MySimCommandType); const MySimCommand* msgCommand = static_cast<const MySimCommand*>(command); DtInfo << msgCommand->messageText() << std::endl; return true; } bool MySimCommandExecutor::execute(const DtSimCommand* command, const DtString& objectName) { assert(command->type() == MySimCommandType); const MySimCommand* msgCommand = static_cast<const MySimCommand*>(command); DtVrfObject* obj = mySimManager->vrfObjectManager()->lookupVrfObjectByName( objectName); if (obj) { obj->objectConsoleWarn() << msgCommand->messageText() << std::endl; } else { DtInfo << "MySimCommand: Could not find entity: " << objectName.string() << std::endl; } return true; } DtSimCommandExecutor* MySimCommandExecutor::create(DtSimManager* simManager) { return new MySimCommandExecutor(simManager); }