VR-Forces 4.0.4 Class Documentation
examples/addPSR/timeKeeperCmpt.h
Go to the documentation of this file.
00001 /********************************************************************************* Copyright (c) 2004 MAK Technologies, Inc.
00002 ** All rights reserved.
00003 *******************************************************************************//********************************************************************************* $RCSfile: timeKeeperCmpt.h,v $ $Revision: 1.3 $ $State: Exp $
00004 *******************************************************************************/
00005 
00006 //
00007 //class DtTimeKeeperComponent
00008 //
00009 //This is a component which simply keeps track of the elapsed simulation time
00010 //since the component was created.  It illustrates the creation and use of
00011 //a process state repository to save the simulation time since creation
00012 //into a checkpointed scenario file, and read it back in at load time.
00013 //
00014 
00015 #include "vrfobjcore/simCmpnt.h"
00016 
00017 class DtTimeKeeperPSR;
00018 
00019 //String which uniquely identifies this controller
00020 const char TimeKeeperComponentType[] = "time-keeper-component";
00021 
00022 class DtTimeKeeperComponent : public DtSimComponent
00023 {
00024 public:
00025    //constructor
00026    DtTimeKeeperComponent(const DtString & name, DtVrfObject* owner, 
00027       DtSimManager * simManager, DtComponentDescriptor* desc = NULL,
00028       DtReaderWriterRegistry * parentRegistry = 0);
00029 
00030    //destructor
00031    virtual ~DtTimeKeeperComponent();
00032 
00033    //copy constructor
00034    DtTimeKeeperComponent(const DtTimeKeeperComponent& orig);
00035 
00036    //assignment operator
00037    DtTimeKeeperComponent& operator=(const DtTimeKeeperComponent& orig);
00038 
00039    //Returns the string type for this component.
00040    virtual DtString type() const;
00041 
00042    //Overridden from the base class to call createPSR().
00043    virtual bool init();
00044 
00045    //Create a time-keeper process state repository, or a different 
00046    //type if it is specified in the OPD.
00047    virtual bool createPSR();
00048 
00049    //Update control values
00050    //For this controller, we simply add dT() to our elapsed time 
00051    //state variable, and print out the value every 10 seconds of 
00052    //simulation time.
00053    virtual void tick();
00054 
00055    //This is called by the factory
00056    static DtSimComponent* creator(const DtString & name, DtVrfObject* owner,
00057       DtSimManager * simManager, DtComponentDescriptor* desc,
00058       DtReaderWriterRegistry * parentRegistry);
00059 
00060 protected:
00061    //This is the pointer to our process state repository used during
00062    //the execution of the simulation.
00063    DtTimeKeeperPSR* myProcessState;
00064 };
00065 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)