⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 launcher.h

📁 Amis - A maximum entropy estimator 一个最大熵模型统计工具
💻 H
字号:
////////////////////////////////////////////////////////////////////////////  Copyright (c) 2000, Yusuke Miyao///  You may distribute under the terms of the Artistic License.//////  <id>$Id: Launcher.h,v 1.3 2003/05/16 13:03:46 yusuke Exp $///  <collection>Maximum Entropy Estimator</collection>///  <name>Launcher.h</name>///  <overview>Object launcher</overview>/////////////////////////////////////////////////////////////////////////#ifndef Amis_Launcher_h_#define Amis_Launcher_h_#include <amis/configure.h>#include <amis/Initializer.h>#include <amis/StringHash.h>#include <amis/LauncherItem.h>#include <amis/StringStream.h>#include <vector>#include <map>#include <iostream>AMIS_NAMESPACE_BEGINtemplate < class T, class ArgType, class Name > class LauncherItem;template < class T, class ArgType, class Name = std::string >class Launcher {protected:  Initializer< Launcher< T, ArgType, Name >* >*& queue;  std::string name;  std::vector< LauncherItem< T, ArgType, Name >* > launcher_items;  std::map< Name, LauncherItem< T, ArgType, Name >* > launcher_hash;  bool initialized;public:  Launcher( const std::string& n,            Initializer< Launcher< T, ArgType, Name >* >*& q )    : queue( q ) {    name = n;    initialized = false;  }  virtual ~Launcher() {}  const std::string& getName() const {    return name;  }  void initLauncherItems() {    if ( ! initialized ) {      Initializer< Launcher< T, ArgType, Name >* >::initAll( queue, this );      initialized = true;    }  }  virtual void setLauncherItem( LauncherItem< T, ArgType, Name >* item ) {    typename std::map< Name, LauncherItem< T, ArgType, Name >* >::iterator it = launcher_hash.find( item->getName() );    if ( it != launcher_hash.end() ) {      OStringStream oss;      oss << "Duplicate launcher item: " << item->getName();      throw IllegalLauncherItemError( oss.str() );    }    launcher_items.push_back( item );    launcher_hash[ item->getName() ] = item;  }  virtual T launch( const Name& name, ArgType arg ) {    typename std::map< Name, LauncherItem< T, ArgType, Name >* >::iterator it = launcher_hash.find( name );    if ( it == launcher_hash.end() ) {      OStringStream oss;      oss << "Cannot find a launcher item for " << getName() << ": " << name;      throw IllegalLauncherItemError( oss.str() );    }    return it->second->launch( arg );  }  virtual void showLauncherItems( std::ostream& os ) {    for ( typename std::map< Name, LauncherItem< T, ArgType, Name >* >::iterator it = launcher_hash.begin();          it != launcher_hash.end();          ++it ) {      os << it->first << '\t' << it->second->getDescription() << '\n';    }  }};AMIS_NAMESPACE_END#endif // Amis_Launcher_h_// end of Launcher.h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -