#ifndef DPSPORT_HEADER #define DPSPORT_HEADER 1 ///////////////////////////////////////////////////// //! docentry="Data Processing.Basics" //! rcsid="$Id: SPort.hh,v 1.10 2000/12/13 12:17:15 ees1cg Exp $" //! file="amma/StdType/DataProc/SPort.hh" //! lib=DataProc //! author="Charles Galambos" //! date="27/10/98" #include "amma/DP/Port.hh" ////////////////////////////////////////////////// //! userlevel=Develop //: Stream position control body class. class DPSeekCtrlBodyC : virtual public DPEntityBodyC { public: DPSeekCtrlBodyC() {} //: Default constructor. virtual BooleanT Seek(UIntT off); //: Seek to location in stream. // Returns FALSE, if seek failed. (Maybe because its // not implemented.) // if an error occurered (Seek returned False) then stream // position will not be changed. virtual BooleanT DSeek(IntT off); //: Delta Seek, goto location relative to the current one. // The default behavour of this functions is : // Do some error checking then: // Seek((UIntT)((IntT) Tell() + off)); // if an error occurered (DSeek returned False) then stream // position will not be changed. virtual UIntT Tell() const; //: Find current location in stream. // Defined as the index of the next object to be written or read. // May return ((UIntT) (-1)) if not implemented. virtual UIntT Size() const; //: Find the total size of the stream. (assuming it starts from 0) // May return ((UIntT) (-1)) if not implemented. virtual UIntT Start() const; //: Find the offset where the stream begins, normally zero. // Defaults to 0 }; ////////////////////////////////////////////////// //! userlevel=Develop //: Stub Stream position control body class. // This is like the main body class, but doesn't issue errors // when unimplemented functions are called. class DPSeekCtrlStubBodyC : public DPSeekCtrlBodyC { public: DPSeekCtrlStubBodyC(); //: Default constructor. DPSeekCtrlStubBodyC(const DPPortC &pb); //: Constructor. virtual BooleanT Seek(UIntT off); //: Seek to location in stream. // Returns FALSE, if seek failed. (Maybe because its // not implemented.) // if an error occurered (Seek returned False) then stream // position will not be changed. virtual BooleanT DSeek(IntT off); //: Delta Seek, goto location relative to the current one. // The default behavour of this functions is : // Do some error checking then: // Seek((UIntT)((IntT) Tell() + off)); // if an error occurered (DSeek returned False) then stream // position will not be changed. virtual UIntT Tell() const; //: Find current location in stream. // May return ((UIntT) (-1)) if not implemented. virtual UIntT Size() const; //: Find the total size of the stream. (assuming it starts from 0) // May return ((UIntT) (-1)) if not implemented. protected: DPPortC pb; }; ////////////////////////////////////////////////// //! userlevel=Normal //: Stream position control handle class. class DPSeekCtrlC : virtual public DPEntityC { public: DPSeekCtrlC() : DPEntityC(TRUE) {} //: Default constructor. DPSeekCtrlC(BooleanT stubIt,const DPPortC &pb = DPPortC()); //: Constructor. // If stubIt is TRUE, a body the produces no // error message is used, otherwise its a noisy one. DPSeekCtrlC(const DPSeekCtrlC &oth) : DPEntityC(oth) {} //: Copy constructor. DPSeekCtrlC(const DPEntityC &oth) : DPEntityC(oth) { if(dynamic_cast(&DPEntityC::Body()) == 0) Invalidate(); // Incorrect type. } //: Base Constructor. inline BooleanT Seek(UIntT off); //: Seek to location in stream. // Returns FALSE, if seek failed. (Maybe because its // not implemented.) // if an error occurered (Seek returned False) then stream // position will not be changed. inline BooleanT DSeek(IntT off); //: Delta Seek, goto location relative to the current one. // The default behavour of this functions is : // Do some error checking then: // Seek((UIntT)((IntT) Tell() + off)); // if an error occurered (DSeek returned False) then stream // position will not be changed. inline UIntT Tell() const; //: Find current location in stream. // Defined as the index of the next object to be written or read. // May return ((UIntT) (-1)) if not implemented. inline UIntT Size() const; //: Find the total size of the stream. (assuming it starts from 0) // May return ((UIntT) (-1)) if not implemented. inline UIntT Start() const; //: Find the offset where the stream begins, normally zero. // Defaults to 0 protected: DPSeekCtrlC(DPSeekCtrlBodyC &bod) : DPEntityC(bod) {} //: Body constructor. inline DPSeekCtrlBodyC &Body() { return dynamic_cast(DPEntityC::Body()); } //: Access body class. inline const DPSeekCtrlBodyC &Body() const { return dynamic_cast(DPEntityC::Body()); } //: Access body class. }; ////////////////////////////////////////////////// //! userlevel=Develop //: Seekable port input body. template class DPISPortBodyC : public DPIPortBodyC, virtual public DPSeekCtrlBodyC { public: DPISPortBodyC() {} //: Default constructor. }; ////////////////////////////////////////////////// //! userlevel=Develop //: Seekable port ouput body. template class DPOSPortBodyC : public DPOPortBodyC, virtual public DPSeekCtrlBodyC { public: DPOSPortBodyC() {} //: Default constructor. }; ////////////////////////////////////////////////// //! userlevel=Normal //: Seekable port input handle. template class DPISPortC : public DPIPortC, public DPSeekCtrlC { public: DPISPortC() : DPEntityC(TRUE) {} //: Default constructor. DPISPortC(const DPISPortC &oth) : DPEntityC(oth) {} //: Copy constructor. DPISPortC(const DPIPortBaseC &oth) : DPEntityC(oth) { if(dynamic_cast *>(&DPEntityC::Body()) == 0) Invalidate(); } //: Base constructor. const DPISPortC &operator= (const DPISPortC &obj) { DPEntityC::operator=(obj); return *this; } //: Assigment. }; ////////////////////////////////////////////////// //! userlevel=Normal //: Seekable port ouput handle. template class DPOSPortC : public DPOPortC, public DPSeekCtrlC { public: DPOSPortC() : DPEntityC(TRUE) {} //: Default constructor. DPOSPortC(const DPOSPortC &oth) : DPEntityC(oth) {} //: Copy constructor. DPOSPortC(const DPOPortBaseC &oth) : DPEntityC(oth) { if(dynamic_cast *>(&DPEntityC::Body()) == 0) Invalidate(); } //: Base constructor. const DPOSPortC &operator= (const DPOSPortC &obj) { DPEntityC::operator=(obj); return *this; } //: Assigment. }; ////////////////////////////////////////////////// inline BooleanT DPSeekCtrlC::Seek(UIntT off) { return Body().Seek(off); } inline BooleanT DPSeekCtrlC::DSeek(IntT off) { return Body().DSeek(off); } inline UIntT DPSeekCtrlC::Tell() const { return Body().Tell(); } inline UIntT DPSeekCtrlC::Size() const { return Body().Size(); } inline UIntT DPSeekCtrlC::Start() const { return Body().Start(); } #endif