Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * naoqi_inifin.cpp - Fawkes NaoQiAspect initializer/finalizer 00004 * 00005 * Created: Thu May 12 15:54:02 2011 00006 * Copyright 2006-2011 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. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #include <plugins/nao/aspect/naoqi_inifin.h> 00025 #include <core/threading/thread_finalizer.h> 00026 00027 namespace fawkes { 00028 #if 0 /* just to make Emacs auto-indent happy */ 00029 } 00030 #endif 00031 00032 /** @class NaoQiAspectIniFin <plugins/nao/aspect/naoqi_inifin.h> 00033 * NaoQiAspect initializer/finalizer. 00034 * This initializer/finalizer will provide the NaoQi broker to threads 00035 * with the NaoQiAspect. 00036 * @author Tim Niemueller 00037 */ 00038 00039 /** Constructor. */ 00040 NaoQiAspectIniFin::NaoQiAspectIniFin() 00041 : AspectIniFin("NaoQiAspect") 00042 { 00043 } 00044 00045 void 00046 NaoQiAspectIniFin::init(Thread *thread) 00047 { 00048 NaoQiAspect *naoqi_thread; 00049 naoqi_thread = dynamic_cast<NaoQiAspect *>(thread); 00050 if (naoqi_thread == NULL) { 00051 throw CannotInitializeThreadException("Thread '%s' claims to have the " 00052 "NaoQiAspect, but RTTI says it " 00053 "has not. ", thread->name()); 00054 } 00055 if (! __naoqi_broker) { 00056 throw CannotInitializeThreadException("NaoQi broker has not been set."); 00057 } 00058 00059 naoqi_thread->init_NaoQiAspect(__naoqi_broker); 00060 } 00061 00062 void 00063 NaoQiAspectIniFin::finalize(Thread *thread) 00064 { 00065 } 00066 00067 00068 /** Set the NaoQi broker to use for aspect initialization. 00069 * @param naoqi_broker NaoQi broker to pass to threads with NaoQiAspect. 00070 */ 00071 void 00072 NaoQiAspectIniFin::set_naoqi_broker(AL::ALPtr<AL::ALBroker> naoqi_broker) 00073 { 00074 __naoqi_broker = naoqi_broker; 00075 } 00076 00077 } // end namespace fawkes