![]() |
VR-Forces 4.0.4 Class Documentation
|
The MyIndividualLocalEntityNetInterface class takes the mass from the DtVrfObjectStateRepository class and puts it into the new MyEntityStateRep for transmission over the network
/******************************************************************************* ** Copyright (c) 2004 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: myIndLclNetIf.h,v $ $Revision: 1.5 $ $State: Exp $ *******************************************************************************/ #ifndef MyIndividualLocalEntityNetInterface_H_ #define MyIndividualLocalEntityNetInterface_H_ #include "vrfobjcore/indLclNetIf.h" class MyIndividualLocalEntityNetInterface : public DtSimIndividualLocalEntityNetInterface { public: //read/writable contructor MyIndividualLocalEntityNetInterface(const DtString & name, DtVrfObject * simObject, DtReaderWriterRegistry * parentRegistry = 0, bool publishObject = true); //destructor virtual ~MyIndividualLocalEntityNetInterface(); //Copies the mass from the VR-Forces state repository into the //VR-Link state repository for publication. virtual void updatePublisher(); //Overridden to completely replace the default VR-Forces interface. //See the comment in the definition. virtual DtString type() const; //Creates a new MyIndividualLocalEntityNetInterface static DtSimObjectNetInterface * creator(const DtString & name, DtVrfObject * simObject, DtReaderWriterRegistry * parentRegistry, bool publishObject); protected: //default constructor; not implemented MyIndividualLocalEntityNetInterface(); //copy constructor; not implemented MyIndividualLocalEntityNetInterface(const MyIndividualLocalEntityNetInterface & orig, DtReaderWriterRegistry * parentRegistry = 0); //assignment operator; not implemented const MyIndividualLocalEntityNetInterface & operator=(const MyIndividualLocalEntityNetInterface & orig); }; #endif
/******************************************************************************* ** Copyright (c) 2004 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: myIndLclNetIf.cxx,v $ $Revision: 1.6 $ $State: Exp $ *******************************************************************************/ #include "myIndLclNetIf.h" #include "myEsr.h" #include "vrfobjcore/vrfNetIfTypes.h" #include "vrfobjcore/vrfObject.h" #include "vrfobjcore/vrfObjSR.h" //read/writable contructor MyIndividualLocalEntityNetInterface:: MyIndividualLocalEntityNetInterface(const DtString & name, DtVrfObject * simObject, DtReaderWriterRegistry * parentRegistry, bool publishObject) : DtSimIndividualLocalEntityNetInterface(name, simObject, parentRegistry, publishObject) { } //destructor MyIndividualLocalEntityNetInterface:: ~MyIndividualLocalEntityNetInterface() { } void MyIndividualLocalEntityNetInterface::updatePublisher() { DtEntityStateRepository * netState = individualNetworkState(); MyEntityStateRep* massState = dynamic_cast<MyEntityStateRep*>(netState); if (!massState) { DtWarn("Cannot cast net state to MyEntityStateRep\n"); DtSimIndividualLocalEntityNetInterface::updatePublisher(); return; } DtVrfObjectStateRepository * localState = mySimObject->vrfState(); if (!localState) { DtWarn("Cannot find DtVrfObjectStateRepository\n"); DtSimIndividualLocalEntityNetInterface::updatePublisher(); return; } //Copy the mass value to the network state from the vrf state. //In this case, the vrf state already has a value which corresponds //to the one added to the FOM. If extending the FOM with a value which //doesn't already exist in the vrf state, a new subclass must be created. //For an example of creating a new vrf state, see the "addEntity" example. massState->setMass(localState->mass()); DtSimIndividualLocalEntityNetInterface::updatePublisher(); } DtString MyIndividualLocalEntityNetInterface::type() const { //Registering this VR-Forces default string (defined in vrfNetIfTypes.h) //has the effect of changing the net interface for all OPE entries which //use this string for their "net-interface" parameter. return DtSimIndividualLocalEntityNetInterfaceType; } DtSimObjectNetInterface * MyIndividualLocalEntityNetInterface::creator( const DtString & name, DtVrfObject * simObject, DtReaderWriterRegistry * parentRegistry, bool publishObject) { return new MyIndividualLocalEntityNetInterface(name, simObject, parentRegistry, publishObject); }