degate  0.1.2
EMarker.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 "EMarker.h"
00024 #include <XmlRpc.h>
00025 #include <boost/format.hpp>
00026 
00027 using namespace degate;
00028 
00029 EMarker::EMarker(int _x, int _y, diameter_t _diameter) :
00030   Circle(_x, _y, _diameter) {
00031 }
00032 
00033 EMarker::~EMarker() {}
00034 
00035 DeepCopyable_shptr EMarker::cloneShallow() const {
00036   auto clone = std::make_shared<EMarker>();
00037   return clone;
00038 }
00039 
00040 void EMarker::cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00041   auto clone = std::dynamic_pointer_cast<EMarker>(dest);
00042   Circle::cloneDeepInto(clone, oldnew);
00043   ConnectedLogicModelObject::cloneDeepInto(clone, oldnew);
00044   RemoteObject::cloneDeepInto(clone, oldnew);
00045 }
00046 
00047 const std::string EMarker::get_descriptive_identifier() const {
00048   if(has_name()) {
00049     boost::format fmter("emarker %1% (%2%)");
00050     fmter % get_name() % get_object_id();
00051     return fmter.str();
00052   }
00053   else {
00054     boost::format fmter("emarker (%1%)");
00055     fmter % get_object_id();
00056     return fmter.str();
00057   }
00058 }
00059 
00060 const std::string EMarker::get_object_type_name() const {
00061   return std::string("EMarker");
00062 }
00063 
00064 
00065 void EMarker::print(std::ostream & os, int n_tabs) const {
00066 
00067   os
00068     << gen_tabs(n_tabs) << "EMarker name      : " << get_name() << std::endl
00069     << gen_tabs(n_tabs) << "Object ID         : " << get_object_id() << std::endl
00070     << gen_tabs(n_tabs) << "EMarker position  : " << get_x() << " / " << get_y() << std::endl
00071     << gen_tabs(n_tabs) << "Bounding box      : " << Circle::get_bounding_box().to_string() << std::endl
00072     << std::endl;
00073     ;
00074 
00075 }
00076 
00077 void EMarker::shift_x(int delta_x) {
00078   Circle::shift_x(delta_x);
00079   notify_shape_change();
00080 }
00081 
00082 void EMarker::shift_y(int delta_y) {
00083   Circle::shift_y(delta_y);
00084   notify_shape_change();
00085 }
00086 
00087 void EMarker::set_x(int x) {
00088   Circle::set_x(x);
00089   notify_shape_change();
00090 }
00091 
00092 void EMarker::set_y(int y) {
00093   Circle::set_y(y);
00094   notify_shape_change();
00095 }
00096 
00097 void EMarker::set_diameter(unsigned int diameter) {
00098   Circle::set_diameter(diameter);
00099   notify_shape_change();
00100 }
00101 
00102 
00103 object_id_t EMarker::push_object_to_server(std::string const& server_url) {
00104 
00105   try {
00106 
00107     xmlrpc_c::paramList params;
00108     params.add(xmlrpc_c::value_string("add"));
00109     params.add(xmlrpc_c::value_string("emarker"));
00110 
00111     Layer_shptr layer = get_layer();
00112     assert(layer != NULL);
00113     params.add(xmlrpc_c::value_int(layer->get_layer_id()));
00114 
00115     params.add(xmlrpc_c::value_int(get_x()));
00116     params.add(xmlrpc_c::value_int(get_y()));
00117     params.add(xmlrpc_c::value_int(get_diameter()));
00118 
00119     int const transaction_id =
00120       xmlrpc_c::value_int(remote_method_call(server_url, "degate.push", params));
00121 
00122     set_remote_object_id(transaction_id);
00123 
00124     std::cout << "Pushed via to server. remote id is: " << transaction_id << std::endl;
00125     return transaction_id;
00126   }
00127   catch(std::exception const& e) {
00128     std::cerr << "Client threw error: " << e.what() << std::endl;
00129     throw XMLRPCException(e.what());
00130   }
00131   catch(...) {
00132     std::cerr << "Client threw unexpected error." << std::endl;
00133     throw XMLRPCException("Client threw unexpected error.");
00134   }
00135 
00136 }