StringT.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_STRINGT_H
32 #define GENAPI_STRINGT_H
33 
34 #include "../IString.h"
35 #include "GenApi/Compatibility.h"
36 #include "GenApi/impl/Log.h"
37 #include "Exception.h"
38 
39 namespace GENAPI_NAMESPACE
40 {
41 
45  template< class Base >
46  class StringT : public Base
47  {
48  public:
50  virtual void SetValue(const GENICAM_NAMESPACE::gcstring& Value, bool Verify = true)
51  {
52  // a list of callbacks to fire held outside(!) the autolock on the stack(!)
53  std::list<CNodeCallback*> CallbacksToFire;
54  {
56  typename Base::EntryMethodFinalizer E( this, meSetValue );
57 
58  GCLOGINFOPUSH( Base::m_pValueLog, "SetValue( '%s' )...", Value.c_str() );
59 
60  if( Verify && !IsWritable( this ) )
61  throw ACCESS_EXCEPTION_NODE("Node is not writable");
62 
63  {
64  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
65 
66  Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue calls
67 
68  Base::InternalSetValue(Value, Verify);
69 
70  // now Base::PostSetValue is called by ~PostSetValueFinalizer, i.e. updates are fired
71  // if this is the call on the top of a chain of SetValue calls
72  }
73  if (Verify)
74  Base::InternalCheckError();
75 
76  GCLOGINFOPOP( Base::m_pValueLog, "...SetValue" );
77 
78  // fire callbacks inside the lock
79  std::list<CNodeCallback*>::iterator ptrCallback;
80  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
81  {
82  (*ptrCallback)->operator ()(cbPostInsideLock);
83  }
84  }
85 
86  // fire callbacks outside the lock
87  std::list<CNodeCallback*>::iterator ptrCallback;
88  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
89  {
90  (*ptrCallback)->operator ()(cbPostOutsideLock);
91  }
92 
93  }
94 
97  {
98  SetValue(Value);
99  return *this;
100  }
101 
103  virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false)
104  {
105  AutoLock l(Base::GetLock());
106 
107  GCLOGINFOPUSH( Base::m_pValueLog, "GetValue...");
108 
109  // Note that readability is tested regardless of Verify
110  if( !IsReadable( this ) )
111  throw ACCESS_EXCEPTION_NODE("Node is not readable");
112 
113  GENICAM_NAMESPACE::gcstring ValueStr( Base::InternalGetValue(Verify, IgnoreCache) );
114 
115  if( Verify )
116  Base::InternalCheckError();
117 
118  GCLOGINFOPOP( Base::m_pValueLog, "...GetValue = %s", ValueStr.c_str() );
119 
120  return ValueStr;
121 
122  }
123 
126  {
127  return GetValue();
128  }
129 
132  {
133  return GetValue();
134  }
135 
137  virtual int64_t GetMaxLength( bool Verify = false )
138  {
139  AutoLock l(Base::GetLock());
140 
141  GCLOGINFOPUSH( Base::m_pRangeLog, "GetMaxLength...");
142 
143  int64_t MaxLength = IsWritable( this ) ?
144  Base::InternalGetMaxLength( Verify )
145  :
146  Base::InternalGetValue( Verify ).size();
147 
148  GCLOGINFOPOP( Base::m_pRangeLog, "...GetMaxLength = %" FMT_I64 "d", MaxLength );
149 
150  return MaxLength;
151  }
152 
153  };
154 
155 }
156 
157 #endif // GENAPI_STRINGT_H
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
virtual GENICAM_NAMESPACE::gcstring operator()()
Get node value.
Definition: StringT.h:125
virtual GENICAM_NAMESPACE::gcstring operator*()
Get node value.
Definition: StringT.h:131
__int64 int64_t
Definition: config-win32.h:21
virtual IString & operator=(const GENICAM_NAMESPACE::gcstring &Value)
Set node value.
Definition: StringT.h:96
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
virtual void SetValue(const GENICAM_NAMESPACE::gcstring &Value, bool Verify=true)
Set node value.
Definition: StringT.h:50
virtual int64_t GetMaxLength(bool Verify=false)
Retrieves the maximum length of the string in bytes.
Definition: StringT.h:137
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody") ...
Definition: Exception.h:172
Definition of macros for cross-platform compatibility.
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:130
Implementation of the IString interface.
Definition: StringT.h:46
A string class which is a clone of std::string.
Definition: GCString.h:52
#define FMT_I64
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT IString
Interface for string properties.
Definition: IString.h:61
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify=false, bool IgnoreCache=false)
Get node value.
Definition: StringT.h:103
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:134
virtual const char * c_str(void) const
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:41