| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef DUMPINTERFACE_H |
| 21 |
#define DUMPINTERFACE_H |
| 22 |
|
| 23 |
#include <ostream> |
| 24 |
|
| 25 |
#include "tNamedEntry.h" |
| 26 |
#include "dltree.h" |
| 27 |
|
| 28 |
class TConcept; |
| 29 |
class TRole; |
| 30 |
|
| 31 |
|
| 32 |
enum diOp |
| 33 |
{ |
| 34 |
diNot, |
| 35 |
diAnd, |
| 36 |
diOr, |
| 37 |
diExists, |
| 38 |
diForall, |
| 39 |
diGE, |
| 40 |
diLE, |
| 41 |
|
| 42 |
diInv, |
| 43 |
|
| 44 |
diOneOf, |
| 45 |
|
| 46 |
diErrorOp, |
| 47 |
|
| 48 |
diLastOp = diErrorOp |
| 49 |
}; |
| 50 |
|
| 51 |
|
| 52 |
enum diAx |
| 53 |
{ |
| 54 |
diErrorAx = diLastOp, |
| 55 |
|
| 56 |
diDefineC, |
| 57 |
diImpliesC, |
| 58 |
diEqualsC, |
| 59 |
diDisjointC, |
| 60 |
|
| 61 |
diDefineR, |
| 62 |
diTransitiveR, |
| 63 |
diFunctionalR, |
| 64 |
diImpliesR, |
| 65 |
diEqualsR, |
| 66 |
diDomainR, |
| 67 |
diRangeR, |
| 68 |
|
| 69 |
diInstanceOf, |
| 70 |
}; |
| 71 |
|
| 72 |
|
| 73 |
class dumpInterface |
| 74 |
{ |
| 75 |
protected: |
| 76 |
|
| 77 |
std::ostream& o; |
| 78 |
|
| 79 |
unsigned int indent = 0; |
| 80 |
|
| 81 |
bool oneliner = false; |
| 82 |
|
| 83 |
protected: |
| 84 |
|
| 85 |
void skipIndent ( void ); |
| 86 |
|
| 87 |
void incIndent ( void ); |
| 88 |
|
| 89 |
void decIndent ( void ); |
| 90 |
|
| 91 |
public: |
| 92 |
|
| 93 |
explicit dumpInterface ( std::ostream& oo ) : o(oo) {} |
| 94 |
|
| 95 |
virtual ~dumpInterface() = default; |
| 96 |
|
| 97 |
|
| 98 |
bool useIndentation ( bool val ) |
| 99 |
{ |
| 100 |
bool ret = oneliner; |
| 101 |
oneliner = val; |
| 102 |
return ret; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
virtual void prologue ( void ) {} |
| 107 |
virtual void epilogue ( void ) {} |
| 108 |
|
| 109 |
|
| 110 |
virtual void dumpTop ( void ) {} |
| 111 |
virtual void dumpBottom ( void ) {} |
| 112 |
virtual void dumpNumber ( unsigned int ) {} |
| 113 |
|
| 114 |
virtual void startOp ( diOp ) {} |
| 115 |
|
| 116 |
virtual void startOp ( diOp, unsigned int ) {} |
| 117 |
virtual void contOp ( diOp ) {} |
| 118 |
virtual void finishOp ( diOp ) {} |
| 119 |
|
| 120 |
virtual void startAx ( diAx ) {} |
| 121 |
virtual void contAx ( diAx ) {} |
| 122 |
virtual void finishAx ( diAx ) {} |
| 123 |
|
| 124 |
|
| 125 |
virtual void dumpName ( const TNamedEntry* p ) { o << p->getName(); } |
| 126 |
|
| 127 |
virtual void dumpConcept ( const TConcept* ) {} |
| 128 |
|
| 129 |
virtual void dumpRole ( const TRole* ) {} |
| 130 |
}; |
| 131 |
|
| 132 |
inline void dumpInterface :: skipIndent ( void ) |
| 133 |
{ |
| 134 |
if ( oneliner ) |
| 135 |
return; |
| 136 |
o << "\n"; |
| 137 |
for ( unsigned int i = indent; i > 0; --i ) |
| 138 |
o << " "; |
| 139 |
} |
| 140 |
|
| 141 |
inline void dumpInterface :: incIndent ( void ) |
| 142 |
{ |
| 143 |
skipIndent(); |
| 144 |
++indent; |
| 145 |
} |
| 146 |
|
| 147 |
inline void dumpInterface :: decIndent ( void ) |
| 148 |
{ |
| 149 |
--indent; |
| 150 |
skipIndent(); |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
void dumpCExpression ( dumpInterface* dump, const DLTree* C ); |
| 155 |
|
| 156 |
void dumpRExpression ( dumpInterface* dump, const DLTree* R ); |
| 157 |
|
| 158 |
#endif |