degate 0.1.1
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 
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 #include "globals.h"
00023 #include "LogicModelObjectBase.h"
00024 #include "Layer.h"
00025 #include "PlacedLogicModelObject.h"
00026 #include "Net.h"
00027 #include "ConnectedLogicModelObject.h"
00028 
00029 #include <boost/foreach.hpp>
00030 
00031 using namespace degate;
00032 
00033 ConnectedLogicModelObject::ConnectedLogicModelObject() {
00034 }
00035 
00036 ConnectedLogicModelObject:: ~ConnectedLogicModelObject() {
00037   remove_net();
00038 };
00039 
00040 void ConnectedLogicModelObject::set_net(Net_shptr net) {
00041   if(this->net != NULL) {
00042     this->net->remove_object(get_object_id());
00043   }
00044   this->net = net;
00045   this->net->add_object(get_object_id());
00046 }
00047 
00048 void ConnectedLogicModelObject::remove_net() {
00049   if(net != NULL) {
00050     net->remove_object(get_object_id());
00051     net.reset();
00052   }
00053 }
00054 
00055 
00056 Net_shptr ConnectedLogicModelObject::get_net()  {
00057   return net;
00058 }
00059 
00060 bool ConnectedLogicModelObject::is_connected() const {
00061   if(net == NULL) return false;
00062   if(net->size() >= 2) return true;
00063   BOOST_FOREACH(object_id_t oid, *net) {
00064     if(oid != get_object_id()) return true;
00065   }
00066   return false;
00067 }