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