fvretriever_plugin.cpp

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