All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  Base::InternalGetSymbolics(Symbolics);
54  }
55 
57  virtual void GetEntries(NodeList_t & Entries)
58  {
60 
61  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, Base::IsStreamable());
79 
80  GCLOGINFOPUSH( Base::m_pValueLog, "SetIntValue( %" FMT_I64 "d )...", Value );
81 
82  if (!Base::CanBeWritten( Verify ))
83  {
84  throw ACCESS_EXCEPTION_NODE( "Node is not writable." );
85  }
86 
87  {
88  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
89 
90  Base::PreSetValue();
91 
92  Base::InternalSetIntValue(Value, Verify);
93 
94  }
95  if (Verify)
96  Base::InternalCheckError();
97 
98  GCLOGINFOPOP( Base::m_pValueLog, "...SetIntValue" );
99 
100  // fire callbacks inside the lock
101  std::list<CNodeCallback*>::iterator ptrCallback;
102  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
103  {
104  (*ptrCallback)->operator ()(cbPostInsideLock);
105  }
106  }
107 
108  // fire callbacks outside the lock
109  std::list<CNodeCallback*>::iterator ptrCallback;
110  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
111  {
112  (*ptrCallback)->operator ()(cbPostOutsideLock);
113  }
114  }
115 
118  {
119  return static_cast<IValue *>(this)->ToString();
120  }
121 
123  virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
124  {
125  AutoLock l(Base::GetLock());
126  typename Base::EntryMethodFinalizer E(this, meGetIntValue, Base::IsStreamable(), IgnoreCache);
127 
128  GCLOGINFOPUSH( Base::m_pValueLog, "GetIntValue...");
129 
130  // Note that readability is tested regardless of Verify
131  if( !IsReadable( this ) )
132  throw ACCESS_EXCEPTION_NODE("Node is not readable.");
133 
134  int64_t IntValue = Base::InternalGetIntValue(Verify, IgnoreCache);
135 
136  if( Verify )
137  Base::InternalCheckError();
138 
139  GCLOGINFOPOP( Base::m_pValueLog, "...GetIntValue = %" FMT_I64 "d", IntValue );
140 
141  return IntValue;
142 
143  }
144 
145 
147  virtual IEnumEntry *GetEntry(const int64_t IntValue)
148  {
149  AutoLock l(Base::GetLock());
150 
151  return Base::InternalGetEntry(IntValue);
152  }
153 
155  virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
156  {
157  AutoLock l(Base::GetLock());
158 
159  int64_t Value = GetIntValue(Verify, IgnoreCache);
160 
161  return GetEntry(Value);
162  }
163 
166  {
167  AutoLock l(Base::GetLock());
168 
169  return Base::InternalGetEntryByName(Symbolic);
170  }
171 
172 
173  };
174 
175 }
176 #endif
GENAPI_NAMESPACE::ToString
virtual GENICAM_NAMESPACE::gcstring ToString()=0
Returns a string representation of the digit.
GENAPI_NAMESPACE
Lexical analyzer for CIntSwissKnife.
Definition: Destructible.h:30
GENAPI_NAMESPACE::cbPostOutsideLock
@ cbPostOutsideLock
callback is fired on leaving the tree inside the lock-guarded area
Definition: NodeCallback.h:48
IEnumeration.h
Definition of interface IEnumeration.
GENICAM_NAMESPACE::gcstring
A string class which is a clone of std::string.
Definition: GCString.h:52
GENAPI_NAMESPACE::GetLock
virtual CLock & GetLock() const =0
Returns the lock which guards the node map.
GENAPI_NAMESPACE::EnumerationT::SetIntValue
virtual void SetIntValue(int64_t Value, bool Verify=true)
Implementation of IEnumeration::SetIntValue()
Definition: EnumerationT.h:72
GENAPI_NAMESPACE::meSetIntValue
@ meSetIntValue
Definition: Exception.h:53
GENAPI_NAMESPACE::Verify
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
GCLOGINFOPOP
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:134
GENAPI_NAMESPACE::EnumerationT::GetEntries
virtual void GetEntries(NodeList_t &Entries)
Implementation of IEnumeration::GetEntries()
Definition: EnumerationT.h:57
Exception.h
GENAPI_NAMESPACE::EnumerationT::GetCurrentEntry
virtual IEnumEntry * GetCurrentEntry(bool Verify=false, bool IgnoreCache=false)
Get the current entry.
Definition: EnumerationT.h:155
GENAPI_NAMESPACE::CanBeWritten
virtual bool CanBeWritten(bool Verify)=0
GENAPI_NAMESPACE::EnumerationT::operator*
virtual GENICAM_NAMESPACE::gcstring operator*()
Implementation of IEnumeration::operator*()
Definition: EnumerationT.h:117
GENAPI_NAMESPACE::EnumerationT
Implementation of the IEnumeration Interface.
Definition: EnumerationT.h:45
ACCESS_EXCEPTION_NODE
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody")
Definition: Exception.h:179
GENAPI_NAMESPACE::IEnumeration
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
GENAPI_NAMESPACE::IsReadable
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
GENAPI_NAMESPACE::AutoLock
Definition: Synch.h:139
GENAPI_NAMESPACE::EnumerationT::operator=
virtual IEnumeration & operator=(const GENICAM_NAMESPACE::gcstring &ValueStr)
Implementation of IEnumeration::operator=()
Definition: EnumerationT.h:65
GENAPI_NAMESPACE::meGetIntValue
@ meGetIntValue
Definition: Exception.h:54
GENAPI_NAMESPACE::IValue
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IValue
Interface for value properties.
Definition: IValue.h:61
int64_t
__int64 int64_t
Definition: config-win32.h:21
GENAPI_NAMESPACE::IsStreamable
virtual bool IsStreamable() const =0
True if the node is streamable.
GENAPI_NAMESPACE::EnumerationT::GetEntryByName
virtual IEnumEntry * GetEntryByName(const GENICAM_NAMESPACE::gcstring &Symbolic)
Implementation of IEnumeration::GetEntryByName()
Definition: EnumerationT.h:165
GENAPI_NAMESPACE::EnumerationT::GetIntValue
virtual int64_t GetIntValue(bool Verify=false, bool IgnoreCache=false)
Implementation of IEnumeration::GetIntValue()
Definition: EnumerationT.h:123
GENAPI_NAMESPACE::cbPostInsideLock
@ cbPostInsideLock
Definition: NodeCallback.h:47
GENAPI_NAMESPACE::EnumerationT::GetSymbolics
virtual void GetSymbolics(StringList_t &Symbolics)
Implementation of IEnumeration::GetSymbolics()
Definition: EnumerationT.h:49
GCLOGINFOPUSH
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:130
FMT_I64
#define FMT_I64
Definition: GCCompatibility.h:35
GENAPI_NAMESPACE::StringList_t
GENICAM_NAMESPACE::gcstring_vector StringList_t
A list of strings.
Definition: Types.h:149
GENAPI_NAMESPACE::FromString
virtual void FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)=0
Set content of the node as string.
GENAPI_NAMESPACE::IEnumEntry
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
GENAPI_NAMESPACE::NodeList_t
node_vector NodeList_t
a list of node references
Definition: INode.h:55
GENAPI_NAMESPACE::EnumerationT::GetEntry
virtual IEnumEntry * GetEntry(const int64_t IntValue)
Get an entry node by its IntValue.
Definition: EnumerationT.h:147


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11