degate  0.1.2
Wire.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 #include <Wire.h>
00031 #include <XmlRpc.h>
00032 #include <exception>
00033 
00034 using namespace degate;
00035 
00036 Wire::Wire(int _from_x, int _from_y, int _to_x, int _to_y, unsigned int _diameter) :
00037   Line(_from_x, _from_y, _to_x, _to_y, _diameter) {
00038 }
00039 
00040 DeepCopyable_shptr Wire::cloneShallow() const {
00041   return std::make_shared<Wire>(get_from_x(), get_from_y(), get_to_x(), get_to_y(), get_diameter());
00042 }
00043 
00044 void Wire::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00045   auto clone = std::dynamic_pointer_cast<Wire>(dest);
00046   Line::cloneDeepInto(dest, oldnew);
00047   RemoteObject::cloneDeepInto(dest, oldnew);
00048 }
00049 
00050 const std::string Wire::get_descriptive_identifier() const {
00051   if(has_name()) {
00052     boost::format fmter("wire %1% (%2%)");
00053     fmter % get_name() % get_object_id();
00054     return fmter.str();
00055   }
00056   else {
00057     boost::format fmter("wire (%1%)");
00058     fmter % get_object_id();
00059     return fmter.str();
00060   }
00061 }
00062 
00063 const std::string Wire::get_object_type_name() const {
00064   return std::string("Wire");
00065 }
00066 
00067 void Wire::print(std::ostream & os, int n_tabs) const {
00068 }
00069 
00070 object_id_t Wire::push_object_to_server(std::string const& server_url) {
00071 
00072   try {
00073 
00074     xmlrpc_c::paramList params;
00075     params.add(xmlrpc_c::value_string("add"));
00076     params.add(xmlrpc_c::value_string("wire"));
00077 
00078     Layer_shptr layer = get_layer();
00079     assert(layer != NULL);
00080     params.add(xmlrpc_c::value_int(layer->get_layer_id()));
00081 
00082     params.add(xmlrpc_c::value_int(get_from_x()));
00083     params.add(xmlrpc_c::value_int(get_from_y()));
00084     params.add(xmlrpc_c::value_int(get_to_x()));
00085     params.add(xmlrpc_c::value_int(get_to_y()));
00086     params.add(xmlrpc_c::value_int(get_diameter()));
00087 
00088     int const transaction_id =
00089       xmlrpc_c::value_int(remote_method_call(server_url, "degate.push", params));
00090 
00091     set_remote_object_id(transaction_id);
00092     std::cout << "Pushed wire to server. remote id is: " << transaction_id << std::endl;
00093     return transaction_id;
00094   }
00095   catch(std::exception const& e) {
00096     std::cerr << "Client threw error: " << e.what() << std::endl;
00097     throw XMLRPCException(e.what());
00098   }
00099   catch(...) {
00100     std::cerr << "Client threw unexpected error." << std::endl;
00101     throw XMLRPCException("Client threw unexpected error.");
00102   }
00103 
00104 }