lgrRecordDriver.h
Go to the documentation of this file.
00001 /******************************************************************************
00002 ** Copyright (c) 1992-2010 VT MAK
00003 ** All rights reserved.
00004 ******************************************************************************/
00005 
00009 
00010 #ifndef lgrRecordDriver_H_
00011 #define lgrRecordDriver_H_
00012 
00013 #include "lgrDriver.h"
00014 #include "absoluteTime.h"
00015 #include "messageBuffer.h"
00016 #include <vlutil/vlRunnable.h>
00017 
00018 class DtThread;
00019 
00020 namespace MAKLogger
00021 {
00022    class DtCheckpointPolicy;
00023    class DtLgrClock;
00024    class DtLgrFileInput;
00025    class DtLgrFileOutput;
00026    class DtLgrPlaybackDriver;
00027    class DtLgrRecordCommandFactory;
00028    class DtLgrRecordInterface;
00029    class DtMessagePipeline;
00030    class DtThreadedObject;
00031    class DtLgrEditorThread;
00032 
00036    class DT_DLL_LGRCORE DtLgrRecordDriver : public DtLgrCommandHandler
00037    {
00038    public:
00039       typedef DtLgrRecordCommandFactory Factory;
00040       typedef DtLgrRecordInterface Interface;
00041 
00042       DT_VIRTUAL_CTR(DtLgrRecordDriver,(DtLgrSystemDriver&))
00043 
00044       virtual ~DtLgrRecordDriver();
00045 
00047       virtual void tick();
00048 
00049       virtual bool releasePipeline();
00050       virtual bool getPipeline();
00051       virtual bool hasPipeline() const;
00052 
00053       virtual bool isFileOpen() const;
00054       virtual bool isFileEmpty() const;
00055 
00056       virtual bool isRecording() const;
00057       virtual bool isPaused() const;
00058 
00060       virtual bool pauseOnRecordAs() const;
00061 
00063       int checkpointPolicyId() const;
00064 
00066       int checkpointCount() const;
00067 
00069       int checkpointSize() const;
00070 
00072       DtAbsoluteTime checkpointTime() const;
00073 
00076       virtual const DtString& filename() const;
00077 
00082       virtual DtCheckpointPolicy* duplicateCheckpointPolicy() const;
00083 
00085       virtual bool recordToMultipleFiles() const;
00086 
00088       virtual double multipleFileDuration() const;
00089 
00091       const DtString& multipleFileNamingConvention() const;
00092 
00094       virtual const DtLgrFileOutput* currentOutput() const;
00095 
00097       virtual bool spawnThread(DtLgrEditorThread* editorThread);
00098 
00100       virtual void stopAllThreads();
00101 
00103       virtual void stopThread( DtLgrEditorThread* runningThread );
00104 
00106       virtual void addTemporaryTrackedEntity(const DtString& name);
00107 
00108    protected:
00109 
00111       DtLgrPlaybackDriver* getPlaybackDriver(bool checkForFileOpen) const;
00112 
00114       virtual void setCheckpointPolicy(DtCheckpointPolicy* policy);
00115 
00117       void tickNormalRecording();
00118 
00120       void tickRecordToMultipleFiles(double multipleFileDuration);
00121 
00122       DtResponse newFile(const DtCommand& command);
00123       DtResponse closeFile(const DtCommand& command);
00124       DtResponse cancelRecording(const DtCommand& command);
00125       DtResponse record(const DtCommand& command);
00126       DtResponse pause(const DtCommand& command);
00127       DtResponse unpause(const DtCommand& command);
00128       DtResponse stop(const DtCommand& command);
00129       DtResponse stopCondition(const DtCommand& command);
00130       DtResponse stopDuration(const DtCommand& command);
00131       DtResponse stopSize(const DtCommand& command);
00132       DtResponse setCheckpointParameters(const DtCommand& command);
00133       DtResponse setPauseOnRecordAs(const DtCommand& command);
00134       DtResponse saveRecordedData(const DtCommand& command);
00135       DtResponse saveRecordedDataFinished(const DtCommand& command);
00136       DtResponse setRecordToMultipleFilesSettings(const DtCommand& command);
00137       DtResponse startRecordToMultipleFiles(const DtCommand& command);
00138 
00139       class DumpCurrentRecordingThread : public DtRunnable
00140       {
00141       public:
00142          DumpCurrentRecordingThread( MAKLogger::DtLgrSystemDriver* driver,
00143             DtString newFileName, DtLgrFileInput* input,
00144             DtLgrFileOutput* output, int packetOperationCount,
00145             double fixedDuration,DtRelativeTime offset);
00146 
00147          virtual ~DumpCurrentRecordingThread();
00148 
00149          virtual void run();
00150 
00151       protected:
00152          DtCommandInterface* myInterface;
00153          DtString myFilename;
00154          DtLgrFileInput* myInputFile;
00155          DtLgrFileOutput* myOutput;
00156          int  myPacketOperationCount;
00157          DtRelativeTime myFixedDuration;
00158          DtRelativeTime myOffset;
00159       };
00160 
00161 
00162       virtual void configurePipeline();
00163 
00164       virtual bool doNewFile(DtString filename,bool overwrite);
00165       virtual bool doRecord(bool multipleFiles);
00166       virtual bool doStop();
00167       virtual bool doPause();
00168       virtual bool doUnpause();
00169 
00171       DtString multipleFileName() const;
00172 
00173       DtString myFileName;
00174       DtLgrFileOutput* myFileOutput;
00175       DtLgrSystemDriver* myDriver;
00176       DtMessagePipeline* myPipeline;
00177 
00179       DtCheckpointPolicy* myCheckpointPolicy;
00180       int myCheckpointPolicyId;
00181       int myCheckpointPolicyCount;
00182       int myCheckpointPolicySize;
00183       DtAbsoluteTime myCheckpointPolicyTime;
00184 
00185       DtLgrClock* myRecordingClock;
00186       DtAbsoluteTime myCurrentTime;
00187 
00188       bool myRecordingFlag;
00189       bool myPausedFlag;
00190       bool myPauseOnRecordAsFlag;
00191       bool myFileEmptyFlag;
00192       int myStopCondition;
00193       bool myStopConditionClose;
00194       DtRelativeTime myStopDuration;
00195       DtU64 myStopSize;
00196       int myPacketOperationCount;
00197       bool mySavingRecordingData;
00198       DtThreadedObject* myDumpThread;
00199 
00200       bool myRecordToMultipleFiles;
00201       double myMultipleFileDuration;
00202       DtString myMultipleFileNamingConvention;
00203       DtAbsoluteTime myTimeToSaveMultipleFiles;
00204       int myMultipleFileIndex;
00205       DtFilePosition myNextSavePosition;
00206       DtMessageBuffer* myCompleteState;
00207 
00208 
00210       typedef std::map<DtLgrEditorThread*,DtThread*> ThreadMap;
00211 
00213       ThreadMap myRunningThreads;
00214 
00216       DtMessageBuffer myPauseTimeSnapshot;
00217    };
00218 
00219 }
00220 
00221 #endif

Document ID: Generated on Tue Oct 11 19:41:03 EDT 2011 from SVN revision 107422
Copyright © 2005-2011 VT MÄK Inc. All Rights Reserved (www.mak.com)