Main Page Namespace List Class Hierarchy Alphabetical List Data Structures File List Namespace Members Data Fields Globals

# ExCAction.cpp

Go to the documentation of this file.

    00001
    00002 /* $Id: ExCAction.cpp,v 1.3 2002/11/24 11:59:00 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         if(GetNumberParam()<ParamNumber)throw ExCExpParameterBadNumberParam();
    00102         try
    00103         {
    00104                 return atoi(m_VecParam.at(ParamNumber).data());
    00105         }catch (...)
    00106         {
    00107                 throw ExCExpParameterConversionError();
    00108         }
    00109         return true;
    00110 UnGuard
    00111 }
    00112
    00113
    00114
    00115 bool ExCAction::AllActionDone()
    00116 {
    00117 Guard(bool ExCAction::AllActionDone())
    00118         while(this->m_NextAction!=NULL)
    00119         {
    00120                 if(this->m_executed==false)
    00121                 {
    00122                         return false;//one action is not done return false to keep action
    00123                 }
    00124         }
    00125         return true;
    00126 UnGuard
    00127 }