00001 #if defined (_MSC_VER) && (_MSC_VER >= 1000) 00002 #pragma once 00003 #endif 00004 #ifndef _INC_BEHAVIOR 00005 #define _INC_BEHAVIOR 00006 #include "Physics.h" 00007 #include "stdafx.h" 00008 #include "itkSmartPointer.h" 00009 #include <itkLightObject.h> 00010 00011 namespace mial 00012 { 00014 00045 template<class Type, int nDims> 00046 class Behavior:public itk::LightObject 00047 { 00048 public: 00049 00050 //Smart pointers 00051 typedef Behavior Self; 00052 typedef itk::SmartPointer<Self> Pointer; 00053 typedef itk::SmartPointer<const Self> ConstPointer; 00054 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00055 //itkNewMacro(Self); 00056 00057 00059 00063 struct Error{ 00064 std::string msg; 00065 std::string name; 00066 }; 00067 00069 00072 struct behaviorIn:public itk::LightObject{ 00073 //Define all common behavior inputs here 00074 //std::istream * args; 00075 typedef behaviorIn Self; 00076 typedef itk::SmartPointer<Self> Pointer; 00077 typedef itk::SmartPointer<const Self> ConstPointer; 00078 typedef itk::WeakPointer<const Self> ConstWeakPointer; 00079 00080 itkNewMacro(Self); 00081 00083 00086 virtual bool fillFromStream(std::istream &args){return false;}; 00087 protected: 00088 behaviorIn(){}; 00089 }; 00090 00092 00100 virtual bool run(typename Behavior<Type,nDims>::behaviorIn * i, std::stringstream *s = NULL)=0; 00101 00103 00106 virtual bool update()=0; 00107 00108 00110 00114 virtual void cleanUp()=0; 00115 00117 std::string getName(){return name;}; // inline 00118 00120 //virtual bool marshallStream(std::istream &args){return false;}; 00121 00123 bool setPhysLayer(Physics<Type,nDims> * phys){ physLayer = phys; return true;}; // inline 00124 00125 virtual bool isFinished()=0; 00126 //bool isFinished(){return finished;}; 00127 00128 protected: 00129 00131 Behavior(std::string name); 00132 00134 Behavior *subBehaviors; 00135 00137 behaviorIn * input; 00138 00140 std::string name; 00141 00143 Physics<Type,nDims> *physLayer; 00144 00145 typedef Physics<Type,nDims> PhysicsType; 00146 typedef typename PhysicsType::MatrixType MatrixType; 00147 typedef typename PhysicsType::VectorType VectorType; 00148 00150 //bool finished; 00151 00152 }; 00153 }// end mial 00154 #include "Behavior.cxx" 00155 #endif /* _INC_BEHAVIOR*/