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

The MySimCommand is a new class that implements a simulation command that prints a message to the console when executed


Header file:

/*******************************************************************************
** Copyright (c) 2006 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
//\file consoleMessageCommand.h
//\brief DtConsoleMessageCommand.
#pragma once
#include <vlutil/vlPrint.h>
const DtSimCommandMessageType MySimCommandType("my-sim-command");
//\brief DtSimCommand which causes a console message to be printed.
//This command will simply print a message to the back-end console
class MySimCommand : public DtSimCommand
{
public:
//Default constructor
//Usual constructor
MySimCommand(const DtString& writeName,
DtReaderWriterRegistry* parentRegistry = NULL);
//copy constructor
MySimCommand(const DtString & writeName, const MySimCommand& orig,
DtReaderWriterRegistry* parentRegistry = NULL);
//destructor
virtual ~MySimCommand();
//assignment operator
//\return MySimCommandType.
const DtSimCommandMessageType& type() const;
//\return A new instance of this class, copied from the original.
parentRegistry = 0) const;
//Message to print to console
virtual DtString messageText() const;
virtual void setMessageText(const DtString& text);
//Text representation of this command.
virtual DtString stringRep() const;
//\copydoc DtSimCommand::netRepSize()
virtual int netRepSize() const;
//\copydoc DtSimCommand::setFromNet()
virtual bool setFromNet(const char* contentBuffer,
unsigned contentSize);
//\copydoc DtSimCommand::setToNet()
virtual bool setToNet();
//Returns a new instance of this class.
static DtSimCommand* creator();
protected:
};

Implementation:

/*******************************************************************************
** Copyright (c) 2006 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: mySimCommand.cxx,v $ $Revision: 1.1 $ $State: Exp $
*******************************************************************************/
#include "../addSimCommandSim/mySimCommand.h"
using namespace DtBufferSerialize;
myMessageText("text", &myRegistry)
{
}
DtReaderWriterRegistry* parentRegistry) :
DtSimCommand(writeName, parentRegistry),
myMessageText("text", &myRegistry)
{
}
MySimCommand::MySimCommand(const DtString & writeName, const MySimCommand& orig,
DtReaderWriterRegistry* parentRegistry) :
DtSimCommand(writeName, orig, parentRegistry),
myMessageText(orig.myMessageText.name(), &myRegistry)
{
myMessageText = orig.myMessageText;
}
{
}
{
if (this != &orig)
{
}
return *this;
}
{
}
parentRegistry) const
{
return new MySimCommand(name, *this, parentRegistry);
}
{
return myMessageText;
}
{
myMessageText = text;
}
{
DtString str;
str += "Print Console Message: ";
str += myMessageText;
return str;
}
{
return size;
}
bool MySimCommand::setFromNet(const char* contentBuffer,
unsigned contentSize)
{
if (!DtSimCommand::setFromNet(contentBuffer, contentSize))
{
return false;
}
contentBuffer += DtSimCommand::netRepSize();
contentBuffer = decode(myMessageText, contentBuffer);
return true;
}
{
{
return false;
}
char* buffer = netRep();
buffer = encode(myMessageText, buffer);
return true;
}
{
return new MySimCommand();
}

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)