00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "freControllerEvents.h"
00025
00026 namespace FREE
00027 {
00028
00032
00033
00034 CallbackCtrlEventBase::
00035 CallbackCtrlEventBase(CallEvent pCE)
00036 {
00037 this->m_CallEvent = pCE;
00038 this->m_ACR = NULL;
00039 };
00040
00041 CallbackCtrlEventBase::
00042 CallbackCtrlEventBase()
00043 {
00044 m_CallEvent = NULL;
00045 this->m_ACR = NULL;
00046 };
00047
00048 bool
00049 CallbackCtrlEventBase::
00050 Execute(const IDPath& senderID, CallbackType callbackID,
00051 void* pData, SessionComponentCache* pSender,
00052 long threadID)
00053 {
00054 if (!m_CallEvent) return false;
00055
00056 bool result = false;
00057
00058 if (this->IsLegalSender(pSender))
00059 {
00060 this->m_ExecutionMutex.Lock();
00061 result = (*m_CallEvent)(senderID, callbackID, pData, pSender, threadID);
00062 this->m_ExecutionMutex.Unlock();
00063 }
00064
00065 return result;
00066 };
00067
00068 void
00069 CallbackCtrlEventBase::
00070 SetACR(SessionComponentCache* pCache)
00071 {
00072 if (pCache)
00073 {
00074 this->m_ACR = pCache->GetRootCache();
00075 }
00076 else
00077 {
00078 this->m_ACR = 0;
00079 }
00080 };
00081
00082 SessionComponentCache*
00083 CallbackCtrlEventBase::
00084 GetACR()
00085 {
00086 return this->m_ACR;
00087 }
00088
00089 bool
00090 CallbackCtrlEventBase::
00091 IsLegalSender(SessionComponentCache* pSender)
00092 {
00093 if (!this->m_ACR) return true;
00094 if (!pSender) return false;
00095
00096 m_ACRMutex.Lock();
00097 bool result = this->m_ACR == pSender->GetRootCache();
00098 m_ACRMutex.Unlock();
00099
00100 return result;
00101 };
00102
00103
00107
00108
00109 ProgressCtrlEventBase::
00110 ProgressCtrlEventBase(ProgEvent pPE)
00111 {
00112 m_ProgressEvent = pPE;
00113 this->m_ACR = NULL;
00114 };
00115
00116 ProgressCtrlEventBase::
00117 ProgressCtrlEventBase()
00118 {
00119 m_ProgressEvent = NULL;
00120 this->m_ACR = NULL;
00121 };
00122
00123 void
00124 ProgressCtrlEventBase::
00125 Execute(const IDPath& senderID, const StatusID status,
00126 const std::string& sComment, SessionComponentCache* pSender,
00127 long threadID)
00128 {
00129 if (!m_ProgressEvent) return;
00130
00131 if (this->IsLegalSender(pSender))
00132 {
00133 this->m_ExecutionMutex.Lock();
00134 (*m_ProgressEvent)(senderID, status, sComment, pSender, threadID);
00135 this->m_ExecutionMutex.Unlock();
00136 }
00137 };
00138
00139 void
00140 ProgressCtrlEventBase::
00141 SetACR(SessionComponentCache* pCache)
00142 {
00143 if (pCache)
00144 {
00145 this->m_ACR = pCache->GetRootCache();
00146 }
00147 else
00148 {
00149 this->m_ACR = 0;
00150 }
00151 };
00152
00153 SessionComponentCache*
00154 ProgressCtrlEventBase::
00155 GetACR()
00156 {
00157 return this->m_ACR;
00158 }
00159
00160 bool
00161 ProgressCtrlEventBase::
00162 IsLegalSender(SessionComponentCache* pSender)
00163 {
00164 if (!this->m_ACR) return true;
00165 if (!pSender) return false;
00166
00167 m_ACRMutex.Lock();
00168 bool result = this->m_ACR == pSender->GetRootCache();
00169 m_ACRMutex.Unlock();
00170
00171 return result;
00172 };
00173
00174 }