arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

SourceObj.h

Go to the documentation of this file.
00001 //------------------------------------------------------------------------
00002 //
00003 //   Joe Kniss
00004 //     6-20-03
00005 //                   ________    ____   ___ 
00006 //                  |        \  /    | /  /
00007 //                  +---+     \/     |/  /
00008 //                  +--+|  |\    /|     < 
00009 //                  |  ||  | \  / |  |\  \ 
00010 //                  |      |  \/  |  | \  \ 
00011 //                   \_____|      |__|  \__\
00012 //                       Copyright  2003 
00013 //                      Joe Michael Kniss
00014 //                   <<< jmk@cs.utah.edu >>>
00015 //               "All Your Base are Belong to Us"
00016 //-------------------------------------------------------------------------
00017 
00018 
00019 ///SourceObj.h
00020 ///  simian core
00021 
00022 
00023 #ifndef __SIMIAN_SOURCE_OBJ_DOT_H
00024 #define __SIMIAN_SOURCE_OBJ_DOT_H
00025 
00026 #include "AlgObj.h"
00027 
00028 //////////////////////////////////////////////////////////////////////////
00029 /// Source Object interface
00030 /// A public interface to a Source object
00031 //////////////////////////////////////////////////////////////////////////
00032 class SourceObjIF : public AlgObj {
00033 public:
00034    virtual ~SourceObjIF() {}
00035    virtual  unsigned int getNumOutputs() const = 0;
00036 
00037    ///////////////////////////////////////////
00038    ///@name Public Execute Interface
00039    ///@{
00040 
00041    /// Execute if anything changed, only if it needs to
00042    virtual void execute() = 0;
00043    /// Execute no matter what!
00044    virtual void force() = 0;
00045 
00046    ///@}
00047    ///////////////////////////////////////////
00048 
00049    ///////////////////////////////////////////
00050    ///@name Frame work interfaces NOT FOR GENERAL USE
00051    ///  users ignore these
00052    ///@{
00053 
00054    ///////////////////////////////////////
00055    /// request interface
00056    virtual bool request(DataObjSP d) = 0;
00057 
00058    ///@}
00059    ///////////////////////////////////////////
00060 
00061 
00062 protected:
00063    /// protected default construction
00064    SourceObjIF() {}
00065    /// Filter constructor chain
00066    SourceObjIF(unsigned int numInputs)
00067       : AlgObj(numInputs) 
00068    {}
00069 
00070 private:
00071    /// not used
00072    SourceObjIF(const SourceObjIF &so);
00073    /// not used
00074    SourceObjIF &operator=(const SourceObjIF &so);
00075 
00076 };
00077 
00078 typedef gutz::SmartPtr<SourceObjIF> SourceObjSP;
00079 
00080 //////////////////////////////////////////////////////////////////////////
00081 /// Source Object base class
00082 //////////////////////////////////////////////////////////////////////////
00083 class SourceObj : public SourceObjIF {
00084 public:
00085    virtual ~SourceObj();
00086    unsigned int getNumOutputs() const {return _nOutputs;}
00087 
00088    ///////////////////////////////////////////
00089    /// Public Execute Interface
00090    /// Execute if anything changed
00091    /// DO NOT override this if you don't know
00092    /// what you are doing, use "execDef()"
00093    /// this will get called by these!
00094    virtual void execute();
00095    /// Execute no matter what!, unless you
00096    /// are going to get an update later
00097    virtual void force();
00098 
00099    ///////////////////////////////////////////
00100    /// Frame work interfaces, 
00101    ///        NOT FOR GENERAL USE
00102    /// ... ignore these
00103    ///////////////////////////////////////////
00104 
00105    ///////////////////////////////////////
00106    /// update interface
00107    virtual void setForwardModified();
00108 
00109    ///////////////////////////////////////
00110    /// request interface
00111    virtual bool request(DataObjSP d);
00112 
00113 protected:
00114    /// protected default construction
00115    SourceObj();
00116    /// use this if you are a "true" source
00117    SourceObj(unsigned int numOutputs);
00118    /// use this if you are a "filter"
00119    SourceObj(unsigned int numInputs, unsigned int numOutputs);
00120 
00121    /// override this one to set the execution behavior
00122    /// of your source
00123    virtual void execDef()
00124    {derr("execDef(), not implemented! This should be over-ridden by a subclass!");}
00125 
00126    void updateOutputs();
00127 
00128    void       addOutput(DataObjSP d);
00129    void       delOutput(DataObjSP d);
00130    bool       isOutput(const DataObjSP d) const;
00131    void       setNumOutputs(int nOut);
00132    void       setOutputN(int outNum, DataObjSP d);
00133    /// returns raw pointer to facilitate easier dynamic_cast<YOUR_DATA_TYPE>
00134    DataObjIF *getOutputN(int outNum);
00135 
00136 private:
00137    DataObjSP *_outputs;
00138    int        _nOutputs;
00139 };
00140 
00141 
00142 
00143 #endif
00144 

Send questions, comments, and bug reports to:
jmk