Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * single_copy.cpp - Fawkes WorldModel Single Interface Copy Fuser 00004 * 00005 * Created: Tue Jan 13 11:46:30 2009 00006 * Copyright 2006-2009 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #include "single_copy.h" 00024 00025 #include <blackboard/blackboard.h> 00026 #include <interface/interface.h> 00027 00028 using namespace fawkes; 00029 00030 /** @class WorldModelSingleCopyFuser "single_copy.h" 00031 * Single interface copy fuser. 00032 * This fuser simply copies the data of one interface to another of the same 00033 * type. 00034 * @author Tim Niemueller 00035 */ 00036 00037 /** Constructor. 00038 * @param blackboard BlackBoard 00039 * @param type interface type of both interfaces 00040 * @param from_id ID of the interface to copy from 00041 * @param to_id ID of the interface to copy to 00042 */ 00043 WorldModelSingleCopyFuser::WorldModelSingleCopyFuser(BlackBoard *blackboard, 00044 const char *type, 00045 const char *from_id, 00046 const char *to_id) 00047 { 00048 __blackboard = blackboard; 00049 __from = blackboard->open_for_reading(type, from_id); 00050 __to = blackboard->open_for_writing(type, to_id); 00051 00052 __from->read(); 00053 __to->copy_values(__from); 00054 __to->write(); 00055 } 00056 00057 00058 /** Destructor. */ 00059 WorldModelSingleCopyFuser::~WorldModelSingleCopyFuser() 00060 { 00061 __blackboard->close(__from); 00062 __blackboard->close(__to); 00063 } 00064 00065 00066 void 00067 WorldModelSingleCopyFuser::fuse() 00068 { 00069 if (__from->has_writer()) { 00070 __from->read(); 00071 __to->copy_values(__from); 00072 __to->write(); 00073 } 00074 }