degate  0.1.2
RCViolation.h
Go to the documentation of this file.
00001 /* -*-c++-*-
00002 
00003   This file is part of the IC reverse engineering tool degate.
00004 
00005   Copyright 2008, 2009, 2010 by Martin Schobert
00006 
00007   Degate is free software: you can redistribute it and/or modify
00008   it under the terms of the GNU General Public License as published by
00009   the Free Software Foundation, either version 3 of the License, or
00010   any later version.
00011 
00012   Degate is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015   GNU General Public License for more details.
00016 
00017   You should have received a copy of the GNU General Public License
00018   along with degate. If not, see <http://www.gnu.org/licenses/>.
00019 
00020 */
00021 
00022 #ifndef __RCVIOLATION_H__
00023 #define __RCVIOLATION_H__
00024 
00025 #include <boost/foreach.hpp>
00026 #include <memory>
00027 #include <list>
00028 #include <LogicModel.h>
00029 #include <RCBase.h>
00030 
00031 namespace degate {
00032 
00033   class RCViolation {
00034   private:
00035 
00036     PlacedLogicModelObject_shptr _obj;
00037     std::string _problem_description;
00038     std::string _rc_violation_class;
00039     RC_SEVERITY _severity;
00040 
00041   public:
00042 
00043     /** Create a new Rule Check violation.
00044      * @param obj The object, which is affected from the violation.
00045      * @param problem_description A string, which contains a description
00046      *   of the violated contraint.
00047      * @param rc_violation_class This is a unique technical name for
00048      *   a rc violation, that indicates the problem class.
00049      * @param severity Indicates the type of problem, actually
00050      *   if a rc violation is just a warning or a real error.
00051      */
00052      
00053     RCViolation(PlacedLogicModelObject_shptr obj,
00054                 std::string const& problem_description,
00055                 std::string const& rc_violation_class,
00056                 RC_SEVERITY severity = RC_ERROR) :
00057       _obj(obj),
00058       _problem_description(problem_description),
00059       _rc_violation_class(rc_violation_class),
00060       _severity(severity) {
00061     }
00062 
00063     std::string get_problem_description() const {
00064       return _problem_description;
00065     }
00066 
00067     std::string get_rc_violation_class() const {
00068       return _rc_violation_class;
00069     }
00070 
00071     RC_SEVERITY get_severity() const {
00072       return _severity;
00073     }
00074 
00075     std::string get_severity_as_string() const {
00076       switch(_severity) {
00077       case RC_ERROR: return "error"; break;
00078       case RC_WARNING: return "warning"; break;      
00079       case RC_UNDEFINED: 
00080       default: return "undefined"; break;
00081       }
00082     }
00083 
00084     static RC_SEVERITY get_severity_from_string(std::string const & str) {
00085       if(str == "error") return RC_ERROR;
00086       else if(str == "warning") return RC_WARNING;
00087       return RC_UNDEFINED;
00088     }
00089 
00090     bool matches_filter(std::string const& filter_pattern) const {
00091       return filter_pattern.empty() ||
00092         get_rc_violation_class().find(filter_pattern) != std::string::npos ||
00093         get_severity_as_string().find(filter_pattern) != std::string::npos ||
00094         get_problem_description().find(filter_pattern) != std::string::npos;
00095     }
00096 
00097     PlacedLogicModelObject_shptr get_object() const {
00098       return _obj;
00099     }
00100 
00101     /**
00102      * Check if two rc violations are conceptually equal.
00103      */
00104     bool equals(RCViolation_shptr rcv) const {
00105       return 
00106         _obj == rcv->_obj &&
00107         _problem_description == rcv->_problem_description &&
00108         _rc_violation_class == rcv->_rc_violation_class &&
00109         _severity == rcv->_severity;
00110     }
00111 
00112 
00113   };
00114 
00115 }
00116 
00117 #endif