RegisterT.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //  (c) 2006 by Basler Vision Technologies
00003 //  Section: Vision Components
00004 //  Project: GenApi
00005 //  Author:  Alexander Happe
00006 //  $Header$
00007 //
00008 //  License: This file is published under the license of the EMVA GenICam  Standard Group.
00009 //  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'.
00010 //  If for some reason you are missing  this file please contact the EMVA or visit the website
00011 //  (http://www.genicam.org) for a full copy.
00012 //
00013 //  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
00014 //  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00015 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016 //  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP
00017 //  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,
00018 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO,
00019 //  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS;
00020 //  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY,
00021 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)
00022 //  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00023 //  POSSIBILITY OF SUCH DAMAGE.
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             // a list of callbacks to fire held outside(!) the autolock on the stack(!)
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                         /* MANTIS 0000062 */
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);  // dtor calls Base::PostSetValue
00102 
00103                     Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue like calls
00104                     Base::InternalSet(pBuffer, Length);
00105 
00106                     if( Verify )
00107                         Base::InternalCheckError();
00108                 }
00109 
00110                 GCLOGINFOPOP( Base::m_pValueLog, "...Set" );
00111 
00112                 // fire callbacks inside the lock
00113                 std::list<CNodeCallback*>::iterator ptrCallback;
00114                 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00115                 {
00116                     (*ptrCallback)->operator ()(cbPostInsideLock);
00117                 }
00118             }
00119 
00120             // fire callbacks outside the lock
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             // Note that readability is tested regardless of Verify
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                 /* MANTIS 0000062 */
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 } // namespace GenApi
00196 
00197 #endif // GENAPI_REGISTERT_H


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:06