BooleanT.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_BOOLEANT_H
32 #define GENAPI_BOOLEANT_H
33 
34 #include "../IBoolean.h"
35 #include "GenApi/impl/Log.h"
36 #include "Exception.h"
37 
38 namespace GENAPI_NAMESPACE
39 {
40 
44  template <class Base>
45  class BooleanT : public Base
46  {
47  public:
48 
50  //{
52  virtual void SetValue(bool Value, bool Verify = true)
53  {
54  // a list of callbacks to fire held outside(!) the autolock on the stack(!)
55  std::list<CNodeCallback*> CallbacksToFire;
56  {
58  typename Base::EntryMethodFinalizer E( this, meSetValue );
59 
60  if( Verify && !IsWritable( this ) )
61  throw ACCESS_EXCEPTION_NODE("Node is not writable.");
62 #pragma BullseyeCoverage off
63  GCLOGINFOPUSH( Base::m_pValueLog, "SetValue( " + (Value ? GENICAM_NAMESPACE::gcstring("true") : GENICAM_NAMESPACE::gcstring("false")) + " )..." );
64 #pragma BullseyeCoverage on
65  {
66  typename Base::PostSetValueFinalizer PostSetValueCaller(this, CallbacksToFire); // dtor calls Base::PostSetValue
67 
68  Base::PreSetValue(); // invalidates all nodes if this is the first call in a chain of SetValue calls
69 
70  Base::InternalSetValue( Value, Verify );
71 
72  if( Verify )
73  Base::InternalCheckError();
74 
75  }
76 
77 #pragma BullseyeCoverage off
78  GCLOGINFOPOP( Base::m_pValueLog, "...SetValue" );
79 #pragma BullseyeCoverage on
80 
81  // fire callbacks inside the lock
82  std::list<CNodeCallback*>::iterator ptrCallback;
83  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
84  {
85  (*ptrCallback)->operator ()(cbPostInsideLock);
86  }
87  }
88 
89  // fire callbacks outside the lock
90  std::list<CNodeCallback*>::iterator ptrCallback;
91  for( ptrCallback = CallbacksToFire.begin(); ptrCallback != CallbacksToFire.end(); ptrCallback++ )
92  {
93  (*ptrCallback)->operator ()(cbPostOutsideLock);
94  }
95  }
96 
98  virtual void operator=(bool Value)
99  {
100  SetValue( Value );
101  }
102 
104  virtual bool GetValue(bool Verify = false, bool IgnoreCache = false) const
105  {
106  AutoLock l(Base::GetLock());
107  typename Base::EntryMethodFinalizer E( this, meGetValue, IgnoreCache );
108 
109  GCLOGINFOPUSH( Base::m_pValueLog, "GetValue..." );
110 
111  // Note that readability is tested regardless of Verify
112  if( !IsReadable( this ) )
113  throw ACCESS_EXCEPTION_NODE("Node is not readable.");
114 
115  const bool Value( Base::InternalGetValue(Verify, IgnoreCache) );
116 
117  if( Verify )
118  Base::InternalCheckError();
119 
120  GCLOGINFOPOP( Base::m_pValueLog, "...GetValue = " + (Value ? GENICAM_NAMESPACE::gcstring("true") : GENICAM_NAMESPACE::gcstring("false") ) );
121 
122  return Value;
123 
124  }
125 
127  virtual bool operator()() const
128  {
129  return GetValue();
130  }
131  //}
132 
133  };
134 }
135 
136 #endif // ifndef GENAPI_BOOLEANT_H
virtual void SetValue(bool Value, bool Verify=true)
IBoolean::SetValue()
Definition: BooleanT.h:52
virtual bool GetValue(bool Verify=false, bool IgnoreCache=false) const
IBoolean::GetValue()
Definition: BooleanT.h:104
bool IsReadable(EAccessMode AccessMode)
Tests if readable.
Definition: INode.h:178
#define ACCESS_EXCEPTION_NODE
Fires a access error exception, e.g. throw ACCESS_ERROR_EXCEPTION("Not everybody") ...
Definition: Exception.h:172
interface GENAPI_DECL_ABSTRACT bool Verify
Definition: IBoolean.h:61
#define GCLOGINFOPUSH(cat,...)
Definition: CLog.h:163
Implementation of the IBoolean interface.
Definition: BooleanT.h:45
A string class which is a clone of std::string.
Definition: GCString.h:52
virtual bool operator()() const
IBoolean::operator()()
Definition: BooleanT.h:127
bool IsWritable(EAccessMode AccessMode)
Tests if writable.
Definition: INode.h:196
#define GCLOGINFOPOP(cat,...)
Definition: CLog.h:164
virtual void operator=(bool Value)
IBoolean::operator=()
Definition: BooleanT.h:98
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:53