00001 00002 /* $Id: ExCAction.cpp,v 1.4 2002/12/13 11:45:02 data Exp $ */ 00003 00004 #include "ExCAction.h" 00005 00006 ExCAction::ExCAction() 00007 { 00008 Guard(ExCAction::ExCAction()) 00009 m_NextAction=NULL; 00010 m_Action=0; 00011 m_ActionNumber=0; 00012 m_executed=false; 00013 m_StartingLife=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000); 00014 m_ExecutingLife=-1; 00015 m_NumberOfExecution=1; 00016 m_Param="NULL"; 00017 m_Param1="NULL"; 00018 m_Param2="NULL"; 00019 UnGuard 00020 } 00021 00022 ExCAction::~ExCAction() 00023 { 00024 Guard(ExCAction::~ExCAction()) 00025 UnGuard 00026 } 00027 00028 ExCAction::ExCAction(const ExCAction& Action) 00029 { 00030 Guard(ExCAction::ExCAction(const ExCAction& Action)) 00031 m_NextAction=Action.m_NextAction; 00032 m_Action=Action.m_Action; 00033 m_ActionNumber=0; 00034 m_NumberOfExecution=Action.m_NumberOfExecution; 00035 m_executed=Action.m_executed; 00036 m_StartingLife=Action.m_StartingLife; 00037 m_ExecutingLife=Action.m_ExecutingLife; 00038 m_Param=Action.m_Param; 00039 m_Param1=Action.m_Param1; 00040 m_Param2=Action.m_Param2; 00041 UnGuard 00042 } 00043 00044 ExCAction::ExCAction(int Action) 00045 { 00046 Guard(ExCAction::ExCAction(int Action)) 00047 m_NumberOfExecution=1; 00048 m_NextAction=NULL; 00049 m_Action=Action; 00050 m_ActionNumber=0; 00051 m_executed=false; 00052 m_StartingLife=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000); 00053 m_ExecutingLife=-1; 00054 m_Param="NULL"; 00055 m_Param1="NULL"; 00056 m_Param2="NULL"; 00057 UnGuard 00058 } 00059 00060 ExCAction::ExCAction(int Action,std::string Param) 00061 { 00062 Guard(ExCAction::ExCAction(int Action,std::string Param)) 00063 m_NumberOfExecution=1; 00064 m_NextAction=NULL; 00065 m_Action=Action; 00066 m_ActionNumber=0; 00067 m_executed=false; 00068 m_StartingLife=(double)((double)glutGet(GLUT_ELAPSED_TIME)/1000); 00069 m_ExecutingLife=-1; 00070 m_Param=Param; 00071 UnGuard 00072 } 00073 00074 // Friends 00075 std::ostream& operator<<(std::ostream& s,const ExCAction &action) 00076 { 00077 s<<" Action :"<<action.m_Action<<" Param :"<<action.m_Param; 00078 s<<" Param1 :"<<action.m_Param1<<" Param2 :"<<action.m_Param2<<std::endl; 00079 return s; 00080 } 00081 std::ostrstream& operator<<(std::ostrstream& s,const ExCAction &action) 00082 { 00083 s<<" Action :"<<action.m_Action<<" Param :"<<action.m_Param; 00084 s<<" Param1 :"<<action.m_Param1<<" Param2 :"<<action.m_Param2<<std::endl; 00085 return s; 00086 } 00087 00088 00089 00090 void ExCAction::SetParam(int ParamNumber,std::string Param) 00091 { 00092 Guard(void ExCAction::SetParam(int ParamNumber,std::string Param)) 00093 if(GetNumberParam()<ParamNumber)throw ExCExpParameterBadNumberParam(); 00094 m_VecParam.at(ParamNumber)=Param; 00095 UnGuard 00096 } 00097 00098 int ExCAction::GetParamAsInt(int ParamNumber) 00099 { 00100 Guard(int ExCAction::GetParamAsInt(int ParamNumber)) 00101 switch(ParamNumber) 00102 { 00103 case 0:return atoi(m_Param.data()); 00104 case 1:return atoi(m_Param1.data()); 00105 case 2:return atoi(m_Param2.data()); 00106 default:return -1; 00107 } 00108 /* if(GetNumberParam()<ParamNumber)throw ExCExpParameterBadNumberParam(); 00109 try 00110 { 00111 return atoi(m_VecParam.at(ParamNumber).data()); 00112 }catch (...) 00113 { 00114 throw ExCExpParameterConversionError(); 00115 } 00116 return true;*/ 00117 UnGuard 00118 } 00119 00120 00121 00122 bool ExCAction::AllActionDone() 00123 { 00124 Guard(bool ExCAction::AllActionDone()) 00125 while(this->m_NextAction!=NULL) 00126 { 00127 if(this->m_executed==false) 00128 { 00129 return false;//one action is not done return false to keep action 00130 } 00131 } 00132 return true; 00133 UnGuard 00134 }