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

📄 builder.hpp

📁 robocup rcssbase-11.1.0(1).zip
💻 HPP
📖 第 1 页 / 共 2 页
字号:
// -*-c++-*-/***************************************************************************                               builder.hpp                  Interface for building config parameter                             -------------------    begin                : 14-MAY-2003    copyright            : (C) 2003 by The RoboCup Soccer Server                            Maintenance Group.    email                : sserver-admin@lists.sourceforge.net ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU LGPL as published by the Free Software  * *   Foundation; either version 2 of the License, or (at your option) any  * *   later version.                                                        * *                                                                         * ***************************************************************************/#ifndef BUILDER_HPP#define BUILDER_HPP#include "../rcssbaseconfig.hpp"#include <map>#include <boost/shared_ptr.hpp>#include <iostream>#include "paramsetter.hpp"#include "paramgetter.hpp"#include "rcssbase/lib/factory.hpp"#include "rcssbase/lib/shared_ptr.hpp"#include <string>namespace rcss{	namespace conf	{		class StatusHandler;		class Parser;		class Builder		{		public:			typedef rcss::lib::shared_ptr< Builder > Ptr;			typedef Ptr(*Creator)( Builder* parent );			typedef rcss::lib::Factory< Creator > Factory;						RCSSBASE_API			static			Factory&			factory();				    			RCSSBASE_API			Builder( const std::string& progname,					 const std::string& module_name );			RCSSBASE_API			Builder( Builder* parent,					 const std::string& module_name );			RCSSBASE_API            virtual            ~Builder();            template< typename V >            bool            buildParam( const std::string& module_name,                        const std::string& param_name,                        V value,						const std::string& name,						int lineno );			RCSSBASE_API            void            createConfFile( std::ostream& conf,							const std::string& module_name );						RCSSBASE_API			void			displayHelp();			/// removeHandler must be called before the handler is destroyed			RCSSBASE_API			void			addHandler( StatusHandler& handler );			RCSSBASE_API			void			removeHandler( StatusHandler& handler );			/// sets the specified parameter to the specified value			template< typename P >			bool			set( const std::string& param, P value )			{				return doBuildParam( param, value, "none", 0 );			} 			/// gets the value of the specified parameter			template< typename P >			RCSSBASE_API			bool			get( const std::string& param,				 P& value ) const;			RCSSBASE_API			bool			genericHelpRequested() const;						RCSSBASE_API			bool			detailedHelpRequested() const;			RCSSBASE_API			Parser*			parser();			template< typename V >			void			addParam( const std::string& name, 					  const Setter< V >& setter,					  const Getter< V >& getter, 					  const std::string& desc )			{ addParam( name, ParamInfo< V >( setter, getter, desc ) ); }						template< typename V >			void			addParam( const std::string& name, 					  V& param, 					  const std::string& desc )			{ 				addParam( name, 						  makeSetter( param ),						  makeGetter( param ),						  desc );			}			RCSSBASE_API			void			manageModule( const rcss::lib::Loader& module );			RCSSBASE_API			const std::string&			getModuleName() const;      		private:			friend class Parser;			friend class ParseErrorHandler;			RCSSBASE_API			void			manageChild( const rcss::lib::shared_ptr< Builder >& child );			RCSSBASE_API			void			clearModules();			std::list< rcss::lib::Loader > m_modules;			std::list< rcss::lib::shared_ptr< Builder > > m_managed_children;			RCSSBASE_API			void			addChild( Builder& child );			RCSSBASE_API			void			removeChild( Builder& child );            template< typename V >            void            createConfFileEntry( std::ostream& conf,                                  const std::string& module_name,                                 const std::string& param_name,                                 V value,                                 const std::string& desc );			template< typename V >			void			displayHelpEntry( std::ostream& out,							  const std::string& module_name,							  const std::string& param_name,							  V value,							  const std::string& desc );						void			displayHelpEntry( std::ostream& out,							  const std::string& module_name,							  const std::string& param_name,							  const std::string& desc );						void			displayHelpEntry( std::ostream& out,							  const std::string& param_name,							  const std::string& desc );			            template< typename V >            void            writeConfValue( std::ostream& conf, V value );            template< typename V >            void            writeConfType( std::ostream& conf, V value );			RCSSBASE_API			void			parseError( const std::string& curr,						const std::string& err,						const std::string& name,						int lineno );						RCSSBASE_API			void			buildError( const std::string& module,						const std::string& param,						const std::string& err,						const std::string& name,						int lineno );						RCSSBASE_API			void			buildWarning( const std::string& module,						  const std::string& param,						  const std::string& warn,						  const std::string& name,						  int lineno );			RCSSBASE_API			void			creatingConfFile( const std::string& conf_name );						RCSSBASE_API			void			createdConfFile( const std::string& conf_name );			RCSSBASE_API			void			confCreationFailed( const std::string& conf_name,								int error );			RCSSBASE_API			void			includeFailed( const std::string& filename,						   const std::string& error,						   const std::string& name,						   int lineno );			RCSSBASE_API			void			loadFailed( const std::string& libname,						const std::string& error,						const std::vector< boost::filesystem::path >& avail,						const std::string& name,						int lineno );						RCSSBASE_API			bool			success() const;						RCSSBASE_API			void			reset();						RCSSBASE_API			const std::string&			progName() const;									RCSSBASE_API			void			requestGenericHelp();						void			requestDetailedHelp();			RCSSBASE_API			void			requestDetailedHelp( const std::string& module_name );						RCSSBASE_API			void			requestDetailedHelpX( const char* begin,								  const char* end )			{				requestDetailedHelp( std::string( begin, end ) );			}						RCSSBASE_API			void			addedToParser( Parser& p );						RCSSBASE_API			void			removedFromParser();			// does not take ownership			Parser* m_parser;			std::list< StatusHandler* > m_handlers;			std::list< Builder* > m_children;						bool m_err;						std::string m_progname;			Builder* m_parent;			bool m_generic_help_requested;			bool m_detailed_help_requested;						template< typename V >			class ParamInfo			{			public:				ParamInfo( const Setter< V >& setter,						   const Getter< V >& getter,						   const std::string& desc )					: m_setter( setter ),					  m_getter( getter ),					  m_desc( desc )				{}              				void				set( V value )				{ m_setter( value ); }				V				get() const				{ 					return m_getter(); 				}				const std::string&				desc() const				{ return m_desc; }			private:				Setter< V > m_setter;				Getter< V > m_getter;				const std::string m_desc;			};			typedef std::map< std::string, ParamInfo< int > > IntMap;			typedef std::map< std::string, ParamInfo< bool > > BoolMap;			typedef std::map< std::string, ParamInfo< double > > DoubMap;			typedef std::map< std::string, ParamInfo< std::string > > StrMap;			RCSSBASE_API			virtual			void			doRequestDetailedHelp( const std::string& module_name ); 			RCSSBASE_API			virtual			void			displayUsage( const std::string& progname );		  			RCSSBASE_API			virtual			void			displayGenericHelp();			RCSSBASE_API			virtual			void			displayDetailedHelp();			RCSSBASE_API			virtual			bool			doBuildParam( const std::string& module_name,						  const std::string& param_name,						  int value,						  const std::string& name,						  int lineno );		  			RCSSBASE_API			virtual			bool			doBuildParam( const std::string& module_name,						  const std::string& param_name,						  bool value,						  const std::string& name,						  int lineno );		  			RCSSBASE_API			virtual			bool			doBuildParam( const std::string& module_name,						  const std::string& param_name,						  double value,						  const std::string& name,						  int lineno );		  			RCSSBASE_API			virtual			bool			doBuildParam( const std::string& module_name,						  const std::string& param_name,						  const std::string& value,						  const std::string& name,						  int lineno );		  			RCSSBASE_API			virtual			void			doCreateConfFile( std::ostream& conf );			template< typename V >			void			addParam( const std::string& name, 					  const ParamInfo< V >& info );			RCSSBASE_API			bool			doBuildParam( const std::string& param_name, int value,						  const std::string& name,						  int lineno );			RCSSBASE_API			bool			doBuildParam( const std::string& param_name, bool value,						  const std::string& name,						  int lineno );			RCSSBASE_API			bool			doBuildParam( const std::string& param_name, double value,						  const std::string& name,						  int lineno );			RCSSBASE_API			bool			doBuildParam( const std::string& param_name, const std::string& value,						  const std::string& name,						  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< int > param,					  int value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< int > param,					  bool value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< int > param,					  double value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< int > param,					  const std::string& value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< bool > param,					  int value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< bool > param,					  bool value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< bool > param,					  double value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< bool > param,					  const std::string& value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,					  ParamInfo< double > param,					  int value,					  const std::string& name,					  int lineno );			RCSSBASE_API			bool			setParam( const std::string& param_name,

⌨️ 快捷键说明

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