Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

OutputRoadSource.cc

Go to the documentation of this file.
00001 
00005 #include <iostream>
00006 
00007 #include <utils/ConfigFile.h>
00008 #include <utils/Generator.h>
00009 #include <TimeSource/TimeSource.h>
00010 #include <RoadDest/RoadDest.h>
00011 
00012 #include "OutputRoadSource.h"
00013 
00015 UTILS_INTF_CREATOR(RoadSource, out, gen, params, globals)
00016 {
00017   UTILS_INTF_REPORT(RoadSource, out);
00018   OutputRoadSource* intf = new OutputRoadSource();
00019   if (!intf->init(*params, gen, globals)) {
00020     delete intf;
00021     return NULL;
00022   }
00023   return intf;
00024 }
00025 
00026 OutputRoadSource::OutputRoadSource()
00027 {
00028   _contained = NULL;
00029   _output = NULL;
00030 }
00031 
00032 OutputRoadSource::~OutputRoadSource()
00033 {
00034   if (_contained)
00035     _contained->unref();
00036   if (_output)
00037     _output->unref();
00038 }
00039 
00040 bool OutputRoadSource::init(utils::ConfigFile& params,
00041                             RoadSourceGenerator* gen,
00042                             utils::SymbolTable* globals)
00043 {
00044   // create the contained interface
00045   _contained = gen->interface(params.getString("contained"), globals);
00046   if (!_contained) {
00047     cerr << "OutputRoadSource::init: could not create contained\n";
00048     return false;
00049   }
00050   _contained->ref();
00051 
00052   _output = RoadDest::generate(params.getString("output", "logger"), globals);
00053   if (!_output) {
00054     cerr << "OutputRoadSource::init: could not create output\n";
00055     return false;
00056   }
00057   _output->ref();
00058   
00059   return true;
00060 }
00061 
00062 bool OutputRoadSource::getPoints(utils::Time& time,
00063                                std::vector<utils::Vec3d>& points,
00064                                bool blocking)
00065 {
00066   if (_contained->getPoints(time, points, blocking)) {
00067     _output->outputPoints(time, points);
00068     return true;
00069   } 
00070   return false;
00071 }

Generated on Fri Jun 16 13:21:19 2006 for ModUtils by  doxygen 1.4.4