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  if( Verify )
71  Base::InternalCheckError();
72 
73  // now Base::PostSetValue is called by ~PostSetValueFinalizer, i.e. updates are fired
74  // if this is the call on the top of a chain of SetValue calls
75  }
76 
77  GCLOGINFOPOP( Base::m_pValueLog, "...SetValue" );
78 
79  // fire callbacks inside the lock
80  std::list<CNodeCallback*>::iterator ptrCallback;
81  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
82  {
83  (*ptrCallback)->operator ()(cbPostInsideLock);
84  }
85  }
86 
87  // fire callbacks outside the lock
88  std::list<CNodeCallback*>::iterator ptrCallback;
89  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
90  {
91  (*ptrCallback)->operator ()(cbPostOutsideLock);
92  }
93 
94  }
95 
98  {
99  SetValue(Value);
100  return *this;
101  }
102 
104  virtual GENICAM_NAMESPACE::gcstring GetValue(bool Verify = false, bool IgnoreCache = false)
105  {
106  AutoLock l(Base::GetLock());
107 
108  GCLOGINFOPUSH( Base::m_pValueLog, "GetValue...");
109 
110  // Note that readability is tested regardless of Verify
111  if( !IsReadable( this ) )
112  throw ACCESS_EXCEPTION_NODE("Node is not readable");
113 
114  GENICAM_NAMESPACE::gcstring ValueStr( Base::InternalGetValue(Verify, IgnoreCache) );
115 
116  if( Verify )
117  Base::InternalCheckError();
118 
119  GCLOGINFOPOP( Base::m_pValueLog, "...GetValue = %s", ValueStr.c_str() );
120 
121  return ValueStr;
122 
123  }
124 
127  {
128  return GetValue();
129  }
130 
133  {
134  return GetValue();
135  }
136 
139  {
140  AutoLock l(Base::GetLock());
141 
142  GCLOGINFOPUSH( Base::m_pRangeLog, "GetMaxLength...");
143 
144  int64_t MaxLength = IsWritable( this ) ?
145  Base::InternalGetMaxLength()
146  :
147  Base::InternalGetValue().size();
148 
149  GCLOGINFOPOP( Base::m_pRangeLog, "...GetMaxLength = %" FMT_I64 "d", MaxLength );
150 
151  return MaxLength;
152  }
153 
154  };
155 
156 }
157 
158 #endif // GENAPI_STRINGT_H
virtual GENICAM_NAMESPACE::gcstring operator()()
Get node value.
Definition: StringT.h:126
virtual GENICAM_NAMESPACE::gcstring operator*()
Get node value.
Definition: StringT.h:132
virtual int64_t GetMaxLength()
Retrieves the maximum length of the string in bytes.
Definition: StringT.h:138
__int64 int64_t
Definition: config-win32.h:21
virtual IString & operator=(const GENICAM_NAMESPACE::gcstring &Value)
Set node value.
Definition: StringT.h:97
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
#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.
interface GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:163
Implementation of the IString interface.
Definition: StringT.h:46
A string class which is a clone of std::string.
Definition: GCString.h:52
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:104
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:164
#define FMT_I64
Definition: Compatibility.h:68
virtual const char * c_str(void) const
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