degate  0.1.2
Net.cc
Go to the documentation of this file.
00001 /*
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 "Net.h"
00026 #include "Layer.h"
00027 #include "LogicModel.h"
00028 #include "ConnectedLogicModelObject.h"
00029 #include "degate_exceptions.h"
00030 
00031 using namespace degate;
00032 
00033 Net::Net() {
00034 }
00035 
00036 Net::~Net() {
00037 }
00038 
00039 DeepCopyable_shptr Net::cloneShallow() const {
00040   auto clone = std::make_shared<Net>();
00041   return clone;
00042 }
00043 
00044 void Net::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00045   auto clone = std::dynamic_pointer_cast<Net>(dest);
00046   clone->connections = connections;
00047   LogicModelObjectBase::cloneDeepInto(dest, oldnew);
00048 }
00049 
00050 Net::connection_iterator Net::begin() {
00051   return connections.begin();
00052 }
00053 
00054 Net::connection_iterator Net::end() {
00055   return connections.end();
00056 }
00057 
00058 void Net::remove_object(object_id_t oid) {
00059 
00060   if(oid == 0)
00061     throw InvalidObjectIDException("The object that has to be "
00062                                    "removed from the net has no object ID.");
00063 
00064   connection_iterator i = connections.find(oid);
00065   if(i != connections.end()) {
00066     connections.erase(i);
00067   }
00068   else
00069     throw CollectionLookupException("Can't remove object from the the net, "
00070                                     "because it is not in the net.");
00071 }
00072 
00073 void Net::remove_object(ConnectedLogicModelObject_shptr o) {
00074   remove_object(o->get_object_id());
00075 }
00076 
00077 
00078 void Net::add_object(object_id_t oid) {
00079   if(oid == 0)
00080     throw InvalidObjectIDException("The object that has to be "
00081                                    "added to the net has no object ID.");
00082   else
00083     connections.insert(oid);
00084 }
00085 
00086 void Net::add_object(ConnectedLogicModelObject_shptr o) {
00087   add_object(o->get_object_id());
00088 }
00089 
00090 
00091 
00092 unsigned int Net::size() const {
00093   return connections.size();
00094 }
00095 
00096 const std::string Net::get_descriptive_identifier() const {
00097   boost::format fmter("Net %1%");
00098   fmter % get_object_id();;
00099   return fmter.str();
00100 }