Node.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //  (c) 2006-2009 by Basler Vision Technologies
00003 //  Section: Vision Components
00004 //  Project: GenApi
00005 //  Author:  Fritz Dierks
00006 //  $Header$
00007 //
00008 //  License: This file is published under the license of the EMVA GenICam  Standard Group.
00009 //  A text file describing the legal terms is included in  your installation as 'GenICam_license.pdf'.
00010 //  If for some reason you are missing  this file please contact the EMVA or visit the website
00011 //  (http://www.genicam.org) for a full copy.
00012 //
00013 //  THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS"
00014 //  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00015 //  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00016 //  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD  GROUP
00017 //  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,  SPECIAL,
00018 //  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  LIMITED TO,
00019 //  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,  DATA, OR PROFITS;
00020 //  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY  THEORY OF LIABILITY,
00021 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT  (INCLUDING NEGLIGENCE OR OTHERWISE)
00022 //  ARISING IN ANY WAY OUT OF THE USE  OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00023 //  POSSIBILITY OF SUCH DAMAGE.
00024 //-----------------------------------------------------------------------------
00030 #ifndef GENAPI_NODE_H
00031 #define GENAPI_NODE_H
00032 
00033 #include <string>
00034 #include <sstream>
00035 #include <algorithm>
00036 #include <cctype>
00037 #include "Base/GCException.h"
00038 #include "../GenApiDll.h"
00039 #include "../Synch.h"
00040 #include "../Types.h"
00041 #include "../INode.h"
00042 #include "../ICategory.h"
00043 #include "INodePrivate.h"
00044 #include "INodeMapPrivate.h"
00045 #include "../IInteger.h"
00046 #include "../IBoolean.h"
00047 #include "../ISelector.h"
00048 #include "../NodeCallback.h"
00049 #include "../EnumClasses.h"
00050 #include "Log.h"
00051 #include "Value2String.h"
00052 #include "PolyReference.h"
00053 #include "NodeMapData/NodeMapDataTypes.h"
00054 #include "NodeMapData/NodeData.h"
00055 #include "NodeMap.h"
00056 #include "../IUserData.h"
00057 #include <list>
00058 
00059 class CProperty;
00060 class CNodeDataMap;
00061 
00062 namespace GENAPI_NAMESPACE
00063 {
00064     namespace detail
00065     {
00067         template< typename C, typename V>
00068         void push_back_unique(C &c, const V &v)
00069         {
00070             if (std::find(c.begin(), c.end(), v) == c.end())
00071             {
00072                 c.push_back(v);
00073             }
00074         }
00075     }
00076 
00077     //*************************************************************
00078     // CNodeImpl class
00079     //*************************************************************
00080 
00085     class CNodeImpl : public INodePrivate, public ISelector, public IUserData
00086     {
00087     public:
00088         //-------------------------------------------------------------
00090 
00091 
00092             CNodeImpl();
00093 
00095             virtual ~CNodeImpl();
00097 
00098     protected:
00099         //-------------------------------------------------------------
00101 
00102 
00103             virtual EAccessMode InternalGetAccessMode() const;
00104 
00106             #pragma BullseyeCoverage off
00107             virtual EInterfaceType InternalGetPrincipalInterfaceType() const
00108             {
00109                 return intfIBase;
00110             }
00111             #pragma BullseyeCoverage on
00112 
00114             EAccessMode InternalGetAccessMode(IBase* pValue) const;
00116 
00117     protected:
00118         //-------------------------------------------------------------
00120 
00121 
00122             virtual GENICAM_NAMESPACE::gcstring InternalGetName(bool FullQualified=false) const;
00123 
00125             virtual GENAPI_NAMESPACE::ENameSpace InternalGetNameSpace()const;
00126 
00128             virtual EVisibility InternalGetVisibility() const;
00129 
00130             // Invalidate the node
00131             virtual void InternalInvalidateNode( std::list<CNodeCallback*> &CallbacksToFire );
00132 
00134             virtual bool InternalIsCachable() const;
00135 
00137             virtual ECachingMode InternalGetCachingMode() const;
00138 
00140             virtual int64_t InternalGetPollingTime() const;
00141 
00143             virtual GENICAM_NAMESPACE::gcstring InternalGetToolTip() const;
00144 
00146             virtual GENICAM_NAMESPACE::gcstring InternalGetDescription() const;
00147 
00148             // Get node display name
00149             virtual GENICAM_NAMESPACE::gcstring InternalGetDisplayName() const;
00150 
00152             virtual GENICAM_NAMESPACE::gcstring InternalGetDeviceName() const;
00153 
00155             virtual void InternalGetChildren(GENAPI_NAMESPACE::NodeList_t &Children, ELinkType LinkType) const;
00156 
00158 
00159             virtual CallbackHandleType InternalRegisterCallback( CNodeCallback *pCallback );
00160 
00162 
00165             virtual bool InternalDeregisterCallback( CallbackHandleType hCallback );
00166 
00168             virtual INodeMap* InternalGetNodeMap() const;
00169 
00171             virtual GENICAM_NAMESPACE::gcstring GetEventID() const;
00172 
00174             virtual bool IsStreamable() const;
00175 
00176             virtual void GetParents(GENAPI_NAMESPACE::NodeList_t &Parents) const;
00177 
00179             virtual void GetPropertyNames(GENICAM_NAMESPACE::gcstring_vector &PropertyNames) const;
00180 
00182 
00183             virtual bool GetProperty(const GENICAM_NAMESPACE::gcstring& PropertyName, GENICAM_NAMESPACE::gcstring& ValueStr, GENICAM_NAMESPACE::gcstring& AttributeStr) const;
00184 
00186             virtual void ImposeAccessMode(EAccessMode ImposedAccessMode);
00187 
00189             virtual void ImposeVisibility(EVisibility ImposedVisibility);
00190 
00192             virtual INode* GetAlias() const;
00193 
00195             virtual INode* GetCastAlias() const;
00196 
00198             virtual void InternalCheckError() const;
00199 
00201             virtual GENICAM_NAMESPACE::gcstring InternalGetDocuURL() const;
00202 
00204             virtual bool InternalIsDeprecated() const;
00205 
00207             virtual bool IsFeature() const;
00208 
00210             virtual EYesNo InternalIsAccessModeCacheable() const;
00211 
00213 
00214             inline bool IsAccessModeCached() const
00215             {
00216                 if( _UndefinedAccesMode == m_AccessModeCache )
00217                     return false;
00218 #pragma BullseyeCoverage off
00219                 if( _CycleDetectAccesMode == m_AccessModeCache )
00220 #pragma BullseyeCoverage on
00221                 {
00222                     // the cycle is neutralized by making at least one node AccessMode cacheable
00223                     m_AccessModeCache = RW;
00224                     GCLOGWARN( m_pAccessLog,  "InternalGetAccessMode : ReadCycle detected at = '%s'", m_Name.c_str() );
00225                 }
00226                 return true;
00227             }
00229 
00230     public:
00231         //-------------------------------------------------------------
00233 
00234             virtual void Initialize(GENAPI_NAMESPACE::INodeMapPrivate* const pNodeMap, CNodeData::ENodeType_t NodeType, NodeID_t &NodeID );
00235             virtual CNodeData::ENodeType_t GetNodeType();
00236             virtual NodeID_t GetNodeID();
00237             virtual void FinalConstruct();
00238             virtual void SetProperty( CProperty &Property );
00239             virtual bool GetProperty(CNodeDataMap *pNodeDataMap, CPropertyID::EProperty_ID_t PropertyID, CNodeData::PropertyVector_t &PropertyList) const;
00240             virtual void SetInvalid(ESetInvalidMode simMode);           
00241             virtual void CollectCallbacksToFire(std::list<CNodeCallback*> &CallbacksToFire, bool allDependents = false);
00242             virtual bool IsTerminalNode() const;
00243             virtual void GetTerminalNodes( GENAPI_NAMESPACE::NodeList_t& Terminals ) const;
00244             virtual bool Poll( int64_t ElapsedTime );
00246 
00247     public:
00248         //-------------------------------------------------------------
00250 
00251             virtual bool IsSelector() const;
00252             virtual void GetSelectedFeatures( FeatureList_t& list ) const;
00253             virtual void GetSelectingFeatures( FeatureList_t& ) const;
00255 
00256     public:
00257 
00259         inline INodeMapPrivate* GetNodeMapPrivate()
00260         {
00261             return m_pNodeMap;
00262         }
00263 
00265         inline void SetParent( INodePrivate *pParent )
00266         {
00267             detail::push_back_unique(m_Parents, pParent);
00268         }
00269 
00270         // 1 : use macro for speed
00271         // 0 : used function for debugging
00272 #if 0
00273 
00274 #       define ADD_ORPHAN_CHILD( PropertyID, Property ) \
00275         INodePrivate *pNode = dynamic_cast<CNodeMap*>(m_pNodeMap)->_GetNodeByID( Property.NodeID() ); \
00276         if( CPropertyID::IsInvalidatingPointer(PropertyID) )\
00277         { \
00278             detail::push_back_unique(m_InvalidatingChildren, pNode); \
00279             if( CPropertyID::IsReadingPointer(PropertyID) ) \
00280             { \
00281                 detail::push_back_unique(m_ReadingChildren, pNode); \
00282                 if( CPropertyID::IsWritingPointer(PropertyID) ) \
00283                 { \
00284                     detail::push_back_unique(m_WritingChildren, pNode); \
00285                 } \
00286              } \
00287          }
00288 
00289         // the compiler will optimize the if() statements away if PropertyID is a constant
00290 #       define ADD_CHILD( PropertyID, Property ) \
00291         INodePrivate *pNode = dynamic_cast<CNodeMap*>(m_pNodeMap)->_GetNodeByID( Property.NodeID() ); \
00292         if( CPropertyID::IsInvalidatingPointer(PropertyID) )\
00293         { \
00294             detail::push_back_unique(m_InvalidatingChildren, pNode);\
00295             dynamic_cast<CNodeImpl*>(pNode)->SetParent( this );\
00296             if( CPropertyID::IsReadingPointer(PropertyID) ) \
00297             { \
00298                 detail::push_back_unique(m_ReadingChildren, pNode);\
00299                 if( CPropertyID::IsWritingPointer(PropertyID) ) \
00300                 { \
00301                     detail::push_back_unique(m_WritingChildren, pNode); \
00302                 } \
00303             } \
00304         }
00305 
00306 #else
00307 #       define ADD_ORPHAN_CHILD( PropertyID, Property ) \
00308         INodePrivate *pNode = dynamic_cast<CNodeMap*>(m_pNodeMap)->_GetNodeByID(Property.NodeID()); \
00309         add_orphan_child( PropertyID, Property, pNode );
00310 
00311 #       define ADD_CHILD( PropertyID, Property ) \
00312         INodePrivate *pNode = dynamic_cast<CNodeMap*>(m_pNodeMap)->_GetNodeByID(Property.NodeID()); \
00313         add_child( PropertyID, Property, pNode );
00314 
00315     // This is a helper function performing the same tasks as the macro above 
00316     // In contrast to the macro however you can set breakpoint here :-)
00317     void add_child(CPropertyID::EProperty_ID_t PropertyID, CProperty &/*Property*/, INodePrivate *pNode)
00318     {
00319         if (CPropertyID::IsInvalidatingPointer(PropertyID))
00320         {
00321             detail::push_back_unique(m_InvalidatingChildren, pNode);
00322             dynamic_cast<CNodeImpl*>(pNode)->SetParent(this);  // this is not present in add_orphan_child
00323             if (CPropertyID::IsReadingPointer(PropertyID))
00324             {
00325                 detail::push_back_unique(m_ReadingChildren, pNode);
00326                 if (CPropertyID::IsWritingPointer(PropertyID))
00327                 {
00328                     detail::push_back_unique(m_WritingChildren, pNode);
00329                 }
00330             }
00331         }
00332     }
00333 
00334     void add_orphan_child(CPropertyID::EProperty_ID_t PropertyID, CProperty &/*Property*/, INodePrivate *pNode)
00335     {
00336         if (CPropertyID::IsInvalidatingPointer(PropertyID))
00337         {
00338             detail::push_back_unique(m_InvalidatingChildren, pNode);
00339             if (CPropertyID::IsReadingPointer(PropertyID))
00340             {
00341                 detail::push_back_unique(m_ReadingChildren, pNode);
00342                 if (CPropertyID::IsWritingPointer(PropertyID))
00343                 {
00344                     detail::push_back_unique(m_WritingChildren, pNode);
00345                 }
00346             }
00347         }
00348     }
00349 #endif
00350     private:
00351         //-------------------------------------------------------------
00352         // ! \name Interface IUserData
00354             UserData_t GetUserData() const;
00355             UserData_t SetUserData( UserData_t userdata );
00357     protected:
00358         //-------------------------------------------------------------
00360 
00361             GENICAM_NAMESPACE::gcstring GetNodeType() const {
00362                        std::string nodetype;
00363                        Value2String(m_NodeTypeEnum, nodetype);
00364                        
00365                        return nodetype.c_str();
00366             }
00367 
00369             GENICAM_NAMESPACE::gcstring m_Name;
00370 
00372             GENICAM_NAMESPACE::gcstring m_Extension;
00373 
00375             ENameSpace m_NameSpace;
00376 
00378             GENICAM_NAMESPACE::gcstring m_DeviceName;
00379 
00381             GENICAM_NAMESPACE::gcstring m_DisplayName;
00382 
00384             GENICAM_NAMESPACE::gcstring m_ToolTip;
00385 
00387             GENICAM_NAMESPACE::gcstring m_Description;
00388 
00390             EVisibility m_Visibility;
00391 
00393             CBooleanPolyRef m_IsImplemented;
00394 
00396             CBooleanPolyRef m_IsAvailable;
00397 
00399             CBooleanPolyRef m_IsLocked;
00400 
00402             CBooleanPolyRef m_BlockPolling;
00403 
00405             IEnumeration *m_pError;
00406 
00408             INode *m_pAlias;
00409 
00411             INode *m_pCastAlias;
00412 
00414             mutable ECachingMode m_CachingMode;
00415 
00417             FeatureList_t m_Selected;
00418 
00420             FeatureList_t m_Selecting;
00421 
00423             GENICAM_NAMESPACE::gcstring m_EventID;
00424 
00426             EYesNo m_IsStreamable;
00427 
00429             EAccessMode m_ImposedAccessMode;
00430 
00432             EVisibility m_ImposedVisibility;
00433 
00435             int64_t m_PollingTime;
00436 
00438             enum ETerminalPropagationState
00439             {
00440                 eNotVisited, 
00441                 eBeingVisited, 
00442                 eTerminalPropagationDone 
00443             };
00444 
00446             ETerminalPropagationState m_propagationState;
00447 
00449             NodeList_t m_Invalidators;
00450 
00452             GENICAM_NAMESPACE::gcstring m_DocuURL;
00453 
00455             EYesNo m_IsDeprecated;
00456 
00458             GENICAM_NAMESPACE::gcstring_vector m_PropertyNames;
00459 
00461             EYesNo m_IsFeature;
00462 
00464 
00465     protected:
00466         //-------------------------------------------------------------
00468 
00469 
00470             NodePrivateVector_t m_Parents;
00471 
00474             NodePrivateVector_t m_ReadingChildren;
00475 
00478             NodePrivateVector_t m_WritingChildren;
00479 
00482             NodePrivateVector_t m_InvalidatingChildren;
00483 
00486             NodePrivateVector_t m_AllDependingNodes;
00487 
00490             NodePrivateVector_t m_AllTerminalNodes;
00492 
00493     protected:
00494         //-------------------------------------------------------------
00496 
00497 
00498             mutable ECachingMode m_CachingModeCache;
00499 
00501             mutable EAccessMode m_AccessModeCache;
00502 
00503             inline void CacheAccessModeIfPossible( EAccessMode AccessMode ) const
00504             {
00505                 m_AccessModeCache = ( Yes == InternalIsAccessModeCacheable() ) ? AccessMode : _UndefinedAccesMode;
00506             }
00507 
00509             mutable bool m_ValueCacheValid;
00510 
00512             mutable bool m_ListOfValidValuesCacheValid;
00513 
00515             virtual bool InternalIsValueCacheValid() const;
00516 
00518             mutable EYesNo m_AccessModeCacheability;
00519 
00521 
00522     protected:
00523         //-------------------------------------------------------------
00525 
00526 
00527             INodeMapPrivate* m_pNodeMap;
00528 
00530             int64_t m_ElapsedTime;
00531 
00533             typedef AutoLock Lock;
00534 
00536             CLock& GetLock() const;
00537 
00539             Counter& GetBathometer() const;
00540 
00542             void PreSetValue();
00543 
00545             void PostSetValue( std::list<CNodeCallback*> &CallbacksToFire );
00546 
00548             bool m_DontDeleteThisCache;
00549 
00551             class PostSetValueFinalizer
00552             {
00553             public:
00555                 PostSetValueFinalizer(CNodeImpl* pThis,  std::list<CNodeCallback*> &CallbacksToFire ) :
00556                     m_pThis( pThis ),
00557                     m_CallbacksToFire( CallbacksToFire )
00558                 {}
00559 
00561                 ~PostSetValueFinalizer()
00562                 {
00563                     m_pThis->PostSetValue( m_CallbacksToFire );
00564                 }
00565 
00567                 CNodeImpl* m_pThis;
00568 
00570                 std::list<CNodeCallback*> &m_CallbacksToFire;
00571 
00572             private:
00574                 // \{
00575                 PostSetValueFinalizer(const PostSetValueFinalizer&);
00576                 PostSetValueFinalizer& operator=(const PostSetValueFinalizer&);
00577                 // \}
00578             };
00579 
00581             std::list<CNodeCallback*> m_Callbacks;
00582 
00584             class EntryMethodFinalizer
00585             {
00586             public:
00588                 EntryMethodFinalizer(const INodePrivate* pThis, EMethod EntryMethod, bool IgnoreCache = false ) 
00589                 {
00590                     assert(pThis);
00591                     m_pNodeMapPrivate = dynamic_cast<INodeMapPrivate*>( pThis->GetNodeMap() );
00592                     m_pNodeMapPrivate->SetEntryPoint( EntryMethod, pThis, IgnoreCache );
00593                 }
00594 
00596                 ~EntryMethodFinalizer()
00597                 {
00598                     m_pNodeMapPrivate->ResetEntryPoint();
00599                 }
00600 
00601             private:
00603                 INodeMapPrivate *m_pNodeMapPrivate;
00604             };
00605 
00607             GENICAM_NAMESPACE::gcstring GetQualifiedName(GENICAM_NAMESPACE::gcstring Name, ENameSpace NameSpace) const;
00608 
00610 
00611         //-------------------------------------------------------------
00613 
00614             // for safety reasons please keep these member variables at the
00615             // end of the class' memory layout
00616 
00618             LOG4CPP_NS::Category *m_pAccessLog;
00619 
00621             LOG4CPP_NS::Category *m_pValueLog;
00622 
00624             LOG4CPP_NS::Category *m_pRangeLog;
00625 
00627             LOG4CPP_NS::Category *m_pPortLog;
00628 
00630             LOG4CPP_NS::Category *m_pCacheLog;
00631 
00633             LOG4CPP_NS::Category *m_pPreProcLog;
00634 
00636             LOG4CPP_NS::Category *m_pMiscLog;
00637 
00639 
00640 
00642         NodeID_t m_NodeID;
00643 
00644         CNodeData::ENodeType_t m_NodeTypeEnum;
00645 
00646         EYesNo m_ExposeStatic;
00647         
00650         UserData_t m_pUserData;
00651 
00652     private:
00653 #if defined( _WIN32 ) && !defined( PHARLAP_WIN32 )
00654         typedef std::wstring string_t;
00655         typedef std::wstring::size_type size_type;
00656         typedef std::wostringstream ostringstream_t;
00657         typedef wchar_t char_t;
00658         #define QUALIFY_LITERAL( x ) _L( x )
00659         #define _L( x ) L ## x
00660         #define GET_MODULE_FILE_NAME GetModuleFileNameW
00661         #define GET_CSTR( x ) x.w_str().c_str()
00662         #define GET_LOCALE_INFO GetLocaleInfoW
00663 #else
00664         typedef std::string string_t;
00665         typedef std::string::size_type size_type;
00666         typedef std::ostringstream ostringstream_t;
00667         typedef char char_t;
00668         #define QUALIFY_LITERAL( x ) x
00669         #define GET_MODULE_FILE_NAME GetModuleFileName
00670         #define GET_CSTR( x ) x.c_str()
00671         #define GET_LOCALE_INFO GetLocaleInfo
00672 #endif
00673 
00674         static const size_t MaxPath;
00675         void GetNodeName( string_t& VariableContent ) const;
00676         void GetStringStreamContent( const ostringstream_t& Content, string_t& VariableContent ) const;
00677         void GetVendorName( string_t& VariableContent ) const;
00678         void GetModelName( string_t& VariableContent ) const;
00679         void GetStandardNameSpace( string_t& VariableContent ) const;
00680         void GetNodeValue( const CValuePtr& ptrValue, CNodeImpl::string_t& VariableContent ) const;
00681 
00682     };
00683 
00685     bool DeleteDoubleCallbacksCompare (GENAPI_NAMESPACE::CNodeCallback* pA, GENAPI_NAMESPACE::CNodeCallback* pB);
00686 
00688     void DeleteDoubleCallbacks( std::list<CNodeCallback*> &CallbackList );
00689 
00690 }
00691 
00692 #endif // ifndef GENAPI_NODE_H


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05