degate  0.1.2
ConnectedLogicModelObject.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 "LogicModelObjectBase.h"
00025 #include "Layer.h"
00026 #include "PlacedLogicModelObject.h"
00027 #include "Net.h"
00028 #include "ConnectedLogicModelObject.h"
00029 
00030 #include <boost/foreach.hpp>
00031 
00032 using namespace degate;
00033 
00034 ConnectedLogicModelObject::ConnectedLogicModelObject() {
00035 }
00036 
00037 ConnectedLogicModelObject:: ~ConnectedLogicModelObject() {
00038   remove_net();
00039 };
00040 
00041 void ConnectedLogicModelObject::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00042   PlacedLogicModelObject::cloneDeepInto(dest, oldnew);
00043   
00044   auto clone = std::dynamic_pointer_cast<ConnectedLogicModelObject>(dest);
00045   if (net.get() != nullptr) {
00046     clone->net = std::dynamic_pointer_cast<Net>(net->cloneDeep(oldnew));
00047   }
00048 }
00049 
00050 void ConnectedLogicModelObject::set_net(Net_shptr net) {
00051   if(this->net != NULL) {
00052     this->net->remove_object(get_object_id());
00053   }
00054   this->net = net;
00055   this->net->add_object(get_object_id());
00056 }
00057 
00058 void ConnectedLogicModelObject::remove_net() {
00059   if(net != NULL) {
00060     net->remove_object(get_object_id());
00061     net.reset();
00062   }
00063 }
00064 
00065 
00066 Net_shptr ConnectedLogicModelObject::get_net()  {
00067   return net;
00068 }
00069 
00070 bool ConnectedLogicModelObject::is_connected() const {
00071   if(net == NULL) return false;
00072   if(net->size() >= 2) return true;
00073   BOOST_FOREACH(object_id_t oid, *net) {
00074     if(oid != get_object_id()) return true;
00075   }
00076   return false;
00077 }