degate  0.1.2
Annotation.cc
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 #include "globals.h"
00024 #include "Annotation.h"
00025 #include <boost/format.hpp>
00026 
00027 using namespace degate;
00028 
00029 Annotation::Annotation(int _min_x, int _max_x, int _min_y, int _max_y,
00030                        class_id_t _class_id) :
00031   Rectangle(_min_x, _max_x, _min_y, _max_y), class_id(_class_id) {
00032 
00033 }
00034 
00035 Annotation::Annotation(BoundingBox const& bbox, class_id_t _class_id) :
00036   Rectangle(bbox.get_min_x(), bbox.get_max_x(),
00037             bbox.get_min_y(), bbox.get_max_y()),
00038   class_id(_class_id) {
00039 }
00040 
00041 Annotation::~Annotation() {
00042 }
00043 
00044 DeepCopyable_shptr Annotation::cloneShallow() const {
00045   auto clone = std::make_shared<Annotation>();
00046   return clone;
00047 }
00048 
00049 void Annotation::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00050   auto clone = std::dynamic_pointer_cast<Annotation>(dest);
00051   clone->class_id = class_id;
00052   clone->parameters = parameters;
00053   Rectangle::cloneDeepInto(dest, oldnew);
00054   PlacedLogicModelObject::cloneDeepInto(dest, oldnew);
00055 }
00056 
00057 Annotation::class_id_t Annotation::get_class_id() const {
00058   return class_id;
00059 }
00060 
00061 void Annotation::set_class_id(Annotation::class_id_t _class_id) {
00062   class_id = _class_id;
00063 }
00064 
00065 const std::string Annotation::get_descriptive_identifier() const {
00066   boost::format fmter("%1% (id=%2%,class=%3%)");
00067   fmter % get_object_id() % get_name() % get_class_id();
00068   return fmter.str();
00069 }
00070 
00071 const std::string Annotation::get_object_type_name() const {
00072   return std::string("Annotation");
00073 }
00074 
00075 void Annotation::print(std::ostream & os, int n_tabs) const {
00076 
00077   os
00078     << gen_tabs(n_tabs) << "Annotation name  : " << get_name() << std::endl
00079     << gen_tabs(n_tabs) << "Description      : " << get_description() << std::endl
00080     << gen_tabs(n_tabs) << "Object ID        : " << get_object_id() << std::endl
00081     << gen_tabs(n_tabs) << "Bounding box     : " << Rectangle::get_bounding_box().to_string() << std::endl
00082     << gen_tabs(n_tabs) << "Annotation class : " << get_class_id() << std::endl
00083     << std::endl;
00084 
00085   os << std::endl;
00086 
00087 }
00088 
00089 Annotation::parameter_set_type::const_iterator Annotation::parameters_begin() const {
00090   return parameters.begin();
00091 }
00092 
00093 Annotation::parameter_set_type::const_iterator Annotation::parameters_end() const {
00094   return parameters.end();
00095 }