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