Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 #ifndef GENAPI_COMMANDT_H
00032 #define GENAPI_COMMANDT_H
00033
00034 #include "GenApi/impl/Log.h"
00035 #include "GenApi/impl/INodeMapPrivate.h"
00036 #include "Exception.h"
00037
00038
00039 namespace GENAPI_NAMESPACE
00040 {
00041
00045 template <class Base>
00046 class CommandT : public Base
00047 {
00048 public:
00050 virtual void Execute(bool Verify = true)
00051 {
00052
00053 std::list<CNodeCallback*> CallbacksToFire;
00054 {
00055 AutoLock l(Base::GetLock());
00056 typename Base::EntryMethodFinalizer E( this, meExecute );
00057
00058 GCLOGINFOPUSH( Base::m_pValueLog, "Execute...");
00059
00060 if( Verify && !IsWritable( this ) )
00061 throw ACCESS_EXCEPTION_NODE("Node is not writable.");
00062
00063 {
00064 typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire);
00065
00066 Base::PreSetValue();
00067
00068 Base::InternalExecute(Verify);
00069
00070 if( Verify )
00071 Base::InternalCheckError();
00072
00073 }
00074
00075 GCLOGINFOPOP( Base::m_pValueLog, "...Execute" );
00076
00077
00078 std::list<CNodeCallback*>::iterator ptrCallback;
00079 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00080 {
00081 (*ptrCallback)->operator ()(cbPostInsideLock);
00082 }
00083 }
00084
00085
00086 std::list<CNodeCallback*>::iterator ptrCallback;
00087 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00088 {
00089 (*ptrCallback)->operator ()(cbPostOutsideLock);
00090 }
00091 }
00092
00094 virtual void operator()()
00095 {
00096 Execute();
00097 }
00098
00100 virtual bool IsDone(bool Verify = true)
00101 {
00102 typename Base::EntryMethodFinalizer E( this, meIsDone );
00103
00104 bool Result = false;
00105 bool FireCallbacks = false;
00106
00107
00108
00109 std::list<CNodeCallback*> CallbacksToFire;
00110 {
00111 AutoLock l(Base::GetLock());
00112
00113 GCLOGINFOPUSH( Base::m_pValueLog, "IsDone...");
00114
00115
00116
00117 if( !IsImplemented( this ) )
00118 throw ACCESS_EXCEPTION_NODE("Node is not implemented.");
00119
00120 Result = Base::InternalIsDone(Verify, FireCallbacks);
00121
00122
00123
00124
00125 if(FireCallbacks)
00126 {
00127 for ( NodePrivateVector_t::iterator it = Base::m_AllTerminalNodes.begin(); it != Base::m_AllTerminalNodes.end(); ++it )
00128 {
00129 (*it)->CollectCallbacksToFire(CallbacksToFire, true);
00130 DeleteDoubleCallbacks(CallbacksToFire);
00131 (*it)->SetInvalid(INodePrivate::simAll);
00132 }
00133 }
00134
00135 #pragma BullseyeCoverage off
00136 GCLOGINFOPOP( Base::m_pValueLog, "...IsDone = " + (Result ? GENICAM_NAMESPACE::gcstring("true") : GENICAM_NAMESPACE::gcstring("false") ) );
00137 #pragma BullseyeCoverage on
00138
00139
00140 if(FireCallbacks)
00141 {
00142 std::list<CNodeCallback*>::iterator ptrCallback;
00143 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00144 {
00145 (*ptrCallback)->operator ()(cbPostInsideLock);
00146 }
00147 }
00148 }
00149
00150
00151 if(FireCallbacks)
00152 {
00153 std::list<CNodeCallback*>::iterator ptrCallback;
00154 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00155 {
00156 (*ptrCallback)->operator ()(cbPostOutsideLock);
00157 }
00158 }
00159
00160 return Result;
00161 }
00162
00163 };
00164
00165 }
00166
00167 #endif