ValueT.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_VALUET_H
00032 #define GENAPI_VALUET_H
00033 
00034 #include "GenApi/NodeCallback.h"
00035 #include "../IValue.h"
00036 #include "Base/GCException.h"
00037 #include "GenApi/impl/Log.h"
00038 #include "../Synch.h"
00039 
00040 
00041 namespace GENAPI_NAMESPACE
00042 {
00043 
00047     template< class Base>
00048     class ValueT
00049         : public Base
00050     {
00051     public:
00052 
00054         virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false)
00055         {
00056             AutoLock l(Base::GetLock());
00057             typename Base::EntryMethodFinalizer E( this, meToString, IgnoreCache );
00058 
00059             GCLOGINFOPUSH( Base::m_pValueLog, "ToString...");
00060 
00061             // Note that readability is tested regardless of Verify
00062             if( !IsReadable( this ) )
00063                 throw ACCESS_EXCEPTION_NODE("Node is not readable");
00064 
00065             GENICAM_NAMESPACE::gcstring ValueStr = Base::InternalToString(Verify, IgnoreCache);
00066 
00067             if( Verify )
00068                 Base::InternalCheckError();
00069 
00070             GCLOGINFOPOP( Base::m_pValueLog, "...ToString = %s", ValueStr.c_str() );
00071 
00072             return ValueStr;
00073         }
00074 
00076         virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true)
00077         {
00078             // a list of callbacks to fire held outside the lock-guarded area on the stack
00079             std::list<CNodeCallback*> CallbacksToFire;
00080             {
00081                 AutoLock l(Base::GetLock());
00082                 typename Base::EntryMethodFinalizer E( this, meFromString );
00083 
00084                 if( Verify && !IsWritable( this ) )
00085                     throw ACCESS_EXCEPTION_NODE("Node is not writable");
00086 
00087                 GCLOGINFO( Base::m_pValueLog, "FromString = '%s' ", ValueStr.c_str() );
00088 
00089                 {
00090                     typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire);  // dtor calls Base::PostSetValue
00091 
00092                     Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue-like calls
00093 
00094                     Base::InternalFromString(ValueStr, Verify);
00095 
00096                     if( Verify )
00097                         Base::InternalCheckError();
00098                 }
00099 
00100                 // fire callbacks inside the lock
00101                 std::list<CNodeCallback*>::iterator ptrCallback;
00102                 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00103                 {
00104                     (*ptrCallback)->operator ()(cbPostInsideLock);
00105                 }
00106             }
00107 
00108             // fire callbacks outside the lock
00109             std::list<CNodeCallback*>::iterator ptrCallback;
00110             for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00111             {
00112                 (*ptrCallback)->operator ()(cbPostOutsideLock);
00113             }
00114 
00115         }
00116 
00118         virtual bool IsValueCacheValid() const
00119         {
00120             return Base::InternalIsValueCacheValid();
00121         }
00122 
00123     };
00124 
00125 
00126 } // namespace GenApi
00127 
00128 #endif // GENAPI_VALUET_H


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