VR-Forces 4.0.4 Class Documentation
include/vrvOsg/DtRegularExpressionVisitor.h
Go to the documentation of this file.
00001 /****************************************************************************** 
00002 ** Copyright (c) 2007 MAK Technologies, Inc. 
00003 ** All rights reserved. 
00004 ******************************************************************************/ 
00005 /****************************************************************************** 
00006 ** $RCSfile: DtRegularExpressionVisitor.h,v $ $Revision: 1.14 $ $State: Exp $ 
00007 ******************************************************************************/ 
00008  
00012  
00013 #ifndef DtRegularExpressionVisitor_H_ 
00014 #define DtRegularExpressionVisitor_H_ 
00015  
00016 #include <vrvOsg/vrvOsg.h> 
00017 #include <osg/NodeVisitor>
00018 #include <osg/Group>
00019 #include <osg/Switch>
00020 #include <boost/regex.hpp>
00021  
00022 namespace makVrv 
00023 { 
00027    class DT_DLL_VRVOSG DtRegularExpressionVisitor : public osg::NodeVisitor 
00028    { 
00029 
00030    public: 
00031 
00032       struct ExpressionNodeData
00033       {
00034          osg::ref_ptr<osg::Node> node;
00035          osg::Matrix localToWorldVector;
00036          std::string match; // what matched the regular expression
00037       };
00038 
00045       typedef std::vector< ExpressionNodeData > NodeVector;
00046 
00048       typedef std::vector<boost::regex> RegexVector;
00049 
00052       DtRegularExpressionVisitor(bool isRegEx = true); 
00053 
00056       DtRegularExpressionVisitor(const std::string& searchExpression, bool isRegEx = true);
00057 
00060       DtRegularExpressionVisitor(const std::vector<std::string>& searchExpressions,bool isRegEx = true);
00061 
00063       virtual ~DtRegularExpressionVisitor();
00064 
00066       void setSearchNames(bool flag);
00067 
00069       void setSearchDescriptions(bool flag);
00070 
00072       void setSearchFilenames(bool flag);
00073 
00078       virtual void apply(osg::ProxyNode& searchNode);
00079 
00082       virtual void apply(osg::Node& searchNode);
00083 
00085       virtual void setExpressionToFind(const std::string &searchExpression);
00086 
00089       virtual NodeVector& nodeVector();
00090 
00092       virtual void setCutTraversal(bool b);
00093 
00096       virtual void reset();
00097 
00098    protected:
00099 
00101       virtual bool regexSearchAndAdd(const std::string& target, osg::Node* node);
00102 
00104       virtual bool searchNames(osg::Node* node);
00105 
00107       virtual bool searchDescriptions(osg::Node* node);
00108 
00110       virtual bool searchFilenames(osg::ProxyNode* proxyNode);
00111 
00112    protected:
00113 
00114       std::vector<std::string> mySearchForStrings;
00115 
00116       std::string myOriginalCacheFileString;
00117       std::string myOriginalFileString;
00118 
00120       RegexVector mySearchForRegularExpressions;
00121 
00122       bool myExpressionIsRegEx;
00123 
00125       NodeVector myFoundNodeVector;
00126 
00128       bool cutTraversal;
00129 
00130       bool mySearchNames;
00131       bool mySearchDescriptions;
00132       bool mySearchFilenames;
00133    }; 
00134 
00135 } 
00136  
00137 #endif
00138 

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)