Generated on Wed Apr 29 2015 11:51:40 for GGL-4.1.2 by doxygen 1.8.3.1
MR_stream.hh
Go to the documentation of this file.
1 #ifndef SGM_MR_STREAM_HH_
2 #define SGM_MR_STREAM_HH_
3 
4 #include "sgm/Match_Reporter.hh"
5 
6 #include <iostream>
7 #include <iomanip>
8 
9 namespace sgm {
10 
11  /*! @brief Writes each match to an output stream
12  *
13  * A sgm::Match_Reporter implementation that writes the matched pairs of
14  * pattern and target graph nodes to stream.
15  *
16  * @author Martin Mann (c) 2008 http://www.bioinf.uni-freiburg.de/~mmann/
17  */
18  class MR_stream : public Match_Reporter {
19 
20  protected:
21 
22  //! the stream to write to
23  std::ostream & out;
24 
25  //! the number of matches reported so far
27 
28  public:
29 
30  //! Construction
31  MR_stream( std::ostream& out );
32 
33  virtual
34  ~MR_stream();
35 
36  //! Writes a match to stream.
37  //! @param pattern the pattern graph that was searched for
38  //! @param target the graph the pattern was found within
39  //! @param match contains the indices of the matched pattern nodes in
40  //! the target graph. match[i] corresponds to the mapping of the ith
41  //! vertex in the pattern graph.
42  virtual
43  void
44  reportHit ( const Pattern_Interface & pattern,
45  const Graph_Interface & target,
46  const Match & match );
47 
48  //! Resets the number of matches reported so far to 0.
49  void
50  resetHits ( void );
51 
52  };
53 
54 } // namespace sgm
55 
56  // IMPLEMENTATION OF MR_stream
57 
58 namespace sgm {
59 
60  inline
61  MR_stream
62  ::MR_stream( std::ostream& out_ )
63  : out(out_), numberOfMatches(0)
64  {}
65 
66  inline
67  MR_stream
69  {}
70 
71  inline
72  void
73  MR_stream
74  ::reportHit ( const Pattern_Interface & pattern,
75  const Graph_Interface & target,
76  const Match & match )
77  {
78  numberOfMatches++;
79 
80  out <<std::setw(6) <<numberOfMatches <<" :";
81  for (size_t i=0; i<match.size(); ++i) {
82  out <<" (" <<i <<"," <<match[i] <<")";
83  }
84  out <<std::endl;
85  }
86 
87  inline
88  void
89  MR_stream
90  ::resetHits ( void )
91  {
92  numberOfMatches = 0;
93  }
94 
95 }
96 
97 #endif /*MR_STREAM_HH_*/