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_REGISTERT_H
00032 #define GENAPI_REGISTERT_H
00033
00034 #include "../IRegister.h"
00035 #include "GenApi/impl/Log.h"
00036 #include "Exception.h"
00037 #include "GenApi/Compatibility.h"
00038
00039 #ifndef _WIN32
00040 # define _snprintf snprintf
00041 #endif
00042
00043 namespace GENAPI_NAMESPACE
00044 {
00045
00046 # ifdef _MSC_VER
00047 # pragma warning ( push )
00048 # pragma warning ( disable : 4996 ) // depcretaced function
00049 # endif
00050
00053 template <class Base>
00054 class RegisterT
00055 : public Base
00056 {
00057 public:
00058
00060 virtual void Set(const uint8_t *pBuffer, int64_t Length, bool Verify = true)
00061 {
00062
00063 std::list<CNodeCallback*> CallbacksToFire;
00064 {
00065 AutoLock l(Base::GetLock());
00066 typename Base::EntryMethodFinalizer E( this, meSet );
00067
00068 if( GENICAM_NAMESPACE::CLog::IsInfoEnabled( Base::m_pValueLog ) && pBuffer )
00069 {
00070 {
00071 static const char fmt[] =
00072 "Set( %" FMT_I64 "d, 0x";
00073 static const int BufferLen(256);
00074 char _pBuffer[256];
00075
00076 int BufferLeft(_snprintf(_pBuffer, BufferLen, fmt, Length));
00077
00078
00079 for(int i = 0; i < Length; i++)
00080 {
00081 const int n =_snprintf(_pBuffer + BufferLeft,
00082 BufferLen - BufferLeft,
00083 "%02X", (unsigned int) pBuffer[i]);
00084 #pragma BullseyeCoverage off
00085 #ifdef _MSC_VER
00086 if (n < 0)
00087 #else
00088 if (BufferLeft + n >= BufferLen)
00089 #endif
00090 break;
00091 #pragma BullseyeCoverage on
00092 BufferLeft += n;
00093 }
00094
00095 GCLOGINFOPUSH( Base::m_pValueLog, "%s )...", _pBuffer);
00096 }
00097 }
00098
00099 if( Verify && !IsWritable( this ) )
00100 throw ACCESS_EXCEPTION_NODE("Node is not writable");
00101
00102 {
00103 typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire);
00104
00105 Base::PreSetValue();
00106 Base::InternalSet(pBuffer, Length);
00107
00108 if( Verify )
00109 Base::InternalCheckError();
00110 }
00111
00112 GCLOGINFOPOP( Base::m_pValueLog, "...Set" );
00113
00114
00115 std::list<CNodeCallback*>::iterator ptrCallback;
00116 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00117 {
00118 (*ptrCallback)->operator ()(cbPostInsideLock);
00119 }
00120 }
00121
00122
00123 std::list<CNodeCallback*>::iterator ptrCallback;
00124 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00125 {
00126 (*ptrCallback)->operator ()(cbPostOutsideLock);
00127 }
00128 }
00129
00130
00132 virtual void Get(uint8_t *pBuffer, int64_t Length, bool Verify = false, bool IgnoreCache = false)
00133 {
00134 AutoLock l(Base::GetLock());
00135 typename Base::EntryMethodFinalizer E( this, meGet, IgnoreCache );
00136
00137 GCLOGINFOPUSH( Base::m_pValueLog, "Get...");
00138
00139
00140 if( !IsReadable( this ) )
00141 throw ACCESS_EXCEPTION_NODE("Node is not readable");
00142
00143 Base::InternalGet(pBuffer, Length, Verify, IgnoreCache );
00144
00145 if( Verify )
00146 Base::InternalCheckError();
00147
00148 if (GENICAM_NAMESPACE::CLog::IsInfoEnabled(Base::m_pValueLog))
00149 {
00150 static const char fmt[] =
00151 "...Get( %" FMT_I64 "d ) = 0x";
00152
00153 static const int BufferLen(256);
00154 char _pBuffer[256];
00155 int BufferLeft(_snprintf(_pBuffer, BufferLen, fmt, Length));
00156
00157
00158 for(int i = 0; i < Length; i++)
00159 {
00160 const int n = _snprintf(_pBuffer + BufferLeft,
00161 BufferLen - BufferLeft,
00162 "%02X", (unsigned int) pBuffer[i]);
00163 #pragma BullseyeCoverage off
00164 #ifdef _MSC_VER
00165 if (n < 0)
00166 break;
00167 #else
00168 if (BufferLeft + n >= BufferLen)
00169 break;
00170 #endif
00171 #pragma BullseyeCoverage on
00172 BufferLeft += n;
00173 }
00174 GCLOGINFOPOP( Base::m_pValueLog, "%s", _pBuffer );
00175 }
00176 }
00177
00179 virtual int64_t GetLength()
00180 {
00181 AutoLock l(Base::GetLock());
00182
00183 return Base::InternalGetLength();
00184 }
00185
00187 virtual int64_t GetAddress()
00188 {
00189 AutoLock l(Base::GetLock());
00190
00191 return Base::InternalGetAddress(false,false);
00192 }
00193
00194 };
00195 # ifdef _MSC_VER
00196 # pragma warning ( pop )
00197 # endif
00198
00199 }
00200
00201 #endif // GENAPI_REGISTERT_H