degate  0.1.2
RCBase.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 __RCBASE_H__
00023 #define __RCBASE_H__
00024 
00025 #include <boost/foreach.hpp>
00026 #include <memory>
00027 #include <list>
00028 #include <LogicModel.h>
00029 #include <RCVContainer.h>
00030 
00031 namespace degate {
00032 
00033   /**
00034    * An enum for several types of Rule Check problem types.
00035    */
00036   enum RC_SEVERITY {
00037     RC_UNDEFINED = 0,
00038     RC_ERROR = 1,
00039     RC_WARNING = 2
00040   };
00041 
00042 
00043   /**
00044    * Base class for Rule Checks.
00045    */
00046 
00047   class RCBase {
00048   public:
00049 
00050     typedef RCVContainer container_type;
00051 
00052 
00053   private:
00054 
00055     std::string _class_name;
00056     std::string _description;
00057     RC_SEVERITY _severity;
00058 
00059     container_type rc_violations;
00060 
00061   public:
00062 
00063     /**
00064      * The constructor.
00065      * @param class_name Short name for the RC class.
00066      * @param description A decription of what the RC basically checks.
00067      * @param severity This parameter indicates wheather this 
00068      *   RC violation container is for an error or just for a warning.
00069      */
00070     RCBase(std::string const& class_name,
00071             std::string const& description,
00072             RC_SEVERITY severity = RC_ERROR) :
00073       _class_name(class_name),
00074       _description(description),
00075       _severity(severity) {
00076     }
00077 
00078     virtual ~RCBase() {}
00079 
00080     /**
00081      * The run method is abstract and must be implemented in derived
00082      * classes. The implementation should check for design rule violations.
00083      * Each RC violation must be stored via method add_rc_violation().
00084      * Note: Because run() can be called multiple times, at the beginning of
00085      * run() you must clear the list of detected violations.
00086      */
00087     virtual void run(LogicModel_shptr lmodel) = 0;
00088 
00089     /**
00090      * Get the list of RC violations.
00091      */
00092 
00093     container_type get_rc_violations() const {
00094       return rc_violations;
00095     }
00096 
00097     /**
00098      * Get the class name of a RC violation.
00099      * @return Returns the RC violation class name as a string.
00100      */
00101     std::string get_rc_class_name() const {
00102       return _class_name;
00103     }
00104 
00105     RC_SEVERITY get_severity() const {
00106       return _severity;
00107     }
00108 
00109   protected:
00110 
00111     /**
00112      * Add a RC violation to the list of already detected violations.
00113      */
00114     void add_rc_violation(RCViolation_shptr violation) {
00115       rc_violations.push_back(violation);
00116     }
00117 
00118     /**
00119      * Clear list of detected violations.
00120      */
00121     void clear_rc_violations() {
00122       rc_violations.clear();
00123     }
00124   };
00125 
00126   typedef std::shared_ptr<RCBase> RCBase_shptr;
00127 
00128 
00129 }
00130 
00131 #include <RCViolation.h>
00132 
00133 #endif