EnumerationT.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_ENUMERATIONT_H
00032 #define GENAPI_ENUMERATIONT_H
00033 
00034 #include "GenApi/IEnumeration.h"
00035 #include "GenApi/impl/Internal_Compatibility.h"
00036 #include "GenApi/impl/Log.h"
00037 #include "Exception.h"
00038 
00039 namespace GENAPI_NAMESPACE
00040 {
00044     template<class Base>
00045     class EnumerationT : public Base
00046     {
00047     public:
00049         virtual void GetSymbolics(StringList_t & Symbolics)
00050         {
00051             AutoLock l(Base::GetLock());
00052 
00053             return Base::InternalGetSymbolics(Symbolics);
00054         }
00055 
00057         virtual void GetEntries(NodeList_t & Entries)
00058         {
00059             AutoLock l(Base::GetLock());
00060 
00061             return Base::InternalGetEntries(Entries);
00062         }
00063 
00065         virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr)
00066         {
00067             static_cast<IValue *>(this)->FromString(ValueStr);
00068             return *this;
00069         }
00070 
00072         virtual void SetIntValue(int64_t Value, bool Verify = true)
00073         {
00074             // a list of callbacks to fire held outside(!) the autolock on the stack(!)
00075             std::list<CNodeCallback*> CallbacksToFire;
00076             {
00077                 AutoLock l(Base::GetLock());
00078                 typename Base::EntryMethodFinalizer E( this, meSetIntValue );
00079 
00080                 GCLOGINFOPUSH( Base::m_pValueLog, "SetIntValue( %" FMT_I64 "d )...", Value );
00081 
00082                 if( Verify && !IsWritable( this ) )
00083                     throw ACCESS_EXCEPTION_NODE("Node is not writable.");
00084 
00085                 {
00086                     typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire);  // dtor calls Base::PostSetValue
00087 
00088                     Base::PreSetValue();
00089 
00090                     Base::InternalSetIntValue(Value, Verify);
00091 
00092                     if( Verify )
00093                         Base::InternalCheckError();
00094 
00095                 }
00096 
00097                 GCLOGINFOPOP( Base::m_pValueLog, "...SetIntValue" );
00098 
00099                 // fire callbacks inside the lock
00100                 std::list<CNodeCallback*>::iterator ptrCallback;
00101                 for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00102                 {
00103                     (*ptrCallback)->operator ()(cbPostInsideLock);
00104                 }
00105             }
00106 
00107             // fire callbacks outside the lock
00108             std::list<CNodeCallback*>::iterator ptrCallback;
00109             for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
00110             {
00111                 (*ptrCallback)->operator ()(cbPostOutsideLock);
00112             }
00113         }
00114 
00116         virtual GENICAM_NAMESPACE::gcstring operator*()
00117         {
00118             return static_cast<IValue *>(this)->ToString();
00119         }
00120 
00122         virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
00123         {
00124             AutoLock l(Base::GetLock());
00125             typename Base::EntryMethodFinalizer E( this, meGetIntValue, IgnoreCache );
00126 
00127             GCLOGINFOPUSH( Base::m_pValueLog, "GetIntValue...");
00128 
00129             // Note that readability is tested regardless of Verify
00130             if( !IsReadable( this ) )
00131                 throw ACCESS_EXCEPTION_NODE("Node is not readable.");
00132 
00133             int64_t IntValue = Base::InternalGetIntValue(Verify, IgnoreCache);
00134 
00135             if( Verify )
00136                 Base::InternalCheckError();
00137 
00138             GCLOGINFOPOP( Base::m_pValueLog, "...GetIntValue = %" FMT_I64 "d", IntValue );
00139 
00140             return IntValue;
00141 
00142         }
00143 
00144 
00146         virtual IEnumEntry *GetEntry(const int64_t IntValue)
00147         {
00148             AutoLock l(Base::GetLock());
00149 
00150             return Base::InternalGetEntry(IntValue);
00151         }
00152 
00154         virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
00155         {
00156             AutoLock l(Base::GetLock());
00157 
00158             int64_t Value = GetIntValue(Verify, IgnoreCache);
00159 
00160             return GetEntry(Value);
00161         }
00162 
00164         virtual IEnumEntry *GetEntryByName(const GENICAM_NAMESPACE::gcstring& Symbolic)
00165         {
00166             AutoLock l(Base::GetLock());
00167 
00168             return Base::InternalGetEntryByName(Symbolic);
00169         }
00170 
00171 
00172     };
00173 
00174 }
00175 #endif


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