ValueT.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_VALUET_H
32 #define GENAPI_VALUET_H
33 
34 #include "GenApi/NodeCallback.h"
35 #include "../IValue.h"
36 #include "Base/GCException.h"
37 #include "GenApi/impl/Log.h"
38 #include "../Synch.h"
39 
40 
41 namespace GENAPI_NAMESPACE
42 {
43 
47  template< class Base>
48  class ValueT
49  : public Base
50  {
51  public:
52 
54  virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify = false, bool IgnoreCache = false)
55  {
57  typename Base::EntryMethodFinalizer E( this, meToString, IgnoreCache );
58 
59  GCLOGINFOPUSH( Base::m_pValueLog, "ToString...");
60 
61  // Note that readability is tested regardless of Verify
62  if( !IsReadable( this ) )
63  throw ACCESS_EXCEPTION_NODE("Node is not readable");
64 
65  GENICAM_NAMESPACE::gcstring ValueStr = Base::InternalToString(Verify, IgnoreCache);
66 
67  if( Verify )
68  Base::InternalCheckError();
69 
70  GCLOGINFOPOP( Base::m_pValueLog, "...ToString = %s", ValueStr.c_str() );
71 
72  return ValueStr;
73  }
74 
76  virtual void FromString(const GENICAM_NAMESPACE::gcstring& ValueStr, bool Verify = true)
77  {
78  // a list of callbacks to fire held outside the lock-guarded area on the stack
79  std::list<CNodeCallback*> CallbacksToFire;
80  {
82  typename Base::EntryMethodFinalizer E( this, meFromString );
83 
84  if( Verify && !IsWritable( this ) )
85  throw ACCESS_EXCEPTION_NODE("Node is not writable");
86 
87  GCLOGINFO( Base::m_pValueLog, "FromString = '%s' ", ValueStr.c_str() );
88 
89  {
90  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
91 
92  Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue-like calls
93 
94  Base::InternalFromString(ValueStr, Verify);
95  }
96 
97  if (Verify)
98  Base::InternalCheckError();
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  }
116 
118  virtual bool IsValueCacheValid() const
119  {
120  return Base::InternalIsValueCacheValid();
121  }
122 
123  };
124 
125 
126 } // namespace GenApi
127 
128 #endif // GENAPI_VALUET_H
#define GCLOGINFO(cat,...)
Definition: CLog.h:129
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify=false, bool IgnoreCache=false)
Implementation of IValue::ToString()
Definition: ValueT.h:54
virtual void FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)
Implementation of IValue::FromString()
Definition: ValueT.h:76
#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
Implementation helpers for CNodeCallbackDefines a bunch of templates for creating callback-functors t...
A string class which is a clone of std::string.
Definition: GCString.h:52
virtual bool IsValueCacheValid() const
Checks if the value comes from cache or is requested from another node.
Definition: ValueT.h:118
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
#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.
Implementation of the IValue interface.
Definition: ValueT.h:48


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