degate  0.1.2
LogicModelObjectBase.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 
00024 #include "globals.h"
00025 #include "LogicModelObjectBase.h"
00026 #include "Layer.h"
00027 #include "PlacedLogicModelObject.h"
00028 
00029 using namespace degate;
00030 
00031 LogicModelObjectBase::LogicModelObjectBase(object_id_t oid) :
00032   object_id(oid) {
00033 }
00034 
00035 LogicModelObjectBase::LogicModelObjectBase(std::string const& object_name,
00036                                            std::string const& object_description) :
00037   object_id(0),
00038   name(object_name),
00039   description(object_description) {
00040 }
00041 
00042 LogicModelObjectBase::LogicModelObjectBase(object_id_t oid,
00043                                            std::string const& object_name,
00044                                            std::string const& object_description) :
00045   object_id(oid),
00046   name(object_name),
00047   description(object_description) {
00048 }
00049 
00050 LogicModelObjectBase::~LogicModelObjectBase() {
00051 }
00052 
00053 void LogicModelObjectBase::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00054   auto clone = std::dynamic_pointer_cast<LogicModelObjectBase>(dest);
00055   clone->object_id = object_id;
00056   clone->name = name;
00057   clone->description = description;
00058 }
00059 
00060 void LogicModelObjectBase::set_name(std::string const& name) {
00061   this->name = name;
00062 }
00063 
00064 void LogicModelObjectBase::set_description(std::string const & description) {
00065   this->description = description;
00066 }
00067 
00068 std::string const & LogicModelObjectBase::get_name() const {
00069   return name;
00070 }
00071 
00072 std::string const & LogicModelObjectBase::get_description() const {
00073   return description;
00074 }
00075 
00076 bool LogicModelObjectBase::has_name() const {
00077   return !name.empty();
00078 }
00079 
00080 bool LogicModelObjectBase::has_description() const {
00081   return !description.empty();
00082 }
00083 
00084 
00085 void LogicModelObjectBase::set_object_id(object_id_t oid) {
00086   object_id = oid;
00087 }
00088 
00089 object_id_t LogicModelObjectBase::get_object_id() const {
00090   return object_id;
00091 }
00092 
00093 bool LogicModelObjectBase::has_valid_object_id() const {
00094   return object_id != 0;
00095 }
00096 
00097 
00098 const std::string LogicModelObjectBase::get_descriptive_identifier() const {
00099   // should be dispatched. In debug mode we break here.
00100   assert(1 == 0);
00101 
00102   boost::format fmter("Generic object %1%");
00103   fmter % get_object_id();;
00104   return fmter.str();
00105 }
00106 
00107 const std::string LogicModelObjectBase::get_object_type_name() const {
00108   return std::string("Generic object");
00109 }
00110 
00111 
00112 
00113 bool LMOCompare::operator() (const LogicModelObjectBase &a, const LogicModelObjectBase &b) const {
00114   return a.get_object_id() < b.get_object_id();
00115 }
00116 
00117 bool LMOCompare::operator() (const LogicModelObjectBase_shptr &a, const LogicModelObjectBase_shptr &b) const {
00118   return this->operator()(*a, *b);
00119 }