Google
Web alhem.net
Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

EventFactory Class Reference

#include <EventFactory.h>

List of all members.

Public Member Functions

 EventFactory ()
 ~EventFactory ()
virtual void StateMachine (IOThread *pclIOT)
IOMessage * GetClass (IO_IDTYPE)


Constructor & Destructor Documentation

EventFactory::EventFactory  ) 
 

Definition at line 44 of file EventFactory.cpp.

00045 { 00046 }

EventFactory::~EventFactory  ) 
 

Definition at line 49 of file EventFactory.cpp.

00050 { 00051 }


Member Function Documentation

IOMessage * EventFactory::GetClass IO_IDTYPE   ) 
 

Definition at line 135 of file EventFactory.cpp.

References GetClass().

Referenced by EventThread::GetClass(), GetClass(), and StateMachine().

00136 { 00137 { 00138 Data::ClassFactory fac; 00139 IOMessage *pclTemp = fac.GetClass(id); 00140 if (pclTemp) 00141 { 00142 return pclTemp; 00143 } 00144 } 00145 { 00146 Event::ClassFactory fac; 00147 IOMessage *pclTemp = fac.GetClass(id); 00148 if (pclTemp) 00149 { 00150 return pclTemp; 00151 } 00152 } 00153 { 00154 Form::ClassFactory fac; 00155 IOMessage *pclTemp = fac.GetClass(id); 00156 if (pclTemp) 00157 { 00158 return pclTemp; 00159 } 00160 } 00161 fprintf(stderr,"EventFactory: Unknown event id: %d\n",id); 00162 exit(-1); 00163 }

void EventFactory::StateMachine IOThread *  pclIOT  )  [virtual]
 

Definition at line 54 of file EventFactory.cpp.

References DEB, GetClass(), SDL_USEREVENT_ADDFORM, StateMachine(), and ticks.

Referenced by EventThread::Run(), and StateMachine().

00055 { 00056 struct timeval tv; 00057 char c; 00058 00059 for(;;) 00060 { 00061 switch (m_state) 00062 { 00063 case 0: 00064 //DEB(printf("EventFactory state 0\n");) 00065 if (!pclIOT -> get_iq()) 00066 return; 00067 pclIOT -> read_input( &c, 1 ); 00068 if (c == 0x02) // stx 00069 m_state = 1; 00070 break; 00071 case 1: 00072 DEB(printf("EventFactory state 1\n");) 00073 if (pclIOT -> get_iq() < m_l0) 00074 return; 00075 pclIOT -> read_input( (char *)&m_id, sizeof(IO_IDTYPE) ); 00076 pclIOT -> read_input( (char *)&m_length, sizeof(IO_LENGTHTYPE) ); 00077 m_state = 2; 00078 break; 00079 case 2: 00080 DEB(printf("EventFactory state 2\n");) 00081 if (pclIOT -> get_iq() < m_length - m_l0) 00082 return; 00083 m_state = 0; 00084 if ( (m_pclMessage = GetClass(m_id)) == NULL) 00085 { 00086 fprintf(stderr,"EventFactory, GetClass() failed, id = %d\n",m_id); 00087 return; 00088 } 00089 #ifdef TRY_VAR 00090 m_pclMessage -> ReadVars(pclIOT); 00091 #else 00092 m_pclMessage -> read_message(pclIOT); 00093 #endif 00094 00095 if (m_pclMessage -> GetIOFamily() == IOF_FORM) 00096 { 00097 DEB(printf("Form received - add to input thread form list\n");) 00098 // it -> AddForm(m_pclMessage); 00099 SDL_Event e; 00100 00101 m_pclMessage -> FormInit(pclIOT); 00102 e.user.type = SDL_USEREVENT; 00103 e.user.code = SDL_USEREVENT_ADDFORM; 00104 e.user.data1 = m_pclMessage; 00105 e.user.data2 = NULL; 00106 SDL_PushEvent(&e); 00107 } 00108 else 00109 { 00110 // wait for execute time 00111 if (m_pclMessage -> GetID() != EVENT_SYNC) 00112 { 00113 tv.tv_usec = (m_pclMessage -> GetTicks() - ticks.get_sync()) * 1000; 00114 long l = tv.tv_usec / 1000; 00115 tv.tv_sec = tv.tv_usec / 1000000; 00116 tv.tv_usec %= 1000000; 00117 if (tv.tv_sec > 0 || tv.tv_usec > 0) 00118 { 00119 DEB(printf("timing event (%ld,%ld) %ld ms\n", tv.tv_sec,tv.tv_usec,l);) 00120 SDL_Delay(l); 00121 } 00122 } 00123 m_pclMessage -> Execute(pclIOT); 00124 } 00125 if (m_pclMessage -> DeleteOnExecute()) 00126 { 00127 delete m_pclMessage; 00128 } 00129 break; 00130 } 00131 } 00132 }


The documentation for this class was generated from the following files:
Generated for SDL C++ GUI by doxygen 1.3.6