degate  0.1.2
RemoteObject.h
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 #ifndef __REMOTEOBJECT_H__
00024 #define __REMOTEOBJECT_H__
00025 
00026 #include "DeepCopyable.h"
00027 
00028 #include <cstdlib>
00029 #include <string>
00030 #include <iostream>
00031 #include <assert.h>
00032 
00033 namespace degate {
00034 
00035   class RemoteObject : public DeepCopyableBase {
00036 
00037   private:
00038 
00039     object_id_t remote_oid;
00040 
00041   protected:
00042 
00043     virtual object_id_t push_object_to_server(std::string const& server_url) = 0;
00044 
00045   public:
00046 
00047     RemoteObject() : remote_oid(0) {
00048     }
00049 
00050     virtual ~RemoteObject() {
00051     }
00052 
00053     void cloneDeepInto(DeepCopyable_shptr dest, oldnew_t *oldnew) const {
00054       auto clone = std::dynamic_pointer_cast<RemoteObject>(dest);
00055       clone->remote_oid = remote_oid;
00056     }
00057 
00058     virtual bool has_remote_object_id() const {
00059       return remote_oid != 0;
00060     }
00061 
00062     virtual object_id_t get_remote_object_id() const {
00063       return remote_oid;
00064     }
00065 
00066     virtual void set_remote_object_id(object_id_t oid) {
00067       remote_oid = oid;
00068     }
00069 
00070 
00071     virtual object_id_t push(std::string const& server_url) {
00072       if(remote_oid == 0) {
00073         debug(TM, "RemoteObject::push(): push object to server.");
00074         return push_object_to_server(server_url);
00075       }
00076       else {
00077         debug(TM, "RemoteObject::push(): object is already pushed to server.");
00078         return 0;
00079       }
00080     }
00081 
00082   };
00083 
00084 
00085 }
00086 
00087 #endif