EnumerationT.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2006 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Alexander Happe
6 // $Header$
7 //
8 // License: This file is published under the license of the EMVA GenICam Standard Group.
9 // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'.
10 // If for some reason you are missing this file please contact the EMVA or visit the website
11 // (http://www.genicam.org) for a full copy.
12 //
13 // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
14 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP
17 // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
21 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23 // POSSIBILITY OF SUCH DAMAGE.
24 //-----------------------------------------------------------------------------
31 #ifndef GENAPI_ENUMERATIONT_H
32 #define GENAPI_ENUMERATIONT_H
33 
34 #include "GenApi/IEnumeration.h"
35 #include "GenApi/impl/Internal_Compatibility.h"
36 #include "GenApi/impl/Log.h"
37 #include "Exception.h"
38 
39 namespace GENAPI_NAMESPACE
40 {
44  template<class Base>
45  class EnumerationT : public Base
46  {
47  public:
49  virtual void GetSymbolics(StringList_t & Symbolics)
50  {
52 
53  return Base::InternalGetSymbolics(Symbolics);
54  }
55 
57  virtual void GetEntries(NodeList_t & Entries)
58  {
60 
61  return Base::InternalGetEntries(Entries);
62  }
63 
66  {
67  static_cast<IValue *>(this)->FromString(ValueStr);
68  return *this;
69  }
70 
72  virtual void SetIntValue(int64_t Value, bool Verify = true)
73  {
74  // a list of callbacks to fire held outside(!) the autolock on the stack(!)
75  std::list<CNodeCallback*> CallbacksToFire;
76  {
78  typename Base::EntryMethodFinalizer E( this, meSetIntValue );
79 
80  GCLOGINFOPUSH( Base::m_pValueLog, "SetIntValue( %" FMT_I64 "d )...", Value );
81 
82  if( Verify && !IsWritable( this ) )
83  throw ACCESS_EXCEPTION_NODE("Node is not writable.");
84 
85  {
86  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
87 
88  Base::PreSetValue();
89 
90  Base::InternalSetIntValue(Value, Verify);
91 
92  if( Verify )
93  Base::InternalCheckError();
94 
95  }
96 
97  GCLOGINFOPOP( Base::m_pValueLog, "...SetIntValue" );
98 
99  // fire callbacks inside the lock
100  std::list<CNodeCallback*>::iterator ptrCallback;
101  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
102  {
103  (*ptrCallback)->operator ()(cbPostInsideLock);
104  }
105  }
106 
107  // fire callbacks outside the lock
108  std::list<CNodeCallback*>::iterator ptrCallback;
109  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
110  {
111  (*ptrCallback)->operator ()(cbPostOutsideLock);
112  }
113  }
114 
117  {
118  return static_cast<IValue *>(this)->ToString();
119  }
120 
122  virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
123  {
124  AutoLock l(Base::GetLock());
125  typename Base::EntryMethodFinalizer E( this, meGetIntValue, IgnoreCache );
126 
127  GCLOGINFOPUSH( Base::m_pValueLog, "GetIntValue...");
128 
129  // Note that readability is tested regardless of Verify
130  if( !IsReadable( this ) )
131  throw ACCESS_EXCEPTION_NODE("Node is not readable.");
132 
133  int64_t IntValue = Base::InternalGetIntValue(Verify, IgnoreCache);
134 
135  if( Verify )
136  Base::InternalCheckError();
137 
138  GCLOGINFOPOP( Base::m_pValueLog, "...GetIntValue = %" FMT_I64 "d", IntValue );
139 
140  return IntValue;
141 
142  }
143 
144 
146  virtual IEnumEntry *GetEntry(const int64_t IntValue)
147  {
148  AutoLock l(Base::GetLock());
149 
150  return Base::InternalGetEntry(IntValue);
151  }
152 
154  virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
155  {
156  AutoLock l(Base::GetLock());
157 
158  int64_t Value = GetIntValue(Verify, IgnoreCache);
159 
160  return GetEntry(Value);
161  }
162 
165  {
166  AutoLock l(Base::GetLock());
167 
168  return Base::InternalGetEntryByName(Symbolic);
169  }
170 
171 
172  };
173 
174 }
175 #endif
virtual IEnumEntry * GetEntry(const int64_t IntValue)
Get an entry node by its IntValue.
Definition: EnumerationT.h:146
Implementation of the IEnumeration Interface.
Definition: EnumerationT.h:45
virtual IEnumEntry * GetEntryByName(const GENICAM_NAMESPACE::gcstring &Symbolic)
Implementation of IEnumeration::GetEntryByName()
Definition: EnumerationT.h:164
virtual GENICAM_NAMESPACE::gcstring operator*()
Implementation of IEnumeration::operator*()
Definition: EnumerationT.h:116
__int64 int64_t
Definition: config-win32.h:21
virtual void GetSymbolics(StringList_t &Symbolics)
Implementation of IEnumeration::GetSymbolics()
Definition: EnumerationT.h:49
virtual IEnumEntry * GetCurrentEntry(bool Verify=false, bool IgnoreCache=false)
Get the current entry.
Definition: EnumerationT.h:154
interface GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
interface GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
virtual void FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)=0
Set content of the node as string.
node_vector NodeList_t
a list of node references
Definition: INode.h:55
virtual GENICAM_NAMESPACE::gcstring ToString()=0
Returns a string representation of the digit.
virtual void GetEntries(NodeList_t &Entries)
Implementation of IEnumeration::GetEntries()
Definition: EnumerationT.h:57
virtual IEnumeration & operator=(const GENICAM_NAMESPACE::gcstring &ValueStr)
Implementation of IEnumeration::operator=()
Definition: EnumerationT.h:65
interface GENAPI_DECL_ABSTRACT IValue
Interface for value properties.
Definition: IValue.h:61
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody") ...
Definition: Exception.h:172
interface GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:163
virtual void SetIntValue(int64_t Value, bool Verify=true)
Implementation of IEnumeration::SetIntValue()
Definition: EnumerationT.h:72
A string class which is a clone of std::string.
Definition: GCString.h:52
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
Definition of interface IEnumeration.
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:164
GENICAM_NAMESPACE::gcstring_vector StringList_t
A list of strings.
Definition: Types.h:150
#define FMT_I64
Definition: Compatibility.h:68
virtual int64_t GetIntValue(bool Verify=false, bool IgnoreCache=false)
Implementation of IEnumeration::GetIntValue()
Definition: EnumerationT.h:122
Part of the generic device API.
Definition: Autovector.h:48
callback is fired on leaving the tree inside the lock-guarded area
Definition: NodeCallback.h:48
virtual CLock & GetLock() const =0
Returns the lock which guards the node map.


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:54