All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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, Base::IsStreamable(), 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, Base::IsStreamable());
83 
84  if (!Base::CanBeWritten( Verify ))
85  {
86  throw ACCESS_EXCEPTION_NODE( "Node is not writable." );
87  }
88 
89  GCLOGINFO( Base::m_pValueLog, "FromString = '%s' ", ValueStr.c_str() );
90 
91  {
92  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
93 
94  Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue-like calls
95 
96  Base::InternalFromString(ValueStr, Verify);
97  }
98 
99  if (Verify)
100  Base::InternalCheckError();
101 
102  // fire callbacks inside the lock
103  std::list<CNodeCallback*>::iterator ptrCallback;
104  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
105  {
106  (*ptrCallback)->operator ()(cbPostInsideLock);
107  }
108  }
109 
110  // fire callbacks outside the lock
111  std::list<CNodeCallback*>::iterator ptrCallback;
112  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
113  {
114  (*ptrCallback)->operator ()(cbPostOutsideLock);
115  }
116 
117  }
118 
120  virtual bool IsValueCacheValid() const
121  {
122  return Base::InternalIsValueCacheValid();
123  }
124 
125  };
126 
127 
128 } // namespace GenApi
129 
130 #endif // GENAPI_VALUET_H
GENAPI_NAMESPACE
Lexical analyzer for CIntSwissKnife.
Definition: Destructible.h:30
NodeCallback.h
Implementation helpers for CNodeCallback.
GENAPI_NAMESPACE::meToString
@ meToString
Definition: Exception.h:44
GENAPI_NAMESPACE::cbPostOutsideLock
@ cbPostOutsideLock
callback is fired on leaving the tree inside the lock-guarded area
Definition: NodeCallback.h:48
GENAPI_NAMESPACE::ValueT::IsValueCacheValid
virtual bool IsValueCacheValid() const
Checks if the value comes from cache or is requested from another node.
Definition: ValueT.h:120
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::ValueT
Implementation of the IValue interface.
Definition: ValueT.h:48
GENAPI_NAMESPACE::Verify
GENICAM_INTERFACE GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
GCLOGINFOPOP
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:134
GENAPI_NAMESPACE::ValueT::FromString
virtual void FromString(const GENICAM_NAMESPACE::gcstring &ValueStr, bool Verify=true)
Implementation of IValue::FromString()
Definition: ValueT.h:76
GENAPI_NAMESPACE::CanBeWritten
virtual bool CanBeWritten(bool Verify)=0
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::ValueT::ToString
virtual GENICAM_NAMESPACE::gcstring ToString(bool Verify=false, bool IgnoreCache=false)
Implementation of IValue::ToString()
Definition: ValueT.h:54
GENAPI_NAMESPACE::IsReadable
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
GENAPI_NAMESPACE::AutoLock
Definition: Synch.h:139
GENAPI_NAMESPACE::meFromString
@ meFromString
Definition: Exception.h:45
GENAPI_NAMESPACE::IsStreamable
virtual bool IsStreamable() const =0
True if the node is streamable.
GENICAM_NAMESPACE::gcstring::c_str
virtual const char * c_str(void) const
GENAPI_NAMESPACE::cbPostInsideLock
@ cbPostInsideLock
Definition: NodeCallback.h:47
GCLOGINFO
#define GCLOGINFO(cat,...)
Definition: CLog.h:129
GCException.h
GCLOGINFOPUSH
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:130


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