IEnumerationT.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:  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 //-----------------------------------------------------------------------------
00031 #ifndef GENAPI_IENUMERATIONT_H
00032 #define GENAPI_IENUMERATIONT_H
00033 
00034 #include <GenApi/GenApiDll.h>
00035 #include <GenApi/Types.h>
00036 #include <GenApi/Pointer.h>
00037 #include <GenApi/IEnumeration.h>
00038 #include <GenApi/Compatibility.h>
00039 #include <vector>
00040 
00041 namespace GENAPI_NAMESPACE
00042 {
00043     //*************************************************************
00044     // Enumeration template interface
00045     //*************************************************************
00046 
00051     template< typename EnumT >
00052     interface IEnumerationT  : public IEnumeration
00053     {
00055 
00059         virtual void SetValue(EnumT Value, bool Verify = true) = 0;
00060 
00062         virtual IEnumeration& operator=(EnumT Value) = 0;
00063 
00065 
00070         virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false) = 0;
00071 
00073         virtual EnumT operator()() = 0;
00074 
00076 
00078         virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr) = 0;
00079 
00081         virtual IEnumEntry *GetEntry(const EnumT Value) = 0;
00082 
00084         virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false) = 0;
00085 
00086     };
00087 
00088     //*************************************************************
00089     // CEnumerationTRef class
00090     //*************************************************************
00091 
00092 #ifndef DOXYGEN_IGNORE
00093 
00099     template< class EnumT >
00100     class CEnumerationTRef : public IEnumerationT< EnumT >, public IReference, public IEnumReference
00101     {
00102     public:
00103         // Constructor
00104         CEnumerationTRef() :
00105           m_Ptr(NULL)
00106           {}
00107 
00108           /*--------------------------------------------------------*/
00109           // IReference
00110           /*--------------------------------------------------------*/
00111 
00113           virtual void SetReference( IBase *ptr )
00114           {
00115               m_Ptr = dynamic_cast< IEnumeration *>( ptr );
00116           }
00117 
00118           /*--------------------------------------------------------*/
00119           // IEnumReference
00120           /*--------------------------------------------------------*/
00121 
00123           virtual void SetNumEnums( int NumEnums )
00124           {
00125               m_EnumExists.resize(NumEnums);
00126               m_EnumValues.resize(NumEnums);
00127 
00128               std::vector<bool>::iterator ptr;
00129               for(ptr = m_EnumExists.begin(); ptr != m_EnumExists.end(); ptr++)
00130                   *ptr = false;
00131 
00132           }
00133 
00135           virtual void SetEnumReference( int Index, GENICAM_NAMESPACE::gcstring Name)
00136           {
00137               if ( m_Ptr )
00138               {
00139                   CEnumEntryPtr ptrEnumEntry = GetEntryByName(Name);
00140 
00141                   if( ptrEnumEntry.IsValid() )
00142                   {
00143                       m_EnumExists[Index] = true;
00144                       m_EnumValues[Index] = ptrEnumEntry->GetValue();
00145                   }
00146               }
00147           }
00148 
00149 
00150           /*--------------------------------------------------------*/
00151           // IBase
00152           /*--------------------------------------------------------*/
00153 
00155           virtual EAccessMode GetAccessMode() const
00156           {
00157               if(m_Ptr)
00158                   return m_Ptr->GetAccessMode();
00159               else
00160                   return NI;
00161           }
00162 
00163           /*--------------------------------------------------------*/
00164           // IValue
00165           /*--------------------------------------------------------*/
00166 
00168           virtual INode* GetNode()
00169           {
00170               if(m_Ptr)
00171                   return m_Ptr->GetNode();
00172               else
00173                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00174           }
00175 
00177           virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false)
00178           {
00179               if(m_Ptr)
00180                   return m_Ptr->ToString(Verify, IgnoreCache);
00181               else
00182                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00183           }
00184 
00186           virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true)
00187           {
00188               if(m_Ptr)
00189                   return m_Ptr->FromString(ValueStr, Verify);
00190               else
00191                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00192           }
00193 
00195           bool IsValueCacheValid() const
00196           {
00197               if(m_Ptr)
00198                   return m_Ptr->IsValueCacheValid();
00199               else
00200                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00201           }
00202 
00203           /*--------------------------------------------------------*/
00204           // IEnumeration
00205           /*--------------------------------------------------------*/
00206 
00208           virtual void GetSymbolics(StringList_t & Symbolics)
00209           {
00210               if(m_Ptr)
00211                   return m_Ptr->GetSymbolics(Symbolics);
00212               else
00213                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00214           }
00215 
00217           virtual void GetEntries(NodeList_t & Entries)
00218           {
00219               if(m_Ptr)
00220                   return m_Ptr->GetEntries(Entries);
00221               else
00222                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00223           }
00224 
00226           virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr)
00227           {
00228               if(m_Ptr)
00229                   return m_Ptr->operator=(ValueStr);
00230               else
00231                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00232           }
00233 
00235           virtual IEnumeration& operator=(const char *pValueStr)
00236           {
00237               if(m_Ptr)
00238                   return m_Ptr->operator=(pValueStr);
00239               else
00240                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00241           }
00242 
00244           virtual void SetIntValue(int64_t Value, bool Verify = true)
00245           {
00246               if(m_Ptr)
00247                   m_Ptr->SetIntValue(Value, Verify);
00248               else
00249                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00250           }
00251 
00253           virtual GENICAM_NAMESPACE::gcstring operator*()
00254           {
00255               if(m_Ptr)
00256                   return m_Ptr->operator*();
00257               else
00258                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00259           }
00260 
00262           virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
00263           {
00264               if(m_Ptr)
00265                   return m_Ptr->GetIntValue(Verify, IgnoreCache);
00266               else
00267                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00268           }
00269 
00271           virtual IEnumEntry *GetEntryByName(const GENICAM_NAMESPACE::gcstring& Symbolic)
00272           {
00273               if(m_Ptr)
00274                   return m_Ptr->GetEntryByName(Symbolic);
00275               else
00276                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00277           }
00278 
00279 
00281           virtual IEnumEntry *GetEntry(const int64_t IntValue)
00282           {
00283               if(m_Ptr)
00284                   return m_Ptr->GetEntry(IntValue);
00285               else
00286                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00287           }
00288 
00290           virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
00291           {
00292               if(m_Ptr)
00293                   return m_Ptr->GetCurrentEntry(Verify, IgnoreCache);
00294               else
00295                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00296           }
00297 
00298           /*--------------------------------------------------------*/
00299           // IEnumerationT
00300           /*--------------------------------------------------------*/
00301 
00303           virtual void SetValue(EnumT Value, bool Verify = true)
00304           {
00305               if(m_Ptr)
00306               {
00307                   if( m_EnumExists[Value] )
00308                   {
00309                       int64_t EnumValue = m_EnumValues[Value];
00310                       m_Ptr->SetIntValue(EnumValue, Verify);
00311                   }
00312                   else
00313                       throw ACCESS_EXCEPTION("EnumEntry %d not present", Value);
00314               }
00315               else
00316                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00317           }
00318 
00320           virtual IEnumeration& operator=(EnumT Value)
00321           {
00322               SetValue(Value);
00323               return *this;
00324           }
00325 
00327           virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false)
00328           {
00329               if(m_Ptr)
00330               {
00331                   int64_t IntValue = m_Ptr->GetIntValue(Verify, IgnoreCache);
00332                   std::vector<int64_t>::iterator ptr;
00333                   for ( unsigned int idx = 0; idx < m_EnumValues.size(); ++idx )
00334                   {
00335                       if( m_EnumExists[idx] &&  m_EnumValues[idx] == IntValue)
00336                           return (EnumT) idx;
00337                   }
00338                   throw ACCESS_EXCEPTION("Unknown IntValue %" FMT_I64 "d", IntValue);
00339               }
00340               else
00341                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00342           }
00343 
00345           virtual EnumT operator()()
00346           {
00347               return GetValue();
00348           }
00349 
00351           virtual IEnumEntry *GetEntry(const EnumT Value)
00352           {
00353               if(m_Ptr)
00354               {
00355                   if( m_EnumExists[Value] )
00356                   {
00357                       int64_t EnumValue = m_EnumValues[Value];
00358                       return m_Ptr->GetEntry(EnumValue);
00359                   }
00360                   else
00361                       return NULL;
00362               }
00363               else
00364                   throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
00365           }
00366 
00367     protected:
00369         IEnumeration *m_Ptr;
00370 
00372         std::vector<int64_t > m_EnumValues;
00373 
00375         std::vector<bool > m_EnumExists;
00376 
00377     };
00378 
00379 #endif
00380 
00381 }
00382 
00383 #endif // ifndef GENAPI_IENUMERATIONT_H


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