C:/cmcintos/defOrgs/source/behavioral/Beh_TranslateAll.cxx

00001 #ifndef _Beh_TranslateAll_txx
00002 #define _Beh_TranslateAll_txx
00003 
00004 #include "Beh_TranslateAll.h"
00005 
00006 namespace mial {
00007 
00008         template<class Type, int nDims>
00009         Beh_TranslateAll<Type,nDims>::Beh_TranslateAll()
00010                 :Behavior<Type,nDims>("Beh_TranslateAll")
00011         {
00012                 //Default constructor
00013                 startTime =0;
00014                 endTime =0;
00015         }
00016         template<class Type, int nDims>
00017         bool Beh_TranslateAll<Type,nDims>::run(typename Behavior<Type,nDims>::behaviorIn * i,std::stringstream *s)
00018         {
00019 
00020                 typename behaviorIn::Pointer in;
00021                 //TODO: Make sure the null works.
00022                 if(i != NULL && s != NULL)
00023                 {
00024                         Error e;
00025                         e.msg = "Only one of struct or stream input may be provided.";
00026                         e.name = "Beh_TranslateAll";
00027                         throw e;
00028                 }
00029                 else if(i != NULL)
00030                         in = reinterpret_cast<behaviorIn *>(i); //Typecast the input to its desired form
00031                 else if( s!= NULL)
00032                 {
00033                         in = behaviorIn::New();
00034                         in->fillFromStream(*s);//in = &behaviorIn(*(reinterpret_cast<std::istream *>(s)));
00035                 }
00036                 else
00037                 {
00038                         Error e;
00039                         e.msg = "Either struct or stream input must be provided.";
00040                         e.name = "Beh_TranslateAll";
00041                         throw e;
00042                 }
00043                 input = in;
00044                 
00045                 startTime = this->physLayer->getTime();
00046                 endTime = startTime+in->duration;
00047                 std::stringstream defArgs;
00048                 for(int i=0;i<nDims;i++)
00049                 {
00050                         defArgs << in->translateAmount[i] << " ";
00051                 }
00052                 std::cout << "Runing Beh_TranslateAll" << std::endl;
00053                 this->physLayer->runDeformation("Def_Translation",NULL,&defArgs);//Indicate that arg list is a stream
00054 
00055                 return false;
00056         }
00057         template<class Type, int nDims>
00058         bool Beh_TranslateAll<Type,nDims>::update()
00059         {
00060                 std::stringstream defArgs;
00061                 for(int i=0;i<nDims;i++)
00062                 {
00063                         defArgs << input->translateAmount[i] << " ";
00064                 }
00065                 this->physLayer->runDeformation("Def_Translation",NULL,&defArgs);//Indicate that arg list is a stream
00066 
00067                 return false;
00068 
00069         }
00070         template<class Type, int nDims>
00071         void Beh_TranslateAll<Type,nDims>::cleanUp()
00072         {
00073                 startTime =0;
00074                 endTime =0;
00075         }
00076 }//end namespace mial
00077 
00078 #endif

Generated on Wed Jul 19 13:05:17 2006 for IDO by  doxygen 1.4.7