00001 // Dear emacs, this is -*- c++ -*- 00002 // $Id: SystematicCode.h 717600 2016-01-13 17:48:13Z krumnack $ 00003 #ifndef PATINTERFACES_SYSTEMATICCODE_H 00004 #define PATINTERFACES_SYSTEMATICCODE_H 00005 00006 // Copyright Nils Krumnack 2012. 00007 // Distributed under the Boost Software License, Version 1.0. 00008 // (See accompanying file LICENSE_1_0.txt or copy at 00009 // http://www.boost.org/LICENSE_1_0.txt) 00010 00011 // Please feel free to contact me (krumnack@iastate.edu) for bug 00012 // reports, feature suggestions, praise and complaints. 00013 00014 namespace CP { 00015 00037 class SystematicCode { 00038 00039 public: 00041 enum ESysCode { 00042 Unsupported = 0, 00043 Ok = 1 00044 }; 00045 00047 SystematicCode( ESysCode code ); 00049 SystematicCode( const SystematicCode& parent ); 00051 ~SystematicCode(); 00052 00054 SystematicCode& operator= ( const SystematicCode& rhs ); 00055 00057 ESysCode code() const; 00058 00060 operator ESysCode() const { return code(); } 00061 00064 bool operator < ( const SystematicCode& rhs ) const { 00065 return m_code < rhs.m_code; 00066 } 00067 00069 void setChecked() const { m_checked = true; } 00071 void ignore() const { setChecked(); } 00072 00074 static void enableFailure(); 00076 static void disableFailure(); 00077 00078 private: 00079 ESysCode m_code; 00080 mutable bool m_checked; 00081 00082 }; // class SystematicCode 00083 00084 } // namespace CP 00085 00086 namespace asg 00087 { 00088 template<typename T> struct CheckHelper; 00089 00090 template<> struct CheckHelper<CP::SystematicCode> 00091 { 00093 static inline bool isSuccess (const CP::SystematicCode& sc) { 00094 return sc == CP::SystematicCode::Ok; } 00095 00097 static inline CP::SystematicCode successCode () { 00098 return CP::SystematicCode::Ok;} 00099 00101 static inline CP::SystematicCode failureCode () { 00102 return CP::SystematicCode::Unsupported;} 00103 }; 00104 } 00105 00106 #endif // PATINTERFACES_SYSTEMATICCODE_H