#ifndef DPIOPORTJOIN_HEADER #define DPIOPORTJOIN_HEADER 1 /////////////////////////////////////////////////////// //! file="amma/StdType/DataProc/IOJoin.hh" //! lib=DataProc //! author="Charles Galambos" //! docentry="Data Processing" //! date="12/10/98" //! rcsid="$Id: IOJoin.hh,v 1.10 2000/12/13 12:17:15 ees1cg Exp $" #include "amma/DP/Port.hh" //! userlevel=Develop //: Join an IPort and a OPort template class DPIOPortJoinBodyC : public DPIOPortBodyC { public: DPIOPortJoinBodyC() : hold(TRUE) {} //: Default constructor. DPIOPortJoinBodyC(const DPIPortC &nin,const DPOPortC &nout,const DPEntityC &ahold = DPEntityC(TRUE)) : in(nin), out(nout), hold(ahold) {} //: Constructor. virtual BooleanT IsGetReady() const { return in.IsGetReady(); } //: Is some data ready ? // TRUE = yes. // Defaults to !IsGetEOS(). virtual BooleanT IsGetEOS() const { return in.IsGetEOS(); } //: Has the End Of Stream been reached ? // TRUE = yes. virtual InT Get() { return in.Get(); } //: Get next piece of data. // May block if not ready, or it will return a constructed // with the default constructor. virtual BooleanT Get(InT &buff) { return in.Get(buff); } //: Try and get next piece of data. // This will NOT block, if no data is ready // it will return FALSE, and not set buff. virtual IntT GetArray(SArray1dC &data) { return in.GetArray(data); } //: Get an array of data. // returns the number of elements processed. virtual void PutEOS() { out.PutEOS(); } //: Put End Of Stream marker. virtual BooleanT IsPutReady() const { return out.IsPutReady(); } //: Is port ready for data ? virtual BooleanT Put(const OutT &dat) { return out.Put(dat); } //: Put data. virtual IntT PutArray(const SArray1dC &data) { return out.PutArray(data); } //: Put an array of data to stream. // returns the number of elements processed. protected: DPIPortC in; DPOPortC out; DPEntityC hold; // User to hold structure ports may connect to. }; //! userlevel=Normal //: Join an IPort and a OPort template class DPIOPortJoinC : public DPIOPortC { public: DPIOPortJoinC() : DPEntityC(TRUE) {} //: Default constructor. DPIOPortJoinC(const DPIPortC &in,const DPOPortC &out,const DPEntityC &ahold = DPEntityC(TRUE)) : DPEntityC(*new DPIOPortJoinBodyC(in,out,ahold)) {} //: Constructor. }; //: Join function. template DPIOPortC DPIOPortJoin(const DPIPortC &in,const DPOPortC &out,const DPEntityC &ahold = DPEntityC(TRUE)) { return DPIOPortJoinC(in,out,ahold); } #endif