VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Time Keeper PSR

This subclass of the DtVrfProcessStateRepository allows a controller to store the current elapsed time


Header file:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: timeKeeperPSR.h,v $ $Revision: 1.2 $ $State: Exp $
*******************************************************************************/

#ifndef DtTimeKeeperPSR_H_
#define DtTimeKeeperPSR_H_

#include "vrfobjcore/vrfProcessStateRepository.h"
#include "vrfutil/rwReal.h"

//class DtTimeKeeperPSR:
//
//This is a sample Process State Repository which has only one value
//which is elapsed time.  This data will be written to and read from 
//the OOB file when a scenario checkpoint is saved and loaded.

extern const char* TimeKeeperPSRType;

class DtTimeKeeperPSR : public DtVrfProcessStateRepository
{
public:

   //constructor
   DtTimeKeeperPSR(DtVrfObject* vrfObject, 
      const DtString& rwName = DtString::nullString(), 
      DtReaderWriterRegistry*  parentRegistry = 0);

   //copy constructor
   DtTimeKeeperPSR(const DtTimeKeeperPSR& orig,
      const DtString& rwName = DtString::nullString(), 
      DtReaderWriterRegistry*  parentRegistry = 0);

   //destructor
   virtual ~DtTimeKeeperPSR();

   //assignment operator
   DtTimeKeeperPSR& operator=(const DtTimeKeeperPSR& orig);

   //returns a newly created copy of this object
   virtual DtVrfProcessStateRepository* clone(
      const DtString& rwName = DtString::nullString(), 
      DtReaderWriterRegistry*  parentRegistry = 0) const;

   //Returns the string type of this process state repository.
   virtual DtString type() const;

   //Get / Set the elapsed time state variable.
   virtual void setElapsedTime(double time);
   virtual double elapsedTime() const;

public:

   //Returns a newly created instance of this class.
   static DtVrfProcessStateRepository* creator (const DtString& rwName,
      DtVrfObject* vrfObject, DtReaderWriterRegistry* parentRegistry);

protected:

   DtRwReal myElapsedTime;
};

#endif

Implementation:

/*******************************************************************************
** Copyright (c) 2004 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: timeKeeperPSR.cxx,v $ $Revision: 1.1 $ $State: Exp $
*******************************************************************************/

#include "timeKeeperPSR.h"

const char* TimeKeeperPSRType = "time-keeper-psr-type";

//Constructor.
//Set the names and initial values of any RW elements of this PSR.
//Here myElapsedTime is set up.
DtTimeKeeperPSR::DtTimeKeeperPSR(DtVrfObject* vrfObject, const DtString& rwName,
   DtReaderWriterRegistry*  parentRegistry) :
   DtVrfProcessStateRepository(vrfObject, rwName, parentRegistry),
   myElapsedTime("elapsed-time", 0.0, &myRegistry)
{
}

//Copy over any state variables in the copy constructor and register
//them with the new parent registry.
DtTimeKeeperPSR::DtTimeKeeperPSR(const DtTimeKeeperPSR& orig, 
   const DtString& rwName, 
   DtReaderWriterRegistry*  parentRegistry) :
   DtVrfProcessStateRepository(orig, rwName, parentRegistry),
   myElapsedTime(orig.myElapsedTime, &myRegistry)
{
}

DtTimeKeeperPSR::~DtTimeKeeperPSR()
{
}

DtTimeKeeperPSR& DtTimeKeeperPSR::operator=(const DtTimeKeeperPSR& orig)
{
   if(this == &orig)
   {
      return *this;
   }

   DtVrfProcessStateRepository::operator=(orig); 

   myElapsedTime = orig.myElapsedTime;

   return *this;
}

DtVrfProcessStateRepository* DtTimeKeeperPSR::clone(const DtString& rwName,  
   DtReaderWriterRegistry*  parentRegistry) const
{
   return new DtTimeKeeperPSR(*this, rwName, parentRegistry);
}

DtString DtTimeKeeperPSR::type() const
{
   return TimeKeeperPSRType;
}

DtVrfProcessStateRepository* DtTimeKeeperPSR::creator(const DtString& rwName,
   DtVrfObject* vrfObject, DtReaderWriterRegistry* parentRegistry)
{
   return new DtTimeKeeperPSR(vrfObject, rwName, parentRegistry);
}

void DtTimeKeeperPSR::setElapsedTime(double time)
{
   myElapsedTime = time;
}

double DtTimeKeeperPSR::elapsedTime() const
{
   return myElapsedTime;
}


Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)