degate  0.1.2
GateLibrary.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  Copyright 2012 Robert Nitsch
00007 
00008  Degate is free software: you can redistribute it and/or modify
00009  it under the terms of the GNU General Public License as published by
00010  the Free Software Foundation, either version 3 of the License, or
00011  any later version.
00012 
00013  Degate is distributed in the hope that it will be useful,
00014  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  GNU General Public License for more details.
00017 
00018  You should have received a copy of the GNU General Public License
00019  along with degate. If not, see <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #ifndef __GATELIBRARY_H__
00024 #define __GATELIBRARY_H__
00025 
00026 #include "DeepCopyable.h"
00027 #include <degate.h>
00028 #include <set>
00029 #include <map>
00030 #include <sstream>
00031 
00032 namespace degate {
00033 
00034   /**
00035    * This class represents a library of template cells.
00036    *
00037    * @todo There is no way to deal with gate libraries, which
00038    *   have different image sizes for the gate templates than the
00039    *   current project. There should be a way to scale the template
00040    *   images, but it is unknown how to derive the scaling factor without pain.
00041    */
00042   class GateLibrary : public DeepCopyable {
00043 
00044   public:
00045 
00046     typedef std::map<object_id_t, GateTemplate_shptr> gate_lib_collection_t;
00047     typedef gate_lib_collection_t::iterator template_iterator;
00048     typedef gate_lib_collection_t::const_iterator const_template_iterator;
00049 
00050   private:
00051 
00052     gate_lib_collection_t templates;
00053 
00054   public:
00055 
00056     /**
00057      * Constructor for the gate library.
00058      */
00059 
00060     GateLibrary();
00061 
00062     /**
00063      * The dtor.
00064      */
00065 
00066     virtual ~GateLibrary();
00067 
00068     //@{
00069     DeepCopyable_shptr cloneShallow() const;
00070     void cloneDeepInto(DeepCopyable_shptr destination, oldnew_t *oldnew) const;
00071     //@}
00072     
00073     /**
00074      * Remove a template from the gate library.
00075      */
00076 
00077     void remove_template(GateTemplate_shptr gate_template);
00078 
00079     /**
00080      * Add a template to the library.
00081      * @exception InvalidObjectIDException This exception is thrown if the
00082      *   template has no object ID.
00083      * @exception InvalidPointerException
00084      */
00085 
00086     void add_template(GateTemplate_shptr gate_template);
00087 
00088     /**
00089      * Get a gate template from the library.
00090      * @exception CollectionLookupException This exception is thrown if
00091      *  there is no gate template that has ID \p id.
00092      * @exception InvalidObjectIDException This exception is thrown if the
00093      *   object ID is invalid.
00094      * @return Returns a shared pointer to the template. The
00095      *   pointer value is NULL, if a template with the \p id
00096      *   was not found.
00097      */
00098 
00099     GateTemplate_shptr get_template(object_id_t id);
00100 
00101 
00102     /**
00103      * Check if a template for a given \p id exists.
00104      */
00105     bool exists_template(object_id_t id) const;
00106 
00107     /**
00108      * Check for a name in the gate library.
00109      * @return Returns true, if a template name is already used for a template.
00110      */
00111 
00112     bool is_name_in_use(std::string const & name) const;
00113 
00114 
00115     /**
00116      * Check if there is a template port in the gate library with the specified object ID.
00117      */
00118 
00119     bool exists_template_port(object_id_t port_id);
00120 
00121     /**
00122      * Lookup a template port in the gate library.
00123      * @throws CollectionLookupException Throws this exception, if the port was nout found.
00124      */
00125 
00126     GateTemplatePort_shptr get_template_port(object_id_t port_id);
00127 
00128 
00129     /**
00130      * Get an iterator in order to iterate over gate templates.
00131      */
00132 
00133     template_iterator begin();
00134 
00135     /**
00136      * Get the end marker for the iteration.
00137      */
00138 
00139     template_iterator end();
00140 
00141     /**
00142      * Get an iterator in order to iterate over gate templates.
00143      */
00144 
00145     const_template_iterator begin() const;
00146 
00147     /**
00148      * Get the end marker for the iteration.
00149      */
00150 
00151     const_template_iterator end() const;
00152 
00153     /**
00154      * print the gate library.
00155      */
00156 
00157     void print(std::ostream & os);
00158 
00159   };
00160 
00161 
00162 
00163 }
00164 
00165 #endif
00166