/* -*- C++ -*- * Copyright ©2008 Hugo Mills * * This software is distributed under the terms of the GNU GPL v3 * For more information on the GPL, see the file COPYING or * visit http://www.gnu.org/ * * This software is distributed without warranty */ #include "reference.h" #include "magellan/content.h" #include "magellan/xforbit.h" extern "C" PluginInfo* getmodules(int i) { PluginInfo* pi = NULL; if(i==0) { PluginInfo_Content* pir = new PluginInfo_Content(); pir->name = "Content Reference"; pir->parser = Reference::parse; pi = pir; } else if(i==1) { PluginInfo_Orbit* pir = new PluginInfo_Orbit(); pir->name = "Orbit Reference"; pir->parser = Reference::parse; pi = pir; } if(pi) { pi->author = "Hugo Mills"; pi->copyright = "©2008 Hugo Mills"; pi->version = 0x10000; } return pi; } template T* Reference::parse( ConfigLexer* lex, const std::string& type, const std::string& subtype ) { if(type != accept_type()) return NULL; if(subtype != accept_subtype()) return NULL; std::string ref; while(!lex->eos()) { if(readkeyedvalue(lex, "ref", &ref)) { } else throw(UnknownConfigToken(lex)); } return new Reference(ref); } template Plugin* Reference::bind(Configuration* config) { T* pointer = config->getplugin(ref); if( pointer != NULL ) { pointer->addreference(); this->destroy(); } return pointer; } /* Lookups by type for what "type" and "subtype" parameters should be */ /* Orbits */ template<> std::string Reference::accept_type(void) { return "ref"; } template<> std::string Reference::accept_subtype(void) { return ""; } /* Contents */ template<> std::string Reference::accept_type(void) { return "ref"; } template<> std::string Reference::accept_subtype(void) { return ""; }