src/engine/Interpreter.h

Go to the documentation of this file.
00001 
00011 #ifndef INTERPRETER_H
00012 #define INTERPRETER_H
00013 
00014 #include <boost/shared_ptr.hpp>
00015 
00016 #include "EntityInstance.h"
00017 #include "BehaviorInstance.h"
00018 #include "LibraryBehaviors.h"
00019 #include "BehaviorTemplateTable.h"
00020 #include "util/Error.h"
00021 #include "parser/impcomp/ExecLoop.h"
00022 
00023 namespace green
00024 {
00025         class Interpreter
00026         {
00027                 protected:
00028                         static Key mMoveBehaviorKey;
00029                         
00030                 public:
00031                         
00032                         static void SetMoveBehaviorKey(Key newKey) {
00033                                 Interpreter::mMoveBehaviorKey = newKey;
00034                         }
00035                         
00039                 static bool RunBehavior(SystemPtr sys, BehaviorTemplateTablePtr behaviorTable,
00040                                                                 BehaviorInstancePtr behavior,
00041                                                                 EntityInstancePtr originalTarget,
00042                                                                 EntityInstancePtr newTarget)
00043                         {
00044                                 CHECK_SHARED(sys);
00045                                 CHECK_SHARED(behaviorTable);
00046                                 CHECK_SHARED(behavior);
00047                                 CHECK_SHARED(originalTarget);
00048                                 CHECK_SHARED(newTarget);
00049                                 
00050                                 Key btemp = behavior->GetTemplate();
00051                                 if(btemp == Interpreter::mMoveBehaviorKey)
00052                                         return MoveBehavior::RunBehavior(sys, behavior, originalTarget, newTarget);
00053                                 else
00054                                 {
00055                                         int behKey = behavior->GetTemplate();
00056                                         OpSeqPtr code = boost::dynamic_pointer_cast<BehaviorTemplate,VariableTableTemplate>
00057                                                                                 (behaviorTable->GetEntry(behKey))
00058                                                                                 ->getResBodyCode();
00059                 
00060                                         ExecLoop::runBody(sys,newTarget->GetTemplate(),*code,
00061                                                                                 newTarget,originalTarget,originalTarget,behavior);
00062                                 }
00063                                 return true;
00064                         }
00065 
00066                 static bool RunInit(SystemPtr sys,VariableTableInstancePtr objectVars,
00067                                                         ArgListPtr arguments)
00068                         {
00069 //                      ExecLoop::runInit(sys,objectVars,arguments);
00070                         return true;
00071                         }
00072         };
00073 }
00074 
00075 #endif

Generated on Fri Apr 27 10:27:37 2007 for Green Engine by  doxygen 1.5.1