RegisterSetHelper.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 / Fritz Dierks
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 //-----------------------------------------------------------------------------
00032 #ifndef REGISTER_SET_HELPER_H
00033 #define REGISTER_SET_HELPER_H
00034 
00035 namespace GENAPI_NAMESPACE
00036 {
00041     class GENAPI_DECL CRegisterSetHelper
00042     {
00043     public:
00045         static size_t CopyData( void *pvDestination, size_t nbyDestSize, const void *pvSource, size_t nbySourceSize )
00046         {
00047             if (nbyDestSize != nbySourceSize)
00048             {
00049                 throw OUT_OF_RANGE_EXCEPTION("CopyData : Destination size (%ld) does not fit source size (%d)", nbyDestSize, nbySourceSize);
00050             }
00051 
00052 #if defined(_WINDOWS_)
00053             if ( IsBadWritePtr(pvDestination, nbyDestSize) || IsBadReadPtr(pvSource, nbySourceSize) )
00054             {
00055                 throw RUNTIME_EXCEPTION("Invalid user buffer");
00056             }
00057 #endif
00058 
00059             memcpy( pvDestination, pvSource, nbySourceSize );
00060             return nbySourceSize;
00061         }
00062 
00066         template<typename T>
00067         static size_t CopyToBuffer( void *pvDestination, size_t nbyDestSize, T *d )
00068         {
00069             return CopyData( pvDestination, nbyDestSize, d, sizeof( *d ) );
00070         }
00071 
00075         template<typename T>
00076         static size_t CopyFromBuffer( T *d, const void *pvDestination, size_t nbyDestSize)
00077         {
00078             return CopyData( d, sizeof( *d ), pvDestination, nbyDestSize);
00079         }
00080     };
00081 
00082 } // namespace GenApi
00083 
00084 #endif // ifndef REGISTER_SET_HELPER_H


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 18:42:47