IEnumerationT.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: Fritz Dierks
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_IENUMERATIONT_H
32 #define GENAPI_IENUMERATIONT_H
33 
34 #include <GenApi/GenApiDll.h>
35 #include <GenApi/Types.h>
36 #include <GenApi/Pointer.h>
37 #include <GenApi/IEnumeration.h>
38 #include <GenApi/Compatibility.h>
39 #include <vector>
40 
41 namespace GENAPI_NAMESPACE
42 {
43  //*************************************************************
44  // Enumeration template interface
45  //*************************************************************
46 
51  template< typename EnumT >
53  {
55 
59  virtual void SetValue(EnumT Value, bool Verify = true) = 0;
60 
62  virtual IEnumeration& operator=(EnumT Value) = 0;
63 
65 
70  virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false) = 0;
71 
73  virtual EnumT operator()() = 0;
74 
76 
78  virtual IEnumeration& operator=(const GENICAM_NAMESPACE::gcstring& ValueStr) = 0;
79 
81  virtual IEnumEntry *GetEntry(const EnumT Value) = 0;
82 
84  virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false) = 0;
85 
86  };
87 
88  //*************************************************************
89  // CEnumerationTRef class
90  //*************************************************************
91 
92 #ifndef DOXYGEN_IGNORE
93 
99  template< class EnumT >
100  class CEnumerationTRef : public IEnumerationT< EnumT >, public IReference, public IEnumReference
101  {
102  public:
103  // Constructor
105  m_Ptr(NULL)
106  {}
107 
108  /*--------------------------------------------------------*/
109  // IReference
110  /*--------------------------------------------------------*/
111 
113  virtual void SetReference( IBase *ptr )
114  {
115  m_Ptr = dynamic_cast< IEnumeration *>( ptr );
116  }
117 
118  /*--------------------------------------------------------*/
119  // IEnumReference
120  /*--------------------------------------------------------*/
121 
123  virtual void SetNumEnums( int NumEnums )
124  {
125  m_EnumExists.resize(NumEnums);
126  m_EnumValues.resize(NumEnums);
127 
128  std::vector<bool>::iterator ptr;
129  for(ptr = m_EnumExists.begin(); ptr != m_EnumExists.end(); ptr++)
130  *ptr = false;
131 
132  }
133 
135  virtual void SetEnumReference( int Index, GENICAM_NAMESPACE::gcstring Name)
136  {
137  if ( m_Ptr )
138  {
139  CEnumEntryPtr ptrEnumEntry = GetEntryByName(Name);
140 
141  if( ptrEnumEntry.IsValid() )
142  {
143  m_EnumExists[Index] = true;
144  m_EnumValues[Index] = ptrEnumEntry->GetValue();
145  }
146  }
147  }
148 
149 
150  /*--------------------------------------------------------*/
151  // IBase
152  /*--------------------------------------------------------*/
153 
155  virtual EAccessMode GetAccessMode() const
156  {
157  if(m_Ptr)
158  return m_Ptr->GetAccessMode();
159  else
160  return NI;
161  }
162 
163  /*--------------------------------------------------------*/
164  // IValue
165  /*--------------------------------------------------------*/
166 
168  virtual INode* GetNode()
169  {
170  if(m_Ptr)
171  return m_Ptr->GetNode();
172  else
173  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
174  }
175 
177  virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false)
178  {
179  if(m_Ptr)
180  return m_Ptr->ToString(Verify, IgnoreCache);
181  else
182  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
183  }
184 
186  virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true)
187  {
188  if(m_Ptr)
189  return m_Ptr->FromString(ValueStr, Verify);
190  else
191  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
192  }
193 
195  bool IsValueCacheValid() const
196  {
197  if(m_Ptr)
198  return m_Ptr->IsValueCacheValid();
199  else
200  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
201  }
202 
203  /*--------------------------------------------------------*/
204  // IEnumeration
205  /*--------------------------------------------------------*/
206 
208  virtual void GetSymbolics(StringList_t & Symbolics)
209  {
210  if(m_Ptr)
211  return m_Ptr->GetSymbolics(Symbolics);
212  else
213  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
214  }
215 
217  virtual void GetEntries(NodeList_t & Entries)
218  {
219  if(m_Ptr)
220  return m_Ptr->GetEntries(Entries);
221  else
222  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
223  }
224 
227  {
228  if(m_Ptr)
229  return m_Ptr->operator=(ValueStr);
230  else
231  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
232  }
233 
235  virtual IEnumeration& operator=(const char *pValueStr)
236  {
237  if(m_Ptr)
238  return m_Ptr->operator=(pValueStr);
239  else
240  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
241  }
242 
244  virtual void SetIntValue(int64_t Value, bool Verify = true)
245  {
246  if(m_Ptr)
247  m_Ptr->SetIntValue(Value, Verify);
248  else
249  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
250  }
251 
254  {
255  if(m_Ptr)
256  return m_Ptr->operator*();
257  else
258  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
259  }
260 
262  virtual int64_t GetIntValue(bool Verify = false, bool IgnoreCache = false)
263  {
264  if(m_Ptr)
265  return m_Ptr->GetIntValue(Verify, IgnoreCache);
266  else
267  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
268  }
269 
272  {
273  if(m_Ptr)
274  return m_Ptr->GetEntryByName(Symbolic);
275  else
276  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
277  }
278 
279 
281  virtual IEnumEntry *GetEntry(const int64_t IntValue)
282  {
283  if(m_Ptr)
284  return m_Ptr->GetEntry(IntValue);
285  else
286  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
287  }
288 
290  virtual IEnumEntry *GetCurrentEntry(bool Verify = false, bool IgnoreCache = false)
291  {
292  if(m_Ptr)
293  return m_Ptr->GetCurrentEntry(Verify, IgnoreCache);
294  else
295  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
296  }
297 
298  /*--------------------------------------------------------*/
299  // IEnumerationT
300  /*--------------------------------------------------------*/
301 
303  virtual void SetValue(EnumT Value, bool Verify = true)
304  {
305  if(m_Ptr)
306  {
307  if( m_EnumExists[Value] )
308  {
309  int64_t EnumValue = m_EnumValues[Value];
310  m_Ptr->SetIntValue(EnumValue, Verify);
311  }
312  else
313  throw ACCESS_EXCEPTION("EnumEntry %d not present", Value);
314  }
315  else
316  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
317  }
318 
320  virtual IEnumeration& operator=(EnumT Value)
321  {
322  SetValue(Value);
323  return *this;
324  }
325 
327  virtual EnumT GetValue(bool Verify = false, bool IgnoreCache = false)
328  {
329  if(m_Ptr)
330  {
331  int64_t IntValue = m_Ptr->GetIntValue(Verify, IgnoreCache);
332  std::vector<int64_t>::iterator ptr;
333  for ( unsigned int idx = 0; idx < m_EnumValues.size(); ++idx )
334  {
335  if( m_EnumExists[idx] && m_EnumValues[idx] == IntValue)
336  return (EnumT) idx;
337  }
338  throw ACCESS_EXCEPTION("Unknown IntValue %" FMT_I64 "d", IntValue);
339  }
340  else
341  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
342  }
343 
345  virtual EnumT operator()()
346  {
347  return GetValue();
348  }
349 
351  virtual IEnumEntry *GetEntry(const EnumT Value)
352  {
353  if(m_Ptr)
354  {
355  if( m_EnumExists[Value] )
356  {
357  int64_t EnumValue = m_EnumValues[Value];
358  return m_Ptr->GetEntry(EnumValue);
359  }
360  else
361  return NULL;
362  }
363  else
364  throw ACCESS_EXCEPTION("Feature not present (reference not valid)");
365  }
366 
367  protected:
370 
372  std::vector<int64_t > m_EnumValues;
373 
375  std::vector<bool > m_EnumExists;
376 
377  };
378 
379 #endif
380 
381 }
382 
383 #endif // ifndef GENAPI_IENUMERATIONT_H
virtual GENICAM_NAMESPACE::gcstring operator*()
Get node value.
#define GENICAM_INTERFACE
Definition: GenICamFwd.h:33
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IBase
Base interface common to all nodes.
Definition: IBase.h:55
virtual void SetValue(EnumT Value, bool Verify=true)
Set node value.
Common types used in the public GenApi interface.
GENICAM_INTERFACE IEnumerationT
Interface for enumeration properties.
Definition: IEnumerationT.h:59
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
virtual bool GetValue(bool Verify=false, bool IgnoreCache=false) const =0
Get node value.
virtual INode * GetNode()
Get the INode interface of the node.
virtual void GetEntries(NodeList_t &Entries)
Get list of entry nodes.
virtual void operator=(bool Value)
Set node value.
Definition: IBoolean.h:64
virtual void SetIntValue(int64_t Value, bool Verify=true)
Set node value.
virtual EnumT operator()()
Get node value.
virtual bool operator()() const
Get node value.
Definition: IBoolean.h:75
__int64 int64_t
Definition: config-win32.h:21
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IReference
Interface to construct a reference.
Definition: Reference.h:50
virtual IEnumeration & operator=(EnumT Value)
Set node value.
virtual IEnumEntry * GetEntry(const int64_t IntValue)=0
Get an entry node by its IntValue.
virtual void GetSymbolics(StringList_t &Symbolics)
Get list of symbolic Values.
virtual EnumT GetValue(bool Verify=false, bool IgnoreCache=false)
Get node value.
virtual IEnumeration & operator=(const GENICAM_NAMESPACE::gcstring &ValueStr)
Set node value.
virtual void FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)
Set content of the node as string.
node_vector NodeList_t
a list of node references
Definition: INode.h:55
Encapsulates a GenApi pointer dealing with the dynamic_cast automatically.
Definition: Pointer.h:51
#define ACCESS_EXCEPTION
Fires a access exception, e.g. throw ACCESS_EXCEPTION("Not everybody")
Definition: GCException.h:253
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumeration
Interface for enumeration properties.
Definition: IEnumeration.h:60
virtual void SetNumEnums(int NumEnums)
sets the number of enum values
virtual void SetReference(IBase *ptr)
sets the implementation to the reference
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumReference
Interface to construct an enum reference.
Definition: Reference.h:64
IEnumeration * m_Ptr
Pointer to the implementation the reference references to.
Definition of macros for cross-platform compatibility.
std::vector< int64_t > m_EnumValues
The values for enums with a given index.
virtual IEnumEntry * GetCurrentEntry(bool Verify=false, bool IgnoreCache=false)=0
Get the current entry.
Not implemented.
Definition: Types.h:56
virtual IEnumEntry * GetCurrentEntry(bool Verify=false, bool IgnoreCache=false)
Get the current entry.
std::vector< bool > m_EnumExists
Indicates it an enum with a given index exists.
virtual IEnumEntry * GetEntryByName(const GENICAM_NAMESPACE::gcstring &Symbolic)
Get an entry node by name.
virtual EAccessMode GetAccessMode() const
Get the access mode of the node.
virtual IEnumEntry * GetEntry(const EnumT Value)
returns the EnumEntry object belonging to the Value
Definition of template CPointer.
virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify=false, bool IgnoreCache=false)
Get content of the node as string.
A string class which is a clone of std::string.
Definition: GCString.h:52
bool IsValueCacheValid() const
Checks if the value comes from cache or is requested from another node.
bool IsValid() const
true if the pointer is valid
Definition: Pointer.h:110
#define FMT_I64
enum GENAPI_NAMESPACE::_EAccessMode EAccessMode
access mode of a node
virtual IEnumEntry * GetEntry(const int64_t IntValue)
Get an entry node by its IntValue.
declspec&#39;s to be used for GenApi Windows dll
Definition of interface IEnumeration.
GENICAM_INTERFACE INode
Interface common to all nodes.
Definition: ICategory.h:51
virtual void SetEnumReference(int Index, GENICAM_NAMESPACE::gcstring Name)
sets the Enum value corresponding to a value
virtual int64_t GetIntValue(bool Verify=false, bool IgnoreCache=false)
Get node value.
GENICAM_NAMESPACE::gcstring_vector StringList_t
A list of strings.
Definition: Types.h:150
virtual IEnumeration & operator=(const char *pValueStr)
Set node value.
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IEnumEntry
Interface of single enum value.
Definition: IEnumEntry.h:60
Lexical analyzer for CIntSwissKnife.
Definition: Autovector.h:48


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:40