~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Open Mash Cross Reference
mash/archive/archive-stream.h

Component: ~ [ mash ] ~ [ apps ] ~ [ gsm ] ~ [ lib ] ~ [ otcl ] ~ [ srm ] ~ [ tcl8.3 ] ~ [ tclcl ] ~ [ tk8.3 ] ~ [ tutorials ] ~

  1 /*
  2  * archive-stream.h --
  3  *
  4  *      This file contains the definitions for the C++ archive file objects.
  5  *
  6  * Copyright (c) 1997-2002 The Regents of the University of California.
  7  * All rights reserved.
  8  *
  9  * Redistribution and use in source and binary forms, with or without
 10  * modification, are permitted provided that the following conditions are met:
 11  *
 12  * A. Redistributions of source code must retain the above copyright notice,
 13  *    this list of conditions and the following disclaimer.
 14  * B. Redistributions in binary form must reproduce the above copyright notice,
 15  *    this list of conditions and the following disclaimer in the documentation
 16  *    and/or other materials provided with the distribution.
 17  * C. Neither the names of the copyright holders nor the names of its
 18  *    contributors may be used to endorse or promote products derived from this
 19  *    software without specific prior written permission.
 20  *
 21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
 22  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 24  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
 25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 31  * POSSIBILITY OF SUCH DAMAGE.
 32  *
 33  * @(#) $Header: /usr/mash/src/repository/mash/mash-1/archive/archive-stream.h,v 1.18 2002/02/03 03:09:26 lim Exp $
 34  */
 35 
 36 #ifndef MASH_ARCHIVE_STREAM_H
 37 #define MASH_ARCHIVE_STREAM_H
 38 
 39 
 40 #include <tclcl.h>
 41 #include "archive/archive-file.h"
 42 #include "archive/lts.h"
 43 
 44 class RecorderStream;
 45 class PlaybackStream;
 46 
 47 
 48 class ArchiveStream : public TclObject {
 49 public:
 50         ArchiveStream() : TclObject(), is_first_(0), dataFile_(NULL),
 51                 indexFile_(NULL)
 52 #ifdef MTRACE
 53           , myNum_(0) {
 54           myNum_ = ++count_;
 55         }
 56 #else
 57         {
 58         }
 59 #endif
 60         virtual ~ArchiveStream() { }
 61 
 62         int datafile (int argc, const char * const *argv);
 63         int indexfile(int argc, const char * const *argv);
 64 
 65 protected:
 66         DataFile  *DataFile_ () { return dataFile_; }
 67         IndexFile *IndexFile_() { return indexFile_;}
 68 
 69         void DataFile_ (DataFile  *file) { dataFile_ = file; }
 70         void IndexFile_(IndexFile *file) { indexFile_= file; }
 71         int is_first_;
 72 private:
 73         DataFile  *dataFile_;
 74         IndexFile *indexFile_;
 75 
 76 #ifdef MTRACE
 77 public:
 78         int myNum_;
 79         static int count_;
 80 private:
 81 #endif
 82 };
 83 
 84 
 85 #ifdef MTRACE
 86 #define MYNUM(x) ((x)->myNum_)
 87 #else
 88 #define MYNUM(x) 0
 89 #endif
 90 
 91 
 92 
 93 /*
 94  * The stream object for interfacing the playback tool to the file system
 95  */
 96 class PlaybackStream : public LTSTimer,
 97                        public LTSTrigger,
 98                        public ArchiveStream {
 99 public:
100         PlaybackStream()
101                 : LTSTimer(),
102                   LTSTrigger(LTS_SPEED|LTS_REFERENCE),
103                   ArchiveStream(), lts_(NULL) { }
104         virtual ~PlaybackStream() {
105                 if (lts_!=NULL) {
106                         // remove myself from the trigger list of the lts
107                         lts_->UnsetTrigger(this);
108                 }
109         }
110         virtual void LTS_Speed() { LTS_Changed(); }
111         virtual void LTS_Reference() { LTS_Changed(); }
112 
113         virtual void Clip(timeval start, timeval end)=0;
114         // obtain the timeout value for the next event
115         // returns: TCL_OK/TCL_ERROR; logical=0.0 if I'm done!
116         virtual int  NextEvent(timeval &logical)=0;
117         virtual void DoEvent()=0; // do the next event
118 
119         int lts (int argc, const char * const *argv);
120         int clip(int argc, const char * const *argv);
121         inline LTS* LTS_() { return lts_; }
122         inline void LTS_(LTS *lts) {
123                 if (lts_ != NULL) {
124                         // if there already is an LTS, remove myself from its
125                         // trigger list
126                         lts_->UnsetTrigger(this);
127                 }
128 
129                 lts_ = lts;
130                 LTSTimer::LTS_(lts);
131                 LTSTrigger::LTS_(lts);
132 
133                 // add myself to the trigger list of the lts
134                 lts->SetTrigger(this);
135         }
136 
137 protected:
138         void callback(u_int32_t triggerType) {
139                 if (triggerType & LTS_SPEED) LTS_Speed();
140                 if (triggerType & LTS_REFERENCE) LTS_Reference();
141         }
142         void timeout();
143 
144 private:
145         void LTS_Changed();
146         LTS       *lts_;
147 };
148 
149 
150 /*
151  * The stream object for interfacing the recorder to the file system
152  */
153 class RecordStream : public ArchiveStream {
154 public:
155         RecordStream() { }
156         virtual ~RecordStream() { }
157 };
158 
159 
160 #endif /* MASH_ARCHIVE_STREAM_H */
161 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.