00001
00008
00009
00010
00011
00012
00013 #if COMPILING_MODULE
00014 #ifndef MOD_BASE_VISITORS_HH
00015 #define MOD_BASE_VISITORS_HH 1
00016
00017 namespace mod_base {
00018
00024 class VisitorFindPartitionNode : public Visitor
00025 {
00026 public:
00027 VisitorFindPartitionNode( Graph& graph, const string& partitionName )
00028 : Visitor(graph),
00029 mPartitionName(partitionName),
00030 mPartitionNode(NULL_NODE)
00031 {
00032 }
00033
00034 void Visit( PartitionNode& partitionNode )
00035 {
00036
00037 if ( partitionNode.GetName() == mPartitionName )
00038 {
00039
00040 mPartitionNode = &partitionNode;
00041 Stop();
00042 }
00043 }
00044
00046 PartitionNode::Ptr GetPartitionNode( void )
00047 {
00048 return mPartitionNode;
00049 }
00050
00051 private:
00052 const string mPartitionName;
00053 PartitionNode::Ptr mPartitionNode;
00054 };
00055
00062 template<typename NODE>
00063 class VisitorFindNode : public Visitor
00064 {
00065 public:
00066 VisitorFindNode( Graph& graph, const string& partitionName )
00067 : Visitor(graph),
00068 mNode(NULL_NODE)
00069 {
00070
00071 VisitorFindPartitionNode visitorFindPartitionNode( graph, partitionName );
00072 graph.Traverse( visitorFindPartitionNode );
00073 const PartitionNode::Ptr partitionNode = visitorFindPartitionNode.GetPartitionNode();
00074
00075
00076 if ( partitionNode != NULL_NODE )
00077 {
00078
00079 SetRootNode( partitionNode );
00080 }
00081 else
00082 {
00083
00084 Stop();
00085 }
00086 }
00087
00088 void Visit( NODE& node )
00089 {
00090
00091 mNode = &node;
00092 Stop();
00093 }
00094
00096 typename NODE::Ptr GetNode( void )
00097 {
00098 return mNode;
00099 }
00100
00101 private:
00102 typename NODE::Ptr mNode;
00103 };
00104
00105 }
00106
00107 #endif // MOD_BASE_VISITORS_HH
00108 #endif // COMPILING_MODULE