#line 1 "/user/cvsspst/ees1cg/RAVL/RAVL-0.7/Core/IO/IOJoin.hh" // This file is part of RAVL, Recognition And Vision Library // Copyright (C) 2001, University of Surrey // This code may be redistributed under the terms of the GNU Lesser // General Public License (LGPL). See the lgpl.licence file for details or // see http://www.gnu.org/copyleft/lesser.html // file-header-ends-here #ifndef RAVL_DPIOPORTJOIN_HEADER #define RAVL_DPIOPORTJOIN_HEADER 1 /////////////////////////////////////////////////////// //! file="Ravl/Core/IO/IOJoin.hh" //! lib=RavlIO //! author="Charles Galambos" //! docentry="Ravl.Core.Data Processing.Ports" //! date="12/10/1998" //! rcsid="$Id: IOJoin.hh,v 1.5 2002/07/31 07:44:54 craftit Exp $" //! userlevel=Normal #include "Ravl/DP/Port.hh" #include "Ravl/DP/IOPort.hh" namespace RavlN { //! 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 bool IsGetReady() const { return in.IsGetReady(); } //: Is some data ready ? // true = yes. // Defaults to !IsGetEOS(). virtual bool 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 bool 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 bool IsPutReady() const { return out.IsPutReady(); } //: Is port ready for data ? virtual bool 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=Advanced //: 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