00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef ANASAZI_STATUS_TEST_OUTPUT_HPP
00031 #define ANASAZI_STATUS_TEST_OUTPUT_HPP
00032
00039 #include "AnasaziConfigDefs.hpp"
00040 #include "AnasaziTypes.hpp"
00041 #include "AnasaziEigensolver.hpp"
00042
00043 #include "AnasaziStatusTest.hpp"
00044
00045
00046
00047 namespace Anasazi {
00048
00058 template <class ScalarType, class MV, class OP>
00059 class StatusTestOutput : public StatusTest<ScalarType,MV,OP> {
00060
00061 public:
00063
00064
00079 StatusTestOutput(const Teuchos::RefCountPtr<OutputManager<ScalarType> > &printer,
00080 Teuchos::RefCountPtr<StatusTest<ScalarType,MV,OP> > test,
00081 int mod = 1,
00082 int printStates = Passed)
00083 : printer_(printer), test_(test), state_(Undefined), stateTest_(printStates), modTest_(mod), numCalls_(0) {}
00084
00086 virtual ~StatusTestOutput() {};
00088
00090
00091
00108 TestStatus checkStatus( Eigensolver<ScalarType,MV,OP>* solver ) {
00109 TEST_FOR_EXCEPTION(test_ == Teuchos::null,StatusTestError,"StatusTestOutput::checkStatus(): child pointer is null.");
00110 state_ = test_->checkStatus(solver);
00111
00112 if (numCalls_++ % modTest_ == 0) {
00113 if ( (state_ & stateTest_) == state_) {
00114 if ( printer_->isVerbosity(StatusTestDetails) ) {
00115 print( printer_->stream(StatusTestDetails) );
00116 }
00117 else if ( printer_->isVerbosity(Debug) ) {
00118 print( printer_->stream(Debug) );
00119 }
00120 }
00121 }
00122
00123 return state_;
00124 }
00125
00127 TestStatus getStatus() const {
00128 return state_;
00129 }
00131
00132
00134
00135
00140 void setChild(Teuchos::RefCountPtr<StatusTest<ScalarType,MV,OP> > test) {
00141 test_ = test;
00142 state_ = Undefined;
00143 }
00144
00146 Teuchos::RefCountPtr<StatusTest<ScalarType,MV,OP> > getChild() const {
00147 return test_;
00148 }
00149
00151
00152
00154
00155
00160 void reset() {
00161 state_ = Undefined;
00162 test_->reset();
00163 numCalls_ = 0;
00164 }
00165
00168 void clearStatus() {
00169 state_ = Undefined;
00170 test_->clearStatus();
00171 }
00172
00174
00176
00177
00179 ostream& print(ostream& os, int indent = 0) const {
00180 string ind(indent,' ');
00181 os << ind << "- StatusTestOutput: ";
00182 switch (state_) {
00183 case Passed:
00184 os << "Passed" << endl;
00185 break;
00186 case Failed:
00187 os << "Failed" << endl;
00188 break;
00189 case Undefined:
00190 os << "Undefined" << endl;
00191 break;
00192 }
00193 os << ind << " (Num calls,Mod test,State test): " << "(" << numCalls_ << ", " << modTest_ << ",";
00194 if (stateTest_ == 0) {
00195 os << " none )" << endl;
00196 }
00197 else {
00198 if ( stateTest_ & Passed == Passed ) os << " Passed";
00199 if ( stateTest_ & Failed == Failed ) os << " Failed";
00200 if ( stateTest_ & Undefined == Undefined ) os << " Undefined";
00201 os << " )" << endl;
00202 }
00203
00204 test_->print(os,indent+3);
00205 return os;
00206 }
00207
00209
00210 private:
00211 Teuchos::RefCountPtr<OutputManager<ScalarType> > printer_;
00212 Teuchos::RefCountPtr<StatusTest<ScalarType,MV,OP> > test_;
00213 TestStatus state_;
00214 int stateTest_;
00215 int modTest_;
00216 int numCalls_;
00217 };
00218
00219 }
00220
00221 #endif