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 ///AlgObj.h 00020 /// simian core 00021 00022 #ifndef __SIMIAN_ALGORITHM_OBJECT_DOT_H 00023 #define __SIMIAN_ALGORITHM_OBJECT_DOT_H 00024 00025 #include "DataObj.h" 00026 #include "SimModObj.h" 00027 00028 /////////////////////////////////////////////////////////////////////////// 00029 /// Alg Obj Interface class 00030 /// This is just the public interface to the class, if you are 00031 /// creating a new algorithm, sub class "AlgObj" not the interface 00032 /////////////////////////////////////////////////////////////////////////// 00033 class AlgObjIF : public SimModObjIF { 00034 public: 00035 virtual ~AlgObjIF(){} 00036 00037 virtual unsigned int getNumInputs() const = 0; 00038 00039 /////////////////////////////////////////// 00040 /// Public Execute Interface 00041 /// Execute if anything changed 00042 virtual void execute() = 0; 00043 /// Execute no matter what! 00044 virtual void force() = 0; 00045 00046 /////////////////////////////////////////// 00047 /// Frame work interfaces, 00048 /// NOT FOR GENERAL USE 00049 /// ... ignore these 00050 /////////////////////////////////////////// 00051 00052 ////////////////////////////////// 00053 /// update interface 00054 /// update when data changes 00055 void update_(DataObjSP d) = 0; 00056 00057 protected: 00058 AlgObjIF(){} 00059 00060 private: 00061 /// not used 00062 AlgObjIF(const AlgObjIF &ao); 00063 void operator=(const AlgObjIF &ao); 00064 }; 00065 00066 /////////////////////////////////////////////////////////////////////////// 00067 /// Alg Obj Base Class 00068 /// a base class for all Algorithms, this includes SourceObjs 00069 /////////////////////////////////////////////////////////////////////////// 00070 class AlgObj : public AlgObjIF { 00071 public: 00072 virtual ~AlgObj(); 00073 unsigned int getNumInputs() const {return _nInputs;} 00074 00075 /////////////////////////////////////////// 00076 /// Public Execute Interface 00077 /// Execute if anything changed 00078 virtual void execute(); 00079 /// Execute no matter what! 00080 virtual void force(); 00081 00082 /////////////////////////////////////////// 00083 /// Frame work interfaces, 00084 /// NOT FOR GENERAL USE 00085 /// ... ignore these 00086 /////////////////////////////////////////// 00087 00088 ////////////////////////////////// 00089 /// update interface 00090 /// update when data changes 00091 void update_(DataObjSP d); 00092 00093 /// set going to be updated 00094 virtual void setForwardModified() {_forward = true;} 00095 00096 protected: 00097 /// protected default constructor/destructor 00098 AlgObj(); 00099 AlgObj(unsigned int numInputs); 00100 00101 /// true if data is current, false if not 00102 virtual bool checkInputs(); 00103 00104 /// check if we have modified inputs 00105 virtual bool inputsModified(); 00106 00107 /// exectue on some changed data 00108 virtual void execDef() 00109 { derr("execDef(), not implemented, should be over-ridden by subclass"); } 00110 00111 /// manipulate inputs 00112 void addInput(DataObjSP d); 00113 void delInput(DataObjSP d); 00114 bool isInput(const DataObjSP d) const; 00115 void setNumInputs(int nInputs); 00116 void setInputN(int inNum, DataObjSP d); 00117 /// returns raw pointer to facilitate easier dynamic_cast<YOUR_DATA_TYPE> 00118 DataObjIF *getInputN(int inNum); 00119 00120 private: 00121 DataObjSP *_inputs; 00122 int _nInputs; 00123 }; 00124 00125 00126 #endif 00127