Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * fvretriever_plugin.cpp - FireVision Retriever Plugin 00004 * 00005 * Created: Tue Jun 26 17:35:33 2007 00006 * Copyright 2006-2007 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 "fvretriever_plugin.h" 00024 #include "retriever_thread.h" 00025 00026 #include <core/exceptions/software.h> 00027 00028 using namespace fawkes; 00029 using namespace firevision; 00030 00031 /** @class FvRetrieverPlugin "fvretriever_plugin.h" 00032 * FireVision Retriever Plugin. 00033 * This is the FireVision retriever plugin. It is a simple plugin that will 00034 * fetch images from a specific camera defined as a configuration setting. 00035 * 00036 * @author Tim Niemueller 00037 */ 00038 00039 /** Constructor. 00040 * @param config Fawkes configuration 00041 */ 00042 FvRetrieverPlugin::FvRetrieverPlugin(Configuration *config) 00043 : Plugin(config) 00044 { 00045 00046 std::string prefix = "/firevision/retriever/camera/"; 00047 Configuration::ValueIterator *vi = config->search(prefix.c_str()); 00048 00049 while (vi->next()) { 00050 if ( ! vi->is_string() ) { 00051 throw TypeMismatchException("Only values of type string are valid for camera" 00052 " argument strings, but got %s for %s", 00053 vi->type(), vi->path()); 00054 } 00055 00056 std::string id = std::string(vi->path()).substr(prefix.length()); 00057 00058 thread_list.push_back(new FvRetrieverThread(vi->get_string().c_str(), id.c_str())); 00059 } 00060 00061 if ( thread_list.empty() ) { 00062 throw Exception("No cameras have been set for fvretriever"); 00063 } 00064 00065 delete vi; 00066 } 00067 00068 PLUGIN_DESCRIPTION("Reads images from cameras and stores them in shared memory") 00069 EXPORT_PLUGIN(FvRetrieverPlugin)