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  }
93  if (Verify)
94  Base::InternalCheckError();
95 
96  GCLOGINFOPOP( Base::m_pValueLog, "...SetIntValue" );
97 
98  // fire callbacks inside the lock
99  std::list<CNodeCallback*>::iterator ptrCallback;
100  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
101  {
102  (*ptrCallback)->operator ()(cbPostInsideLock);
103  }
104  }
105 
106  // fire callbacks outside the lock
107  std::list<CNodeCallback*>::iterator ptrCallback;
108  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
109  {
110  (*ptrCallback)->operator ()(cbPostOutsideLock);
111  }
112  }
113 
116  {
117  return static_cast<IValue *>(this)->ToString();
118  }
119 
121  virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
122  {
123  AutoLock l(Base::GetLock());
124  typename Base::EntryMethodFinalizer E( this, meGetIntValue, IgnoreCache );
125 
126  GCLOGINFOPUSH( Base::m_pValueLog, "GetIntValue...");
127 
128  // Note that readability is tested regardless of Verify
129  if( !IsReadable( this ) )
130  throw ACCESS_EXCEPTION_NODE("Node is not readable.");
131 
132  int64_t IntValue = Base::InternalGetIntValue(Verify, IgnoreCache);
133 
134  if( Verify )
135  Base::InternalCheckError();
136 
137  GCLOGINFOPOP( Base::m_pValueLog, "...GetIntValue = %" FMT_I64 "d", IntValue );
138 
139  return IntValue;
140 
141  }
142 
143 
145  virtual IEnumEntry *GetEntry(const int64_t IntValue)
146  {
147  AutoLock l(Base::GetLock());
148 
149  return Base::InternalGetEntry(IntValue);
150  }
151 
153  virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
154  {
155  AutoLock l(Base::GetLock());
156 
157  int64_t Value = GetIntValue(Verify, IgnoreCache);
158 
159  return GetEntry(Value);
160  }
161 
164  {
165  AutoLock l(Base::GetLock());
166 
167  return Base::InternalGetEntryByName(Symbolic);
168  }
169 
170 
171  };
172 
173 }
174 #endif
virtual IEnumEntry * GetEntry(const int64_t IntValue)
Get an entry node by its IntValue.
Definition: EnumerationT.h:145
Implementation of the IEnumeration Interface.
Definition: EnumerationT.h:45
virtual IEnumEntry * GetEntryByName(const GENICAM_NAMESPACE::gcstring &Symbolic)
Implementation of IEnumeration::GetEntryByName()
Definition: EnumerationT.h:163
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
virtual GENICAM_NAMESPACE::gcstring operator*()
Implementation of IEnumeration::operator*()
Definition: EnumerationT.h:115
__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:153
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
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.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
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
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody") ...
Definition: Exception.h:172
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:130
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
#define FMT_I64
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
Definition of interface IEnumeration.
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:134
GENICAM_NAMESPACE::gcstring_vector StringList_t
A list of strings.
Definition: Types.h:150
virtual int64_t GetIntValue(bool Verify=false, bool IgnoreCache=false)
Implementation of IEnumeration::GetIntValue()
Definition: EnumerationT.h:121
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IValue
Interface for value properties.
Definition: IValue.h:61
Lexical analyzer for CIntSwissKnife.
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 Wed Mar 17 2021 02:48:40