StringT.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_STRINGT_H
00032 #define GENAPI_STRINGT_H
00033 
00034 #include "../IString.h"
00035 #include "GenApi/Compatibility.h"
00036 #include "GenApi/impl/Log.h"
00037 #include "Exception.h"
00038 
00039 namespace GENAPI_NAMESPACE
00040 {
00041 
00045     template< class Base >
00046     class StringT : public Base
00047     {
00048     public:
00050         virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true)
00051         {
00052             // a list of callbacks to fire held outside(!) the autolock on the stack(!)
00053             std::list<CNodeCallback*> CallbacksToFire;
00054             {
00055                 AutoLock l(Base::GetLock());
00056                 typename Base::EntryMethodFinalizer E( this, meSetValue );
00057 
00058                 GCLOGINFOPUSH( Base::m_pValueLog, "SetValue( '%s' )...", Value.c_str() );
00059 
00060                 if( Verify && !IsWritable( this ) )
00061                     throw  ACCESS_EXCEPTION_NODE("Node is not writable");
00062 
00063                 {
00064                     typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire);  // dtor calls Base::PostSetValue
00065 
00066                     Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue calls
00067 
00068                     Base::InternalSetValue(Value, Verify);
00069 
00070                     if( Verify )
00071                         Base::InternalCheckError();
00072 
00073                     // now Base::PostSetValue is called by ~PostSetValueFinalizer, i.e. updates are fired
00074                     // if this is the call on the top of a chain of SetValue calls
00075                 }
00076 
00077                 GCLOGINFOPOP( Base::m_pValueLog, "...SetValue" );
00078 
00079                 // fire callbacks inside the lock
00080                 std::list<CNodeCallback*>::iterator ptrCallback;
00081                 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00082                 {
00083                     (*ptrCallback)->operator ()(cbPostInsideLock);
00084                 }
00085             }
00086 
00087             // fire callbacks outside the lock
00088             std::list<CNodeCallback*>::iterator ptrCallback;
00089             for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00090             {
00091                 (*ptrCallback)->operator ()(cbPostOutsideLock);
00092             }
00093 
00094         }
00095 
00097         virtual IString& operator=(const GENICAM_NAMESPACE::gcstring& Value)
00098         {
00099             SetValue(Value);
00100             return *this;
00101         }
00102 
00104         virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false)
00105         {
00106             AutoLock l(Base::GetLock());
00107 
00108             GCLOGINFOPUSH( Base::m_pValueLog, "GetValue...");
00109 
00110             // Note that readability is tested regardless of Verify
00111             if( !IsReadable( this ) )
00112                 throw ACCESS_EXCEPTION_NODE("Node is not readable");
00113 
00114             GENICAM_NAMESPACE::gcstring ValueStr( Base::InternalGetValue(Verify, IgnoreCache) );
00115 
00116             if( Verify )
00117                 Base::InternalCheckError();
00118 
00119             GCLOGINFOPOP( Base::m_pValueLog, "...GetValue = %s", ValueStr.c_str() );
00120 
00121             return ValueStr;
00122 
00123         }
00124 
00126         virtual GENICAM_NAMESPACE::gcstring operator()()
00127         {
00128             return GetValue();
00129         }
00130 
00132         virtual GENICAM_NAMESPACE::gcstring operator*()
00133         {
00134             return GetValue();
00135         }
00136 
00138         virtual int64_t GetMaxLength()
00139         {
00140             AutoLock l(Base::GetLock());
00141 
00142             GCLOGINFOPUSH( Base::m_pRangeLog, "GetMaxLength...");
00143 
00144             int64_t MaxLength = IsWritable( this ) ?
00145                 Base::InternalGetMaxLength() 
00146                 :
00147                 Base::InternalGetValue().size();
00148 
00149             GCLOGINFOPOP( Base::m_pRangeLog, "...GetMaxLength = %" FMT_I64 "d", MaxLength );
00150 
00151             return MaxLength;
00152         }
00153     
00154     };
00155 
00156 }
00157 
00158 #endif // GENAPI_STRINGT_H


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