| 1 |
/* treeWriter.h |
| 2 |
*/ |
| 3 |
#ifndef _CHECK_TREEWRITER_H |
| 4 |
#define _CHECK_TREEWRITER_H |
| 5 |
|
| 6 |
#include "osl/move.h" |
| 7 |
#include <boost/scoped_ptr.hpp> |
| 8 |
#include <string> |
| 9 |
#include <iosfwd> |
| 10 |
|
| 11 |
namespace osl |
| 12 |
{ |
| 13 |
namespace container |
| 14 |
{ |
| 15 |
class MoveVector; |
| 16 |
} |
| 17 |
namespace checkmate |
| 18 |
{ |
| 19 |
class CheckHashRecord; |
| 20 |
class CheckMove; |
| 21 |
using container::MoveVector; |
| 22 |
|
| 23 |
namespace analyzer |
| 24 |
{ |
| 25 |
class RecordSet; |
| 26 |
/** |
| 27 |
* CheckTableAnalyzer で探索木を出力 |
| 28 |
*/ |
| 29 |
class TreeWriter |
| 30 |
{ |
| 31 |
int depth; |
| 32 |
public: |
| 33 |
TreeWriter(); |
| 34 |
virtual ~TreeWriter(); |
| 35 |
void incDepth() { ++depth; } |
| 36 |
void decDepth() { --depth; } |
| 37 |
virtual const std::string header() const { return ""; } |
| 38 |
int getDepth() const { return depth; } |
| 39 |
virtual void showRecord(const CheckHashRecord */*record*/) {} |
| 40 |
/** |
| 41 |
* move をたどる前に呼ばれる |
| 42 |
*/ |
| 43 |
virtual void showMove(const CheckHashRecord */*from*/, |
| 44 |
const CheckMove& /*move*/) {} |
| 45 |
/** |
| 46 |
* move から帰った時に呼ばれる |
| 47 |
*/ |
| 48 |
virtual void showMoveAfter(const CheckHashRecord * /*from*/, |
| 49 |
const CheckMove& /*move*/) {} |
| 50 |
virtual void showMoves(const MoveVector& /*moves*/) {} |
| 51 |
virtual void writeln(const char * /*msg*/) {} |
| 52 |
}; |
| 53 |
|
| 54 |
/** |
| 55 |
* dot (www.graphviz.org) 用. |
| 56 |
* log の出力にはむかないと思われる. |
| 57 |
*/ |
| 58 |
class DotWriter : public TreeWriter |
| 59 |
{ |
| 60 |
std::ostream& os; |
| 61 |
std::unique_ptr<RecordSet> visited; |
| 62 |
/** |
| 63 |
* 小さい証明数/反証数のノードを無視 |
| 64 |
*/ |
| 65 |
size_t minimumPdp; |
| 66 |
public: |
| 67 |
explicit DotWriter(std::ostream&, size_t min=0, const char *graphname=0); |
| 68 |
~DotWriter(); |
| 69 |
const std::string header() const; |
| 70 |
void showRecord(const CheckHashRecord *record); |
| 71 |
void showMove(const CheckHashRecord *from, const CheckMove& move); |
| 72 |
void showMoves(const MoveVector& moves); |
| 73 |
void writeln(const char *msg); |
| 74 |
}; |
| 75 |
|
| 76 |
|
| 77 |
/** |
| 78 |
* Emacs の outline-mode 用 |
| 79 |
*/ |
| 80 |
class OutlineWriter : public TreeWriter |
| 81 |
{ |
| 82 |
public: |
| 83 |
OutlineWriter(); |
| 84 |
virtual ~OutlineWriter(); |
| 85 |
const std::string header() const; |
| 86 |
}; |
| 87 |
|
| 88 |
class TreeStreamWriter : public OutlineWriter |
| 89 |
{ |
| 90 |
protected: |
| 91 |
std::ostream *os; |
| 92 |
bool simpleMove; |
| 93 |
public: |
| 94 |
explicit TreeStreamWriter(std::ostream *, bool simpleMove); |
| 95 |
~TreeStreamWriter(); |
| 96 |
void showRecord(const CheckHashRecord *record); |
| 97 |
void showMove(const CheckMove& m); |
| 98 |
void showMove(const CheckHashRecord *from, const CheckMove& move); |
| 99 |
void showMoves(const MoveVector& moves); |
| 100 |
void writeln(const char *msg); |
| 101 |
}; |
| 102 |
|
| 103 |
} // namespace analyzer |
| 104 |
} // namespace checkmate |
| 105 |
} // namespace osl |
| 106 |
|
| 107 |
|
| 108 |
#endif /* _CHECK_TREEWRITER_H */ |
| 109 |
// ;;; Local Variables: |
| 110 |
// ;;; mode:c++ |
| 111 |
// ;;; c-basic-offset:2 |
| 112 |
// ;;; End: |